Format code, fix PHP errors

pull/3064/head
Julio 5 years ago
parent 28c6356ccd
commit 748ce8a4fd
  1. 118
      public/main/forum/forumfunction.inc.php
  2. 22
      public/main/group/group.php
  3. 23
      public/main/group/group_category.php
  4. 30
      public/main/group/group_creation.php
  5. 16
      public/main/group/group_overview.php
  6. 110
      public/main/group/group_space.php
  7. 19
      public/main/group/import.php
  8. 28
      public/main/group/member_settings.php
  9. 44
      public/main/group/settings.php
  10. 25
      public/main/group/tutor_settings.php

@ -830,6 +830,7 @@ function store_forum($values, $courseInfo = [], $returnId = false)
->setEndTime(!empty($values['end_time']) ? api_get_utc_datetime($values['end_time']) : null)
->setSessionId($session_id)
->setLpId($values['lp_id'] ?? 0)
;
$user = api_get_user_entity(api_get_user_id());
@ -2353,84 +2354,6 @@ function getPosts(
return $list;
}
/**
* This function retrieves all the information of a post.
*
* @param int $post_id integer that indicates the forum
*
* @return array returns
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
* @version february 2006, dokeos 1.8
*/
function get_post_information($post_id)
{
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$table_users = Database::get_main_table(TABLE_MAIN_USER);
$course_id = api_get_course_int_id();
$post_id = (int) $post_id;
if (empty($post_id)) {
return [];
}
$sql = 'SELECT posts.*, email FROM '.$table_posts.' posts, '.$table_users." users
WHERE
c_id = $course_id AND
posts.poster_id=users.user_id AND
posts.post_id = ".$post_id;
$result = Database::query($sql);
return Database::fetch_array($result, 'ASSOC');
}
/**
* This function retrieves all the information of a thread.
*
* @param int $forumId
* @param integer $thread_id that indicates the forum
* @param int|null $sessionId Optional. If is null then it is considered the current session
*
* @return array returns
* @deprecated
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
* @version february 2006, dokeos 1.8
*/
function get_thread_information($forumId, $thread_id, $sessionId = null)
{
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$thread_id = (int) $thread_id;
$sessionId = null !== $sessionId ? (int) $sessionId : api_get_session_id();
$sessionCondition = api_get_session_condition(
$sessionId,
true,
false,
'threads.session_id'
);
$forumCondition = '';
if (!empty($forumId)) {
$forumId = (int) $forumId;
$forumCondition = " threads.forum_id = $forumId AND ";
}
$sql = "SELECT * FROM $table_item_property item_properties
INNER JOIN
$table_threads threads
ON (item_properties.ref = threads.thread_id AND threads.c_id = item_properties.c_id)
WHERE
$forumCondition
item_properties.tool= '".TOOL_FORUM_THREAD."' AND
threads.thread_id = $thread_id
$sessionCondition
";
$result = Database::query($sql);
return Database::fetch_assoc($result);
}
/**
* This function retrieves forum thread users details.
*
@ -2634,45 +2557,6 @@ function get_thread_users_not_qualify($thread_id)
return Database::query($sql);
}
/**
* This function retrieves all the information of a given forum_id.
*
* @param integer $forum_id that indicates the forum
*
* @return array returns
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
* @version february 2006, dokeos 1.8
*
* @deprecated this functionality is now moved to get_forums($forum_id)
*/
function get_forum_information($forum_id, $courseId = 0)
{
$table_forums = Database::get_course_table(TABLE_FORUM);
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$courseId = empty($courseId) ? api_get_course_int_id() : (int) $courseId;
$forum_id = (int) $forum_id;
$sql = "SELECT *
FROM $table_forums forums
INNER JOIN $table_item_property item_properties
ON (forums.c_id = item_properties.c_id)
WHERE
item_properties.tool = '".TOOL_FORUM."' AND
item_properties.ref = '".$forum_id."' AND
forums.forum_id = '".$forum_id."' AND
forums.c_id = ".$courseId.'
';
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
$row['approval_direct_post'] = 0;
// We can't anymore change this option, so it should always be activated.
return $row;
}
/**
* This function retrieves all the information of a given forumcategory id.
*

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
@ -14,8 +15,6 @@ use ChamiloSession as Session;
* @author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
* @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
* @author Isaac Flores, code cleaning and improvements
*
* @package chamilo.group
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -62,6 +61,7 @@ if (isset($_GET['action']) && $is_allowed_in_course) {
header("Location: $currentUrl");
exit;
}
break;
case 'set_invisible':
if (api_is_allowed_to_edit()) {
@ -70,6 +70,7 @@ if (isset($_GET['action']) && $is_allowed_in_course) {
header("Location: $currentUrl");
exit;
}
break;
case 'self_reg':
if (GroupManager::is_self_registration_allowed($userId, $groupInfo)) {
@ -82,6 +83,7 @@ if (isset($_GET['action']) && $is_allowed_in_course) {
header("Location: $currentUrl");
exit;
}
break;
case 'self_unreg':
if (GroupManager::is_self_unregistration_allowed($userId, $groupInfo)) {
@ -90,6 +92,7 @@ if (isset($_GET['action']) && $is_allowed_in_course) {
header("Location: $currentUrl");
exit;
}
break;
}
}
@ -112,6 +115,7 @@ if (api_is_allowed_to_edit(false, true)) {
header("Location: $currentUrl");
exit;
}
break;
case 'empty_selected':
if (is_array($_POST['group'])) {
@ -124,6 +128,7 @@ if (api_is_allowed_to_edit(false, true)) {
header("Location: $currentUrl");
exit;
}
break;
case 'fill_selected':
if (is_array($_POST['group'])) {
@ -135,6 +140,7 @@ if (api_is_allowed_to_edit(false, true)) {
header("Location: $currentUrl");
exit;
}
break;
}
}
@ -147,6 +153,7 @@ if (api_is_allowed_to_edit(false, true)) {
Display::addFlash(Display::return_message(get_lang('The category order was changed')));
header("Location: $currentUrl");
exit;
break;
case 'delete_one':
$groupInfo = GroupManager::get_group_properties($my_get_id);
@ -154,6 +161,7 @@ if (api_is_allowed_to_edit(false, true)) {
Display::addFlash(Display::return_message(get_lang('Group deleted')));
header("Location: $currentUrl");
exit;
break;
case 'fill_one':
$groupInfo = GroupManager::get_group_properties($my_get_id);
@ -161,6 +169,7 @@ if (api_is_allowed_to_edit(false, true)) {
Display::addFlash(Display::return_message(get_lang('Groups have been filled (or completed) by users present in the \'Users\' list.')));
header("Location: $currentUrl");
exit;
break;
case 'delete_category':
if (empty($sessionId)) {
@ -171,6 +180,7 @@ if (api_is_allowed_to_edit(false, true)) {
header("Location: $currentUrl");
exit;
}
break;
}
}
@ -188,7 +198,7 @@ if (api_is_allowed_to_edit(false, true)) {
$actionsLeft .= '<a href="group_creation.php?'.api_get_cidreq().'">'.
Display::return_icon('add-groups.png', get_lang('Create new group(s)'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_get_setting('allow_group_categories') === 'true' && empty($sessionId)) {
if ('true' === api_get_setting('allow_group_categories') && empty($sessionId)) {
$actionsLeft .= '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.
Display::return_icon('new_folder.png', get_lang('Add category'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
@ -219,7 +229,7 @@ echo $toolbar;
echo UserManager::getUserSubscriptionTab(3);
/* List all categories */
if (api_get_setting('allow_group_categories') === 'true') {
if ('true' === api_get_setting('allow_group_categories')) {
$defaultCategory = [
'id' => 0,
'iid' => 0,
@ -257,7 +267,7 @@ if (api_get_setting('allow_group_categories') === 'true') {
]
);
// Move
if ($index != 0) {
if (0 != $index) {
$actions .= ' <a href="group.php?'.api_get_cidreq().'&action=swap_cat_order&id1='.$categoryId.'&id2='.$group_cats[$index - 1]['id'].'">'.
Display::return_icon('up.png', '&nbsp;', '', ICON_SIZE_SMALL).'</a>';
}
@ -282,7 +292,7 @@ if (api_get_setting('allow_group_categories') === 'true') {
echo GroupManager::process_groups($group_list);
}
if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') {
if (!isset($_GET['origin']) || 'learnpath' != $_GET['origin']) {
Display::display_footer();
}

@ -1,9 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.group
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_GROUP;
@ -11,7 +9,7 @@ $current_course_tool = TOOL_GROUP;
// Notice for unauthorized people.
api_protect_course_script(true);
if (api_get_setting('allow_group_categories') == 'false') {
if ('false' == api_get_setting('allow_group_categories')) {
api_not_allowed(true);
}
@ -36,7 +34,7 @@ if (!empty($sessionId)) {
function check_max_number_of_members($value)
{
$max_member_no_limit = $value['max_member_no_limit'];
if ($max_member_no_limit == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
if (GroupManager::MEMBER_PER_GROUP_NO_LIMIT == $max_member_no_limit) {
return true;
}
$max_member = $value['max_member'];
@ -55,7 +53,7 @@ function check_groups_per_user($value)
{
$groups_per_user = (int) $value['groups_per_user'];
if (isset($_POST['id']) &&
$groups_per_user != GroupManager::GROUP_PER_MEMBER_NO_LIMIT &&
GroupManager::GROUP_PER_MEMBER_NO_LIMIT != $groups_per_user &&
GroupManager::get_current_max_groups_per_user($_POST['id']) > $groups_per_user) {
return false;
}
@ -123,14 +121,14 @@ $form->addText('title', get_lang('Title'));
// Groups per user
$possible_values = [];
for ($i = 1; $i <= 10; $i++) {
for ($i = 1; $i <= 10; ++$i) {
$possible_values[$i] = $i;
}
$possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All');
$group = [
$form->createElement('select', 'groups_per_user', null, $possible_values, ['id' => 'groups_per_user']),
$form->createElement('static', null, null, get_lang(' groups')),
$form->createElement('static', null, null, get_lang(' groups')),
];
$form->addGroup($group, 'limit_group', get_lang('A user can be member of maximum'), null, false);
$form->addRule('limit_group', get_lang('The maximum number of groups per user you submitted is invalid. There are now users who are subscribed in more groups than the number you propose.'), 'callback', 'check_groups_per_user');
@ -386,7 +384,7 @@ $currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq();
// If form validates -> save data
if ($form->validate()) {
$values = $form->exportValues();
if ($values['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
if (GroupManager::MEMBER_PER_GROUP_NO_LIMIT == $values['max_member_no_limit']) {
$max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else {
$max_member = $values['max_member'];
@ -415,7 +413,7 @@ if ($form->validate()) {
isset($values['document_access']) ? $values['document_access'] : 0
);
Display::addFlash(Display::return_message(get_lang('Group settings have been modified')));
header("Location: ".$currentUrl."&category=".$values['id']);
header('Location: '.$currentUrl.'&category='.$values['id']);
exit;
case 'add_category':
GroupManager::create_category(
@ -435,8 +433,9 @@ if ($form->validate()) {
isset($values['document_access']) ? $values['document_access'] : 0
);
Display::addFlash(Display::return_message(get_lang('Category created')));
header("Location: ".$currentUrl);
header('Location: '.$currentUrl);
exit;
break;
}
}
@ -452,7 +451,7 @@ echo '</div>';
$defaults = $category;
$defaults['action'] = $action;
if ($defaults['max_student'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
if (GroupManager::MEMBER_PER_GROUP_NO_LIMIT == $defaults['max_student']) {
$defaults['max_member_no_limit'] = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else {
$defaults['max_member_no_limit'] = 1;

@ -1,14 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.group
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_GROUP;
// Notice for unauthorized people.
api_protect_course_script(true);
if (!api_is_allowed_to_edit(false, true)) {
@ -28,7 +23,7 @@ if (isset($_POST['action'])) {
$useOnlyFirstCategory = true;
}
for ($i = 0; $i < $_POST['number_of_groups']; $i++) {
for ($i = 0; $i < $_POST['number_of_groups']; ++$i) {
$group1['name'] = empty($_POST['group_'.$i.'_name']) ? get_lang('Group').' '.$i : $_POST['group_'.$i.'_name'];
$group1['category'] = isset($_POST['group_'.$i.'_category']) ? $_POST['group_'.$i.'_category'] : null;
if ($useOnlyFirstCategory) {
@ -57,6 +52,7 @@ if (isset($_POST['action'])) {
Display::addFlash(Display::return_message(get_lang('group(s) has (have) been added')));
header('Location: '.$currentUrl);
exit;
break;
case 'create_subgroups':
GroupManager::create_subgroups(
@ -66,12 +62,14 @@ if (isset($_POST['action'])) {
Display::addFlash(Display::return_message(get_lang('group(s) has (have) been added')));
header('Location: '.$currentUrl);
exit;
break;
case 'create_class_groups':
GroupManager::create_class_groups($_POST['group_category']);
Display::addFlash(Display::return_message(get_lang('group(s) has (have) been added')));
header('Location: '.$currentUrl);
exit;
break;
}
}
@ -84,7 +82,7 @@ $interbreadcrumb[] = [
Display::display_header($nameTools, 'Group');
if (isset($_POST['number_of_groups'])) {
if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1) {
if (!is_numeric($_POST['number_of_groups']) || (int) ($_POST['number_of_groups']) < 1) {
echo Display::return_message(
get_lang('Please enter the desired number of groups').'<br /><br />
<a href="group_creation.php?'.api_get_cidreq().'">&laquo; '.get_lang('Back').'</a>',
@ -92,7 +90,7 @@ if (isset($_POST['number_of_groups'])) {
false
);
} else {
$number_of_groups = intval($_POST['number_of_groups']);
$number_of_groups = (int) ($_POST['number_of_groups']);
if ($number_of_groups > 1) {
?>
<script>
@ -167,16 +165,16 @@ EOT;
$group_el = [];
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('Group name').'</b>');
if (api_get_setting('allow_group_categories') === 'true') {
if ('true' === api_get_setting('allow_group_categories')) {
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('Group category').'</b>');
}
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('seats (optional)').'</b>');
$form->addGroup($group_el, 'groups', null, "</td><td>", false);
$form->addGroup($group_el, 'groups', null, '</td><td>', false);
// Checkboxes
if ($_POST['number_of_groups'] > 1) {
$group_el = [];
$group_el[] = $form->createElement('static', null, null, ' ');
if (api_get_setting('allow_group_categories') === 'true') {
if ('true' === api_get_setting('allow_group_categories')) {
$group_el[] = $form->createElement(
'checkbox',
'same_category',
@ -195,10 +193,10 @@ EOT;
$form->addGroup($group_el, 'groups', null, '</td><td>', false);
}
// Properties for all groups
for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number++) {
for ($group_number = 0; $group_number < $_POST['number_of_groups']; ++$group_number) {
$group_el = [];
$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
if (api_get_setting('allow_group_categories') === 'true') {
if ('true' === api_get_setting('allow_group_categories')) {
$group_el[] = $form->createElement(
'select',
'group_'.$group_number.'_category',
@ -254,7 +252,7 @@ EOT;
/*
* Show form to generate subgroups
*/
if (api_get_setting('allow_group_categories') === 'true') {
if ('true' === api_get_setting('allow_group_categories')) {
$groups = GroupManager::get_group_list();
if (!empty($groups)) {
$base_group_options = [];
@ -321,7 +319,7 @@ EOT;
$classForm->addHtml($description);
$classForm->addElement('hidden', 'action');
if (api_get_setting('allow_group_categories') === 'true') {
if ('true' === api_get_setting('allow_group_categories')) {
$group_categories = GroupManager :: get_categories();
$cat_options = [];
foreach ($group_categories as $index => $category) {

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -11,8 +12,6 @@
* @author Patrick Cool, show group comment under the group name
* @author Roan Embrechts, initial self-unsubscribe code, code cleaning, virtual course support
* @author Bart Mollet, code cleaning, use of Display-library, list of courseAdmin-tools, use of GroupManager
*
* @package chamilo.group
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
@ -33,6 +32,7 @@ if (isset($_GET['action'])) {
$data = GroupManager::exportCategoriesAndGroupsToArray(null, true);
Export::arrayToCsv($data);
exit;
break;
case 'export_pdf':
$content = GroupManager::getOverview($courseId, $keyword);
@ -42,22 +42,26 @@ if (isset($_GET['action'])) {
$content = $extra.$content;
$pdf->content_to_pdf($content, null, null, api_get_course_id());
break;
case 'export':
$groupId = isset($_GET['id']) ? intval($_GET['id']) : null;
$groupId = isset($_GET['id']) ? (int) ($_GET['id']) : null;
$data = GroupManager::exportCategoriesAndGroupsToArray($groupId, true);
switch ($_GET['type']) {
case 'csv':
Export::arrayToCsv($data);
exit;
break;
case 'xls':
if (!empty($data)) {
Export::arrayToXls($data);
exit;
}
break;
}
break;
}
}
@ -65,7 +69,7 @@ if (isset($_GET['action'])) {
/* Header */
$interbreadcrumb[] = ['url' => 'group.php?'.api_get_cidreq(), 'name' => get_lang('Groups')];
$origin = api_get_origin();
if ($origin != 'learnpath') {
if ('learnpath' != $origin) {
// So we are not in learnpath tool
if (!api_is_allowed_in_course()) {
api_not_allowed(true);
@ -84,7 +88,7 @@ if ($origin != 'learnpath') {
$actions = '<a href="group_creation.php?'.api_get_cidreq().'">'.
Display::return_icon('add.png', get_lang('Create new group(s)'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_get_setting('allow_group_categories') === 'true') {
if ('true' === api_get_setting('allow_group_categories')) {
$actions .= '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.
Display::return_icon('new_folder.png', get_lang('Add category'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
@ -113,6 +117,6 @@ Display::return_icon('user.png', get_lang('Go to').' '.get_lang('Users'), '', IC
echo Display::toolbarAction('actions', [$actions, GroupManager::getSearchForm()]);
echo GroupManager::getOverview($courseId, $keyword);
if ($origin != 'learnpath') {
if ('learnpath' != $origin) {
Display::display_footer();
}

@ -1,16 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script shows the group space for one specific group, possibly displaying
* a list of users in the group, subscribe or unsubscribe option, tutors...
*
* @package chamilo.group
*
* @todo Display error message if no group ID specified
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_GROUP;
// Notice for unauthorized people.
api_protect_course_script(true, false, 'group');
@ -85,7 +83,7 @@ echo '<a href="'.api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq()
*/
$subscribe_group = '';
if (GroupManager::is_self_registration_allowed($user_id, $current_group)) {
$subscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfReg=1&group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("Please confirm your choice"), ENT_QUOTES))."'".')) return false;">'.
$subscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfReg=1&group_id='.$current_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES))."'".')) return false;">'.
get_lang('Add me to this group').'</a>';
}
@ -94,7 +92,7 @@ if (GroupManager::is_self_registration_allowed($user_id, $current_group)) {
*/
$unsubscribe_group = '';
if (GroupManager :: is_self_unregistration_allowed($user_id, $current_group)) {
$unsubscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("Please confirm your choice"), ENT_QUOTES))."'".')) return false;">'.
$unsubscribe_group = '<a class="btn btn-default" href="'.api_get_self().'?selfUnReg=1" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES))."'".')) return false;">'.
get_lang('Unsubscribe me from this group.').'</a>';
}
echo '&nbsp;</div>';
@ -125,10 +123,10 @@ if (api_is_allowed_to_edit(false, true) ||
) {
$actions_array = [];
if (is_array($forums_of_groups)) {
if ($current_group['forum_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
if (GroupManager::TOOL_NOT_AVAILABLE != $current_group['forum_state']) {
foreach ($forums_of_groups as $key => $value) {
if ($value['forum_group_public_private'] == 'public' ||
($value['forum_group_public_private'] == 'private') ||
if ('public' == $value['forum_group_public_private'] ||
('private' == $value['forum_group_public_private']) ||
!empty($user_is_tutor) ||
api_is_allowed_to_edit(false, true)
) {
@ -146,7 +144,7 @@ if (api_is_allowed_to_edit(false, true) ||
}
}
if ($current_group['doc_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
if (GroupManager::TOOL_NOT_AVAILABLE != $current_group['doc_state']) {
// Link to the documents area of this group
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(),
@ -154,7 +152,7 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['calendar_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
if (GroupManager::TOOL_NOT_AVAILABLE != $current_group['calendar_state']) {
$groupFilter = '';
if (!empty($group_id)) {
$groupFilter = "&type=course&user_id=GROUP:$group_id";
@ -166,14 +164,14 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['work_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
if (GroupManager::TOOL_NOT_AVAILABLE != $current_group['work_state']) {
// Link to the works area of this group
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'content' => Display::return_icon('work.png', get_lang('Assignments'), [], 32),
];
}
if ($current_group['announcements_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
if (GroupManager::TOOL_NOT_AVAILABLE != $current_group['announcements_state']) {
// Link to a group-specific part of announcements
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.api_get_cidreq(),
@ -181,7 +179,7 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['wiki_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
if (GroupManager::TOOL_NOT_AVAILABLE != $current_group['wiki_state']) {
// Link to the wiki area of this group
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).'wiki/index.php?'.api_get_cidreq().'&action=show&title=index&session_id='.api_get_session_id().'&group_id='.$current_group['id'],
@ -189,30 +187,30 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['chat_state'] != GroupManager::TOOL_NOT_AVAILABLE) {
if (GroupManager::TOOL_NOT_AVAILABLE != $current_group['chat_state']) {
// Link to the chat area of this group
if (api_get_course_setting('allow_open_chat_window')) {
$actions_array[] = [
'url' => "javascript: void(0);",
'url' => 'javascript: void(0);',
'content' => Display::return_icon('chat.png', get_lang('Chat'), [], 32),
'url_attributes' => [
'onclick' => " window.open('../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id']."','window_chat_group_".api_get_course_id()."_".api_get_group_id()."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')",
'onclick' => " window.open('../chat/chat.php?".api_get_cidreq().'&toolgroup='.$current_group['id']."','window_chat_group_".api_get_course_id().'_'.api_get_group_id()."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')",
],
];
} else {
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id'],
'url' => api_get_path(WEB_CODE_PATH).'chat/chat.php?'.api_get_cidreq().'&toolgroup='.$current_group['id'],
'content' => Display::return_icon('chat.png', get_lang('Chat'), [], 32),
];
}
}
$enabled = api_get_plugin_setting('bbb', 'tool_enable');
if ($enabled === 'true') {
if ('true' === $enabled) {
$bbb = new bbb();
if ($bbb->hasGroupSupport()) {
$actions_array[] = [
'url' => api_get_path(WEB_PLUGIN_PATH)."bbb/start.php?".api_get_cidreq(),
'url' => api_get_path(WEB_PLUGIN_PATH).'bbb/start.php?'.api_get_cidreq(),
'content' => Display::return_icon('bbb.png', get_lang('Videoconference'), [], 32),
];
}
@ -224,9 +222,9 @@ if (api_is_allowed_to_edit(false, true) ||
} else {
$actions_array = [];
if (is_array($forums_of_groups)) {
if ($current_group['forum_state'] == GroupManager::TOOL_PUBLIC) {
if (GroupManager::TOOL_PUBLIC == $current_group['forum_state']) {
foreach ($forums_of_groups as $key => $value) {
if ($value['forum_group_public_private'] == 'public') {
if ('public' == $value['forum_group_public_private']) {
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).
'forum/viewforum.php?cid='.api_get_course_int_id().'&forum='.$value['forum_id'].'&gid='.Security::remove_XSS($current_group['id']).'&origin=group',
@ -242,7 +240,7 @@ if (api_is_allowed_to_edit(false, true) ||
}
}
if ($current_group['doc_state'] == GroupManager::TOOL_PUBLIC) {
if (GroupManager::TOOL_PUBLIC == $current_group['doc_state']) {
// Link to the documents area of this group
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(),
@ -250,7 +248,7 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['calendar_state'] == GroupManager::TOOL_PUBLIC) {
if (GroupManager::TOOL_PUBLIC == $current_group['calendar_state']) {
$groupFilter = '';
if (!empty($group_id)) {
$groupFilter = "&type=course&user_id=GROUP:$group_id";
@ -262,7 +260,7 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['work_state'] == GroupManager::TOOL_PUBLIC) {
if (GroupManager::TOOL_PUBLIC == $current_group['work_state']) {
// Link to the works area of this group
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
@ -270,7 +268,7 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['announcements_state'] == GroupManager::TOOL_PUBLIC) {
if (GroupManager::TOOL_PUBLIC == $current_group['announcements_state']) {
// Link to a group-specific part of announcements
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.api_get_cidreq(),
@ -278,7 +276,7 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['wiki_state'] == GroupManager::TOOL_PUBLIC) {
if (GroupManager::TOOL_PUBLIC == $current_group['wiki_state']) {
// Link to the wiki area of this group
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH).'wiki/index.php?'.api_get_cidreq().'&action=show&title=index&session_id='.api_get_session_id().'&group_id='.$current_group['id'],
@ -286,16 +284,16 @@ if (api_is_allowed_to_edit(false, true) ||
];
}
if ($current_group['chat_state'] == GroupManager::TOOL_PUBLIC) {
if (GroupManager::TOOL_PUBLIC == $current_group['chat_state']) {
// Link to the chat area of this group
if (api_get_course_setting('allow_open_chat_window')) {
$actions_array[] = [
'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id']."','window_chat_group_".api_get_course_id()."_".api_get_group_id()."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"",
'url' => "javascript: void(0);\" onclick=\"window.open('../chat/chat.php?".api_get_cidreq().'&toolgroup='.$current_group['id']."','window_chat_group_".api_get_course_id().'_'.api_get_group_id()."','height=380, width=625, left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no') \"",
'content' => Display::return_icon('chat.png', get_lang('Chat'), [], 32),
];
} else {
$actions_array[] = [
'url' => api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&toolgroup=".$current_group['id'],
'url' => api_get_path(WEB_CODE_PATH).'chat/chat.php?'.api_get_cidreq().'&toolgroup='.$current_group['id'],
'content' => Display::return_icon('chat.png', get_lang('Chat'), [], 32),
];
}
@ -311,7 +309,7 @@ if (api_is_allowed_to_edit(false, true) ||
*/
$tutors = GroupManager::get_subscribed_tutors($current_group);
$tutor_info = '';
if (count($tutors) == 0) {
if (0 == count($tutors)) {
$tutor_info = get_lang('(none)');
} else {
$tutor_info .= '<ul class="thumbnails">';
@ -342,7 +340,7 @@ $table = new SortableTable(
'group_users',
'get_number_of_group_users',
'get_group_user_data',
(api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1
api_is_western_name_order() xor api_sort_by_first_name() ? 2 : 1
);
$origin = api_get_origin();
$my_cidreq = isset($_GET['cid']) ? (int) $_GET['cid'] : 0;
@ -359,7 +357,7 @@ if (api_is_western_name_order()) {
$table->set_header(2, get_lang('First name'));
}
if (api_get_setting('show_email_addresses') == 'true' || api_is_allowed_to_edit() == 'true') {
if ('true' == api_get_setting('show_email_addresses') || 'true' == api_is_allowed_to_edit()) {
$table->set_header(3, get_lang('e-mail'));
$table->set_column_filter(3, 'email_filter');
$table->set_header(4, get_lang('active'));
@ -400,7 +398,7 @@ function get_number_of_group_users()
FROM $table
WHERE
c_id = $course_id AND
group_id = '".intval($groupInfo['iid'])."'";
group_id = '".(int) ($groupInfo['iid'])."'";
$result = Database::query($sql);
$return = Database::fetch_array($result, 'ASSOC');
@ -436,15 +434,15 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
$tableGroup = Database::get_course_table(TABLE_GROUP);
// Query
if (api_get_setting('show_email_addresses') === 'true') {
$sql = "SELECT user.id AS col0,
".(
if ('true' === api_get_setting('show_email_addresses')) {
$sql = 'SELECT user.id AS col0,
'.(
api_is_western_name_order() ?
"user.firstname AS col1,
user.lastname AS col2,"
'user.firstname AS col1,
user.lastname AS col2,'
:
"user.lastname AS col1,
user.firstname AS col2,"
'user.lastname AS col1,
user.firstname AS col2,'
)."
user.email AS col3
, user.active AS col4
@ -460,14 +458,14 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
LIMIT $from, $number_of_items";
} else {
if (api_is_allowed_to_edit()) {
$sql = "SELECT DISTINCT
$sql = 'SELECT DISTINCT
u.id AS col0,
".(api_is_western_name_order() ?
"u.firstname AS col1,
u.lastname AS col2,"
'.(api_is_western_name_order() ?
'u.firstname AS col1,
u.lastname AS col2,'
:
"u.lastname AS col1,
u.firstname AS col2,")."
'u.lastname AS col1,
u.firstname AS col2,')."
u.email AS col3
, u.active AS col4
FROM $table_user u
@ -481,15 +479,15 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
ORDER BY col$column $direction
LIMIT $from, $number_of_items";
} else {
$sql = "SELECT DISTINCT
$sql = 'SELECT DISTINCT
user.id AS col0,
".(
'.(
api_is_western_name_order() ?
"user.firstname AS col1,
user.lastname AS col2 "
'user.firstname AS col1,
user.lastname AS col2 '
:
"user.lastname AS col1,
user.firstname AS col2 "
'user.lastname AS col1,
user.firstname AS col2 '
)."
, user.active AS col3
FROM $table_user user
@ -562,9 +560,9 @@ function user_icon_filter($user_id)
* The parameters use a trick of the sorteable table, where the first param is
* the original value of the column
*
* @param string User name (value of the column at the time of calling)
* @param string URL parameters
* @param array Row of the "sortable table" as it is at the time of function call - we extract the user ID from there
* @param string $name User name (value of the column at the time of calling)
* @param string $url_params URL parameters
* @param array $row Row of the "sortable table" as it is at the time of function call - we extract the user ID from there
*
* @return string HTML link
*/
@ -575,6 +573,6 @@ function user_name_filter($name, $url_params, $row)
return UserManager::getUserProfileLink($userInfo);
}
if ($origin != 'learnpath') {
if ('learnpath' != $origin) {
Display::display_footer();
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -49,7 +50,7 @@ if ($form->validate()) {
!empty($_FILES['file']['tmp_name'])
) {
$groupData = Import::csv_reader($_FILES['file']['tmp_name']);
$deleteNotInArray = $form->getSubmitValue('delete_not_in_file') == 1 ? true : false;
$deleteNotInArray = 1 == $form->getSubmitValue('delete_not_in_file') ? true : false;
$result = GroupManager::importCategoriesAndGroupsFromArray(
$groupData,
@ -60,33 +61,33 @@ if ($form->validate()) {
$html = null;
foreach ($result as $status => $data) {
if ($status != 'error') {
if ('error' != $status) {
if (empty($data['category']) && empty($data['group'])) {
continue;
}
}
$html .= " <h3>".get_lang(ucfirst($status)).' </h3>';
$html .= ' <h3>'.get_lang(ucfirst($status)).' </h3>';
if (!empty($data['category'])) {
$html .= "<h4> ".get_lang('Categories').':</h4>';
$html .= '<h4> '.get_lang('Categories').':</h4>';
foreach ($data['category'] as $category) {
$html .= "<div>".$category['category']."</div>";
$html .= '<div>'.$category['category'].'</div>';
}
}
if (!empty($data['group'])) {
$html .= "<h4> ".get_lang('Groups').':</h4>';
$html .= '<h4> '.get_lang('Groups').':</h4>';
foreach ($data['group'] as $group) {
$html .= "<div>".$group['group']."</div>";
$html .= '<div>'.$group['group'].'</div>';
}
}
if ($status == 'error') {
if ('error' == $status) {
if (!empty($data)) {
foreach ($data as $message) {
if (!empty($message)) {
$html .= "<div>".$message."</div>";
$html .= '<div>'.$message.'</div>';
}
}
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -8,8 +9,6 @@
* @author various contributors
* @author Roan Embrechts (VUB), partial code cleanup, initial virtual course support
*
* @package chamilo.group
*
* @todo course admin functionality to create groups based on who is in which course (or class).
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -39,13 +38,13 @@ if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
function sort_users($user_a, $user_b)
{
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
if ('true' === $orderListByOfficialCode) {
$cmp = api_strcmp($user_a['official_code'], $user_b['official_code']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
@ -55,11 +54,11 @@ function sort_users($user_a, $user_b)
if (api_sort_by_first_name()) {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
@ -67,11 +66,11 @@ function sort_users($user_a, $user_b)
}
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
@ -85,7 +84,7 @@ function sort_users($user_a, $user_b)
*/
function check_group_members($value)
{
if ($value['max_student'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
if (GroupManager::MEMBER_PER_GROUP_NO_LIMIT == $value['max_student']) {
return true;
}
if (isset($value['max_student']) &&
@ -136,7 +135,7 @@ if (!empty($complete_user_list)) {
continue;
}
//prevent invitee users add to groups or tutors - see #8091
if ($user['status'] != INVITEE) {
if (INVITEE != $user['status']) {
$officialCode = !empty($user['official_code']) ? ' - '.$user['official_code'] : null;
$groups = $userGroup->getUserGroupListByUser($user['user_id']);
@ -149,8 +148,8 @@ if (!empty($complete_user_list)) {
$name = api_get_person_name($user['firstname'], $user['lastname']).
' ('.$user['username'].')'.$officialCode;
if ($orderUserListByOfficialCode === 'true') {
$officialCode = !empty($user['official_code']) ? $user['official_code']." - " : '? - ';
if ('true' === $orderUserListByOfficialCode) {
$officialCode = !empty($user['official_code']) ? $user['official_code'].' - ' : '? - ';
$name = $officialCode.' '.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
}
$possible_users[$user['user_id']] = $name.$groupNameListToString;
@ -197,7 +196,7 @@ if ($form->validate()) {
if (isset($_POST['group_members']) &&
count($_POST['group_members']) > $max_member &&
$max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT
GroupManager::MEMBER_PER_GROUP_NO_LIMIT != $max_member
) {
Display::addFlash(Display::return_message(get_lang('Number proposed exceeds max. that you allowed (you can modify in the group settings). Group composition has not been modified'), 'warning'));
header('Location: group.php?'.api_get_cidreq(true, false));
@ -215,6 +214,7 @@ switch ($action) {
GroupManager:: unsubscribe_all_users($current_group);
echo Display::return_message(get_lang('The group is now empty'), 'confirm');
}
break;
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -7,15 +8,10 @@
* @author various contributors
* @author Roan Embrechts (VUB), partial code cleanup, initial virtual course support
*
* @package chamilo.group
*
* @todo course admin functionality to create groups based on who is in which course (or class).
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_GROUP;
// Notice for unauthorized people.
api_protect_course_script(true);
$group_id = api_get_group_id();
@ -45,7 +41,7 @@ $form->addElement('html', '<div class="col-md-6">');
// Group name
$form->addElement('text', 'name', get_lang('Group name'));
if (api_get_setting('allow_group_categories') == 'true') {
if ('true' == api_get_setting('allow_group_categories')) {
$groupCategories = GroupManager::get_categories();
$categoryList = [];
//$categoryList[] = null;
@ -132,8 +128,8 @@ $form->addElement('html', '<div class="col-md-6">');
// Documents settings
$group = [
$form->createElement('radio', 'doc_state', get_lang('Documents'), get_lang('Not available'), GroupManager::TOOL_NOT_AVAILABLE),
$form->createElement('radio', 'doc_state', null, get_lang('Public access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'doc_state', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
$form->createElement('radio', 'doc_state', null, get_lang('Public access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'doc_state', null, get_lang('Private access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
];
$form->addGroup(
$group,
@ -198,8 +194,8 @@ $group = [
get_lang('Not available'),
GroupManager::TOOL_NOT_AVAILABLE
),
$form->createElement('radio', 'work_state', null, get_lang('Public access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'work_state', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
$form->createElement('radio', 'work_state', null, get_lang('Public access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'work_state', null, get_lang('Private access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
];
$form->addElement('html', '</div>');
@ -219,8 +215,8 @@ $form->addGroup(
// Calendar settings
$group = [
$form->createElement('radio', 'calendar_state', get_lang('Agenda'), get_lang('Not available'), GroupManager::TOOL_NOT_AVAILABLE),
$form->createElement('radio', 'calendar_state', null, get_lang('Public access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'calendar_state', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
$form->createElement('radio', 'calendar_state', null, get_lang('Public access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'calendar_state', null, get_lang('Private access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
];
$form->addElement('html', '</div>');
@ -245,9 +241,9 @@ $form->addElement('html', '<div class="col-md-6">');
// Announcements settings
$group = [
$form->createElement('radio', 'announcements_state', get_lang('Announcements'), get_lang('Not available'), GroupManager::TOOL_NOT_AVAILABLE),
$form->createElement('radio', 'announcements_state', null, get_lang('Public access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'announcements_state', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
$form->createElement('radio', 'announcements_state', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only)BetweenUsers'), GroupManager::TOOL_PRIVATE_BETWEEN_USERS),
$form->createElement('radio', 'announcements_state', null, get_lang('Public access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'announcements_state', null, get_lang('Private access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
$form->createElement('radio', 'announcements_state', null, get_lang('Private access (access authorized to group members only)BetweenUsers'), GroupManager::TOOL_PRIVATE_BETWEEN_USERS),
];
$form->addGroup(
@ -265,8 +261,8 @@ $form->addElement('html', '<div class="col-md-6">');
// Forum settings
$group = [
$form->createElement('radio', 'forum_state', get_lang('Group Forum'), get_lang('Not available'), GroupManager::TOOL_NOT_AVAILABLE),
$form->createElement('radio', 'forum_state', null, get_lang('Public access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'forum_state', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
$form->createElement('radio', 'forum_state', null, get_lang('Public access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'forum_state', null, get_lang('Private access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
];
$form->addGroup(
$group,
@ -287,8 +283,8 @@ $form->addElement('html', '<div class="col-md-6">');
// Wiki settings
$group = [
$form->createElement('radio', 'wiki_state', get_lang('Wiki'), get_lang('Not available'), GroupManager::TOOL_NOT_AVAILABLE),
$form->createElement('radio', 'wiki_state', null, get_lang('Public access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'wiki_state', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
$form->createElement('radio', 'wiki_state', null, get_lang('Public access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'wiki_state', null, get_lang('Private access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
];
$form->addGroup(
$group,
@ -304,8 +300,8 @@ $form->addElement('html', '<div class="col-md-6">');
// Chat settings
$group = [
$form->createElement('radio', 'chat_state', get_lang('Chat'), get_lang('Not available'), GroupManager::TOOL_NOT_AVAILABLE),
$form->createElement('radio', 'chat_state', null, get_lang('Public access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course) access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'chat_state', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only) access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
$form->createElement('radio', 'chat_state', null, get_lang('Public access (access authorized to any member of the course)'), GroupManager::TOOL_PUBLIC),
$form->createElement('radio', 'chat_state', null, get_lang('Private access (access authorized to group members only)'), GroupManager::TOOL_PRIVATE),
];
$form->addGroup(
$group,
@ -323,7 +319,7 @@ $form->addElement('html', '</div>');
if ($form->validate()) {
$values = $form->exportValues();
if ($values['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
if (GroupManager::MEMBER_PER_GROUP_NO_LIMIT == $values['max_member_no_limit']) {
$max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else {
$max_member = $values['max_member'];
@ -351,7 +347,7 @@ if ($form->validate()) {
);
if (isset($_POST['group_members']) &&
count($_POST['group_members']) > $max_member &&
$max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT
GroupManager::MEMBER_PER_GROUP_NO_LIMIT != $max_member
) {
Display::addFlash(Display::return_message(get_lang('Number proposed exceeds max. that you allowed (you can modify in the group settings). Group composition has not been modified'), 'warning'));
header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$categoryId);
@ -370,7 +366,7 @@ if (!empty($category)) {
$action = isset($_GET['action']) ? $_GET['action'] : '';
$defaults['action'] = $action;
if ($defaults['maximum_number_of_students'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
if (GroupManager::MEMBER_PER_GROUP_NO_LIMIT == $defaults['maximum_number_of_students']) {
$defaults['max_member_no_limit'] = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else {
$defaults['max_member_no_limit'] = 1;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -8,8 +9,6 @@
* @author various contributors
* @author Roan Embrechts (VUB), partial code cleanup, initial virtual course support
*
* @package chamilo.group
*
* @todo course admin functionality to create groups based on who is in which course (or class).
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -39,13 +38,13 @@ if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
function sort_users($user_a, $user_b)
{
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
if ('true' === $orderListByOfficialCode) {
$cmp = api_strcmp($user_a['official_code'], $user_b['official_code']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
@ -55,11 +54,11 @@ function sort_users($user_a, $user_b)
if (api_sort_by_first_name()) {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
@ -67,11 +66,11 @@ function sort_users($user_a, $user_b)
}
} else {
$cmp = api_strcmp($user_a['lastname'], $user_b['lastname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
$cmp = api_strcmp($user_a['firstname'], $user_b['firstname']);
if ($cmp !== 0) {
if (0 !== $cmp) {
return $cmp;
} else {
return api_strcmp($user_a['username'], $user_b['username']);
@ -122,7 +121,7 @@ if (!empty($complete_user_list)) {
}
//prevent invitee users add to groups or tutors - see #8091
if ($user['status'] != INVITEE) {
if (INVITEE != $user['status']) {
$officialCode = !empty($user['official_code']) ? ' - '.$user['official_code'] : null;
$groups = $userGroup->getUserGroupListByUser($user['user_id']);
@ -137,8 +136,8 @@ if (!empty($complete_user_list)) {
$user['lastname']
).' ('.$user['username'].')'.$officialCode;
if ($orderUserListByOfficialCode === 'true') {
$officialCode = !empty($user['official_code']) ? $user['official_code']." - " : '? - ';
if ('true' === $orderUserListByOfficialCode) {
$officialCode = !empty($user['official_code']) ? $user['official_code'].' - ' : '? - ';
$name = $officialCode.' '.api_get_person_name(
$user['firstname'],
$user['lastname']
@ -175,7 +174,7 @@ if ($form->validate()) {
if (isset($_POST['group_members']) &&
count($_POST['group_members']) > $max_member &&
$max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT
GroupManager::MEMBER_PER_GROUP_NO_LIMIT != $max_member
) {
Display::addFlash(Display::return_message(get_lang('Number proposed exceeds max. that you allowed (you can modify in the group settings). Group composition has not been modified'), 'warning'));
header('Location: group.php?'.api_get_cidreq(true, false));

Loading…
Cancel
Save