diff --git a/main/group/group.php b/main/group/group.php index 270c5455e2..ef3548c017 100755 --- a/main/group/group.php +++ b/main/group/group.php @@ -1,56 +1,31 @@ -'; //jQuery $htmlHeadXtra[] = ''; $nameTools = get_lang('GroupManagement'); -/* ------------------------------------------------------------ - Libraries ------------------------------------------------------------ -*/ -require_once (api_get_path(LIBRARY_PATH).'course.lib.php'); -require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); +/* Libraries */ -//Create default category if it doesn't exist when group categories aren't allowed -if( api_get_setting('allow_group_categories') == 'false') -{ +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; + +// Create default category if it doesn't exist when group categories aren't allowed +if (api_get_setting('allow_group_categories') == 'false') { $cat_table = Database::get_course_table(TABLE_GROUP_CATEGORY); $sql = "SELECT * FROM $cat_table WHERE id = '".DEFAULT_GROUP_CATEGORY."'"; $res = Database::query($sql); $num = Database::num_rows($res); - if($num == 0) - { + if ($num == 0) { Database::query("INSERT INTO ".$cat_table." ( id , title , description , forum_state , wiki_state, max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order ) VALUES ('2', '".lang2db($DefaultGroupCategory)."', '', '1', '1', '8', '0', '0', '0', '0');"); } } -/* ------------------------------------------------------------ - Header ------------------------------------------------------------ -*/ -if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') -{ //so we are not in learnpath tool +/* Header */ + +if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') { + // So we are not in learnpath tool event_access_tool(TOOL_GROUP); - if (! $is_allowed_in_course) api_not_allowed(true); + if (!$is_allowed_in_course) { + api_not_allowed(true); + } } Display::display_header(get_lang('Groups')); @@ -109,21 +78,17 @@ Display::display_introduction_section(TOOL_GROUP); $my_get_id2 = Security::remove_XSS($_GET['id2']); $my_get_id = Security::remove_XSS($_GET['id']); -if (isset ($_GET['action'])) -{ - switch ($_GET['action']) - { +if (isset($_GET['action'])) { + switch ($_GET['action']) { case 'self_reg' : - if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $my_group_id)) - { - GroupManager :: subscribe_users($_SESSION['_user']['user_id'],$my_group_id); + if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $my_group_id)) { + GroupManager :: subscribe_users($_SESSION['_user']['user_id'], $my_group_id); Display :: display_confirmation_message(get_lang('GroupNowMember')); } break; case 'self_unreg' : - if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $my_group_id)) - { - GroupManager :: unsubscribe_users($_SESSION['_user']['user_id'],$my_group_id); + if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $my_group_id)) { + GroupManager :: unsubscribe_users($_SESSION['_user']['user_id'], $my_group_id); Display :: display_confirmation_message(get_lang('StudentDeletesHimself')); } break; @@ -132,62 +97,56 @@ if (isset ($_GET['action'])) break; } } + /* * Group-admin functions */ -if (api_is_allowed_to_edit(false,true)) -{ +if (api_is_allowed_to_edit(false, true)) { // Post-actions - if (isset ($_POST['action'])) - { - switch ($_POST['action']) - { + if (isset($_POST['action'])) { + switch ($_POST['action']) { case 'delete_selected' : - if( is_array($_POST['group'])) - { + if (is_array($_POST['group'])) { GroupManager :: delete_groups($my_group); Display :: display_confirmation_message(get_lang('SelectedGroupsDeleted')); } break; case 'empty_selected' : - if( is_array($_POST['group'])) - { + if (is_array($_POST['group'])) { GroupManager :: unsubscribe_all_users($my_group); Display :: display_confirmation_message(get_lang('SelectedGroupsEmptied')); } break; case 'fill_selected' : - if( is_array($_POST['group'])) - { + if (is_array($_POST['group'])) { GroupManager :: fill_groups($my_group); Display :: display_confirmation_message(get_lang('SelectedGroupsFilled')); } break; } } + // Get-actions - if (isset ($_GET['action'])) - { - switch ($_GET['action']) - { - case 'swap_cat_order' : - GroupManager :: swap_category_order($my_get_id1,$my_get_id2); + if (isset($_GET['action'])) { + switch ($_GET['action']) { + case 'swap_cat_order': + GroupManager :: swap_category_order($my_get_id1, $my_get_id2); Display :: display_confirmation_message(get_lang('CategoryOrderChanged')); break; - case 'delete_one' : + case 'delete_one': GroupManager :: delete_groups($my_get_id); Display :: display_confirmation_message(get_lang('GroupDel')); break; - case 'empty_one' : + case 'empty_one': GroupManager :: unsubscribe_all_users($my_get_id); Display :: display_confirmation_message(get_lang('GroupEmptied')); break; - case 'fill_one' : + case 'fill_one': GroupManager :: fill_groups($my_get_id); Display :: display_confirmation_message(get_lang('GroupFilledGroups')); break; - case 'delete_category' : + case 'delete_category': GroupManager :: delete_category($my_get_id); Display :: display_confirmation_message(get_lang('CategoryDeleted')); break; @@ -196,10 +155,9 @@ if (api_is_allowed_to_edit(false,true)) } echo '
'.$category['description'].'
'; + } else { + $group_list = GroupManager :: get_group_list(); + $in_category = true; } - else { - $group_list = GroupManager :: get_group_list(); - $in_category = true; - } //if (count($group_list) > 0 && $in_category) - if ($in_category) - { + if ($in_category) { $totalRegistered = 0; // Determine wether current user is tutor for this course $user_is_tutor = GroupManager :: is_tutor($_user['user_id']); - $group_data = array (); + $group_data = array(); foreach ($group_list as $index => $this_group) { - //validacion when belongs to a session + // Validacion when belongs to a session $session_img = api_get_session_image($this_group['session_id'], $_user['status']); - // all the tutors of this group - $tutorsids_of_group=GroupManager::get_subscribed_tutors($this_group['id'],true); + // All the tutors of this group + $tutorsids_of_group=GroupManager::get_subscribed_tutors($this_group['id'], true); - // create a new table-row + // Create a new table-row $row = array (); - // checkbox - if (api_is_allowed_to_edit(false,true) && count($group_list) > 1) - { + // Checkbox + if (api_is_allowed_to_edit(false,true) && count($group_list) > 1) { $row[] = $this_group['id']; } - // group name - if ((api_is_allowed_to_edit(false,true) || - in_array($_user['user_id'],$tutorsids_of_group) || + // Group name + if ((api_is_allowed_to_edit(false, true) || + in_array($_user['user_id'], $tutorsids_of_group) || $this_group['is_member'] || - GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_FORUM) || - GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_DOCUMENTS) || - GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_CALENDAR) || - GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_ANNOUNCEMENT) || - GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_WORK) || - GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_WIKI)) - && !(api_is_course_coach() && intval($this_group['session_id'])!=intval($_SESSION['id_session']))) - { - isset($origin)?$orig=$origin:$orig=null; + GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_FORUM) || + GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_DOCUMENTS) || + GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_CALENDAR) || + GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_ANNOUNCEMENT) || + GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_WORK) || + GroupManager::user_has_access($_user['user_id'], $this_group['id'], GROUP_TOOL_WIKI)) + && !(api_is_course_coach() && intval($this_group['session_id']) != intval($_SESSION['id_session']))) { + $orig = isset($origin) ? $origin : null; $group_name = ''.stripslashes($this_group['name']).''; - if (!empty($_SESSION['_user']['user_id']) && !empty($this_group['id_tutor']) && $_SESSION['_user']['user_id'] == $this_group['id_tutor']) - { + if (!empty($_SESSION['_user']['user_id']) && !empty($this_group['id_tutor']) && $_SESSION['_user']['user_id'] == $this_group['id_tutor']) { $group_name .= ' ('.get_lang('OneMyGroups').')'; - } - elseif ($this_group['is_member']) - { + } elseif ($this_group['is_member']) { $group_name .= ' ('.get_lang('MyGroup').')'; } - if(api_is_allowed_to_edit() && !empty($this_group['session_name'])) - { + if (api_is_allowed_to_edit() && !empty($this_group['session_name'])) { $group_name .= ' ('.$this_group['session_name'].')'; } $group_name .= $session_img; - $row[] = $group_name.''; - if (count($categories) > 1 || isset ($categories[0]) && $categories[0]['id'] != VIRTUAL_COURSE_CATEGORY) - { + if (count($categories) > 1 || isset ($categories[0]) && $categories[0]['id'] != VIRTUAL_COURSE_CATEGORY) { $create_groups_form = new FormValidator('create_groups'); $create_groups_form->addElement('header', '', $nameTools); $group_el = array (); $group_el[] = & $create_groups_form->createElement('static', null, null, get_lang('Create')); - $group_el[] = & $create_groups_form->createElement('text', 'number_of_groups', null, array ('size' => 3)); + $group_el[] = & $create_groups_form->createElement('text', 'number_of_groups', null, array('size' => 3)); $group_el[] = & $create_groups_form->createElement('static', null, null, get_lang('NewGroups')); $group_el[] = & $create_groups_form->createElement('style_submit_button', 'submit', get_lang('ProceedToCreateGroup'), 'class="save"'); $create_groups_form->addGroup($group_el, 'create_groups', null, ' ', false); - $defaults = array (); + $defaults = array(); $defaults['number_of_groups'] = 1; $create_groups_form->setDefaults($defaults); $create_groups_form->display(); - } - else - { + } else { echo get_lang('NoCategoriesDefined'); } //echo ''; + /* * Show form to generate groups from virtual courses */ $virtual_courses = CourseManager :: get_virtual_courses_linked_to_real_course($_course['sysCode']); - if (count($virtual_courses) > 0) - { + if (count($virtual_courses) > 0) { echo ''.get_lang('CreateGroupsFromVirtualCourses').''; echo '
'; echo get_lang('CreateGroupsFromVirtualCoursesInfo'); $create_virtual_groups_form = new FormValidator('create_virtual_groups'); $create_virtual_groups_form->addElement('hidden', 'action'); $create_virtual_groups_form->addElement('submit', 'submit', get_lang('Ok')); - $create_virtual_groups_form->setDefaults(array ('action' => 'create_virtual_groups')); + $create_virtual_groups_form->setDefaults(array('action' => 'create_virtual_groups')); $create_virtual_groups_form->display(); echo ''; } + /* * Show form to generate subgroups */ - if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) - { + if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) { $base_group_options = array (); $groups = GroupManager :: get_group_list(); - foreach ($groups as $index => $group) - { + foreach ($groups as $index => $group) { $number_of_students = GroupManager :: number_of_students($group['id']); - if ($number_of_students > 0) - { + if ($number_of_students > 0) { $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')'; } } - if (count($base_group_options) > 0) - { + if (count($base_group_options) > 0) { echo ''.get_lang('CreateSubgroups').''; echo '
'; echo ''; } } + /* * Show form to generate groups from classes subscribed to the course */ $classes = ClassManager :: get_classes_in_course($_course['sysCode']); - if (count($classes) > 0) - { + if (count($classes) > 0) { echo ''.get_lang('GroupsFromClasses').''; echo ''.get_lang('CreateSubgroupsInfo').'
'; $create_subgroups_form = new FormValidator('create_subgroups'); $create_subgroups_form->addElement('hidden', 'action'); - $group_el = array (); + $group_el = array(); $group_el[] = & $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups')); - $group_el[] = & $create_subgroups_form->createElement('text', 'number_of_groups', null, array ('size' => 3)); + $group_el[] = & $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3)); $group_el[] = & $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom')); $group_el[] = & $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options); $group_el[] = & $create_subgroups_form->createElement('submit', 'submit', get_lang('Ok')); $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false); - $defaults = array (); + $defaults = array(); $defaults['action'] = 'create_subgroups'; $create_subgroups_form->setDefaults($defaults); $create_subgroups_form->display(); echo '
'; echo ''; } } -/* -=============================================================================== - DOKEOS FOOTER -=============================================================================== -*/ + +/* FOOTER */ + Display :: display_footer(); -?> diff --git a/main/group/group_edit.php b/main/group/group_edit.php index b939e3ac9c..daa5eb5cf6 100755 --- a/main/group/group_edit.php +++ b/main/group/group_edit.php @@ -1,83 +1,48 @@ "group.php", "name" => get_lang('Groups')); +$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups')); if (!api_is_allowed_to_edit(false,true)) { api_not_allowed(true); } -/* -============================================================================== - FUNCTIONS -============================================================================== -*/ + +/* FUNCTIONS */ /** * function to sort users after getting the list in the db. Necessary because there are 2 or 3 queries. Called by usort() */ - function sort_users($user_a, $user_b) { if (api_sort_by_first_name()) { $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']); @@ -117,6 +82,7 @@ function check_max_number_of_members($value) { $max_member = $value['max_member']; return is_numeric($max_member); } + /** * Function to check if the number of selected group members is valid */ @@ -129,17 +95,15 @@ function check_group_members($value) { } return true; } -/* -============================================================================== - MAIN CODE -============================================================================== -*/ + +/* MAIN CODE */ // Build form $form = new FormValidator('group_edit'); $form->addElement('header', '', $nameTools); $form->addElement('hidden', 'action'); $form->addElement('hidden', 'referer'); + // Group name $form->add_textfield('name', get_lang('GroupName')); @@ -160,9 +124,9 @@ $form->addElement('textarea', 'description', get_lang('Description'), array ('co // Members per group $form->addElement('radio', 'max_member_no_limit', get_lang('GroupLimit'), get_lang('NoLimit'), MEMBER_PER_GROUP_NO_LIMIT); -$group = array (); +$group = array(); $group[] = & $form->createElement('radio', 'max_member_no_limit', null, get_lang('MaximumOfParticipants'), 1); -$group[] = & $form->createElement('text', 'max_member', null, array ('size' => 2)); +$group[] = & $form->createElement('text', 'max_member', null, array('size' => 2)); $group[] = & $form->createElement('static', null, null, get_lang('GroupPlacesThis')); $form->addGroup($group, 'max_member_group', null, '', false); $form->addRule('max_member_group', get_lang('InvalidMaxNumberOfMembers'), 'callback', 'check_max_number_of_members'); @@ -206,27 +170,25 @@ $form->addElement('radio', 'chat_state', get_lang('Chat'), get_lang('NotAvailabl $form->addElement('radio', 'chat_state', null, get_lang('Public'), TOOL_PUBLIC); $form->addElement('radio', 'chat_state', null, get_lang('Private'), TOOL_PRIVATE); -// getting all the users +// Getting all the users if (isset($_SESSION['id_session'])) { - $complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id'],true,$_SESSION['id_session']); - $complete_user_list2 = CourseManager :: get_coach_list_from_course_code($_course['id'],$_SESSION['id_session']); - $complete_user_list = array_merge($complete_user_list,$complete_user_list2); + $complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id'], true, $_SESSION['id_session']); + $complete_user_list2 = CourseManager :: get_coach_list_from_course_code($_course['id'], $_SESSION['id_session']); + $complete_user_list = array_merge($complete_user_list, $complete_user_list2); } else { $complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id']); } usort($complete_user_list, 'sort_users'); - -$possible_users = array (); +$possible_users = array(); foreach ($complete_user_list as $index => $user) { $possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')'; } -//print_r($complete_user_list2); // Group tutors $group_tutor_list = GroupManager :: get_subscribed_tutors($current_group['id']); -$selected_users = array (); +$selected_users = array(); $selected_tutors = array(); foreach ($group_tutor_list as $index => $user) { //$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], .$user['lastname']); @@ -247,8 +209,8 @@ $group_tutors_element->setElementTemplate(' '); -$group_tutors_element->setButtonAttributes('add',array('class'=>'arrowr')); -$group_tutors_element->setButtonAttributes('remove',array('class'=>'arrowl')); +$group_tutors_element->setButtonAttributes('add', array('class' => 'arrowr')); +$group_tutors_element->setButtonAttributes('remove', array('class' => 'arrowl')); // Group members $group_member_list = GroupManager :: get_subscribed_users($current_group['id']); @@ -272,8 +234,8 @@ $group_members_element->setElementTemplate(' '); -$group_members_element->setButtonAttributes('add',array('class'=>'arrowr')); -$group_members_element->setButtonAttributes('remove',array('class'=>'arrowl')); +$group_members_element->setButtonAttributes('add', array('class' => 'arrowr')); +$group_members_element->setButtonAttributes('remove', array('class' => 'arrowl')); $form->addFormRule('check_group_members'); // submit button @@ -286,31 +248,31 @@ if ($form->validate()) { } else { $max_member = $values['max_member']; } - $self_registration_allowed = isset ($values['self_registration_allowed']) ? 1 : 0; - $self_unregistration_allowed = isset ($values['self_unregistration_allowed']) ? 1 : 0; - GroupManager :: set_group_properties($current_group['id'], strip_tags($values['name']), strip_tags($values['description']), $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'],$values['wiki_state'], $values['chat_state'], $self_registration_allowed, $self_unregistration_allowed); + $self_registration_allowed = isset($values['self_registration_allowed']) ? 1 : 0; + $self_unregistration_allowed = isset($values['self_unregistration_allowed']) ? 1 : 0; + GroupManager :: set_group_properties($current_group['id'], strip_tags($values['name']), strip_tags($values['description']), $max_member, $values['doc_state'], $values['work_state'], $values['calendar_state'], $values['announcements_state'], $values['forum_state'], $values['wiki_state'], $values['chat_state'], $self_registration_allowed, $self_unregistration_allowed); - // storing the tutors (we first remove all the tutors and then add only those who were selected) + // Storing the tutors (we first remove all the tutors and then add only those who were selected) GroupManager :: unsubscribe_all_tutors($current_group['id']); if (isset ($_POST['group_tutors']) && count($_POST['group_tutors']) > 0) { GroupManager :: subscribe_tutors($values['group_tutors'], $current_group['id']); } - // storing the users (we first remove all users and then add only those who were selected) + // Storing the users (we first remove all users and then add only those who were selected) GroupManager :: unsubscribe_all_users($current_group['id']); if (isset ($_POST['group_members']) && count($_POST['group_members']) > 0) { GroupManager :: subscribe_users($values['group_members'], $current_group['id']); } - // returning to the group area (note: this is inconsistent with the rest of dokeos) + // Returning to the group area (note: this is inconsistent with the rest of chamilo) $cat = GroupManager :: get_category_from_group($current_group['id']); header('Location: '.$values['referer'].'?action=show_msg&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); - } + $defaults = $current_group; $defaults['group_members'] = $selected_users; $defaults['group_tutors'] = $selected_tutors; -isset($_GET['action'])?$action=$_GET['action']:$action=''; +$action = isset($_GET['action']) ? $_GET['action'] : ''; $defaults['action'] = $action; if ($defaults['maximum_number_of_students'] == MEMBER_PER_GROUP_NO_LIMIT) { $defaults['max_member_no_limit'] = MEMBER_PER_GROUP_NO_LIMIT; @@ -324,17 +286,18 @@ if ($referer != 'group_space.php' && $referer != 'group.php') { $referer = 'group.php'; } if (isset($_POST['group_members'])) { - if (count($_POST['group_members'])<=$defaults['max_member']) { + if (count($_POST['group_members']) <= $defaults['max_member']) { // } else { - header('Location:group_edit.php?show_message='.get_lang('GroupTooMuchMembers')); + header('Location:group_edit.php?show_message='.get_lang('GroupTooMuchMembers')); } } -Display :: display_header($nameTools, "Group"); + +Display :: display_header($nameTools, 'Group'); ?> setDefaults($defaults); $form->display(); -/* -============================================================================== - FOOTER -============================================================================== -*/ + +/* FOOTER */ + Display :: display_footer(); -?> diff --git a/main/group/group_overview.php b/main/group/group_overview.php index d19c160e3e..eba5fa50d7 100755 --- a/main/group/group_overview.php +++ b/main/group/group_overview.php @@ -1,76 +1,43 @@ - $group) - { + foreach ($groups as $index => $group) { $users = GroupManager::get_users($group['id']); - foreach($users as $index => $user) - { + foreach ($users as $index => $user) { $row = array(); $user = api_get_user_info($user); $row[] = $group['name']; @@ -80,7 +47,7 @@ if( isset($_GET['action'])) $data[] = $row; } } - switch($_GET['type']) { + switch ($_GET['type']) { case 'csv': Export::export_table_csv($data); exit; @@ -92,24 +59,24 @@ if( isset($_GET['action'])) } } -/* ------------------------------------------------------------ - Header ------------------------------------------------------------ -*/ -$interbreadcrumb[]=array("url" => "group.php","name" => get_lang('Groups')); -if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') -{ //so we are not in learnpath tool - if (! $is_allowed_in_course) api_not_allowed(true); - if (!api_is_allowed_to_edit(false,true)) api_not_allowed(true); - else Display::display_header($nameTools,"Group"); -} -else -{ -?> 'group.php', 'name' => get_lang('Groups')); +if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') { + // So we are not in learnpath tool + if (!$is_allowed_in_course) { + api_not_allowed(true); + } + if (!api_is_allowed_to_edit(false, true)) { + api_not_allowed(true); + } else { + Display::display_header($nameTools, 'Group'); + } +} else { +?> '; echo Display::return_icon('groupadd.gif', get_lang('NewGroupCreate')) . ''.get_lang('NewGroupCreate').''; echo Display::return_icon('group.gif', get_lang('Groups')) .''.get_lang('Groups').''; @@ -124,22 +91,18 @@ echo Display::return_icon('excel.gif', get_lang('ExportAsXLS')).' "group.php", "name" => get_lang("Groups")); +$this_section = SECTION_COURSES; +$nameTools = get_lang('GroupSpace'); +$interbreadcrumb[] = array ('url' => 'group.php', 'name' => get_lang('Groups')); -/* ------------------------------------------------------------ - Ensure all private groups // Juan Carlos Ra�a Trabado ------------------------------------------------------------ -*/ +/* Ensure all private groups // Juan Carlos Raña Trabado */ $forums_of_groups = get_forums_of_group($current_group['id']); -$forum_state_public=0; +$forum_state_public = 0; if (is_array($forums_of_groups)) { foreach ($forums_of_groups as $key => $value) { if($value['forum_group_public_private'] == 'public') { - $forum_state_public=1; + $forum_state_public = 1; } } } -if ($current_group['doc_state']!=1 and $current_group['calendar_state']!=1 and $current_group['work_state']!=1 and $current_group['announcements_state']!=1 and $current_group['wiki_state']!=1 and $current_group['chat_state']!=1 and $forum_state_public!=1) { - if (!api_is_allowed_to_edit(null,true) and !GroupManager :: is_user_in_group($_user['user_id'], $current_group['id'])) { +if ($current_group['doc_state'] != 1 && $current_group['calendar_state'] != 1 && $current_group['work_state'] != 1 && $current_group['announcements_state'] != 1 && $current_group['wiki_state'] != 1 && $current_group['chat_state'] != 1 && $forum_state_public != 1) { + if (!api_is_allowed_to_edit(null,true) && !GroupManager :: is_user_in_group($_user['user_id'], $current_group['id'])) { echo api_not_allowed($print_headers); } } -/* ------------------------------------------------------------ - Header ------------------------------------------------------------ -*/ -Display::display_header($nameTools.' '.stripslashes($current_group['name']),"Group"); -/* ------------------------------------------------------------ - Introduction section - (editable by course admin) ------------------------------------------------------------ -*/ +/* Header */ + +Display::display_header($nameTools.' '.stripslashes($current_group['name']), 'Group'); + +/* Introduction section (editable by course admin) */ + Display::display_introduction_section(group_space_.$_SESSION['_gid']); -/* ------------------------------------------------------------ - Actions and Action links ------------------------------------------------------------ -*/ +/* Actions and Action links */ + /* * User wants to register in this group */ @@ -124,38 +83,36 @@ echo ''.Display::return_icon('back.png',get_lang('BackToGrou /* * Edit the group */ -if (api_is_allowed_to_edit(false,true) or GroupManager :: is_tutor($_user['user_id'])) { - isset($origin)?$my_origin = $origin:$my_origin=''; - echo Display::return_icon('edit.gif', get_lang("EditGroup"))."".get_lang("EditGroup").""; +if (api_is_allowed_to_edit(false, true) or GroupManager :: is_tutor($_user['user_id'])) { + $my_origin = isset($origin) ? $origin : ''; + echo Display::return_icon('edit.gif', get_lang('EditGroup')).''.get_lang('EditGroup').''; } /* * Register to group */ if (GroupManager :: is_self_registration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) { - echo ''.Display::return_icon('groupadd.gif').get_lang("RegIntoGroup").''; + echo ''.Display::return_icon('groupadd.gif').get_lang("RegIntoGroup").''; } /* * Unregister from group */ if (GroupManager :: is_self_unregistration_allowed($_SESSION['_user']['user_id'], $current_group['id'])) { - echo ''.Display::return_icon('group_delete.gif').get_lang("StudentUnsubscribe").''; + echo ''.Display::return_icon('group_delete.gif').get_lang("StudentUnsubscribe").''; } echo ' '; -if( isset($_GET['action'])) { - switch( $_GET['action']) { +if (isset($_GET['action'])) { + switch ($_GET['action']) { case 'show_msg': Display::display_normal_message(Security::remove_XSS($_GET['msg'])); break; } } -/* ------------------------------------------------------------ - Main Display Area ------------------------------------------------------------ -*/ + +/* Main Display Area */ + $course_code = $_course['sysCode']; $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course($_SESSION['_user']['user_id'], $course_code); @@ -167,174 +124,143 @@ $is_course_member = CourseManager :: is_user_subscribed_in_real_or_linked_course if (!empty($current_group['description'])) { echo ''.get_lang('GroupsFromClassesInfo').'
'; echo ''; - foreach ($classes as $index => $class) - { + foreach ($classes as $index => $class) { $number_of_users = count(ClassManager :: get_users($class['id'])); echo '
- '; echo $class['name']; @@ -389,22 +312,17 @@ else $create_class_groups_form = new FormValidator('create_class_groups_form'); $create_class_groups_form->addElement('hidden', 'action'); - if (api_get_setting('allow_group_categories') == 'true') - { + if (api_get_setting('allow_group_categories') == 'true') { $group_categories = GroupManager :: get_categories(); $cat_options = array (); - foreach ($group_categories as $index => $category) - { + foreach ($group_categories as $index => $category) { // Don't allow new groups in the virtual course category! - if ($category['id'] != VIRTUAL_COURSE_CATEGORY) - { + if ($category['id'] != VIRTUAL_COURSE_CATEGORY) { $cat_options[$category['id']] = $category['title']; } } $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); - } - else - { + } else { $create_class_groups_form->addElement('hidden', 'group_category'); } $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); @@ -415,10 +333,7 @@ else echo '
'.stripslashes($current_group['description']).''; } + /* * Group Tools */ // If the user is subscribed to the group or the user is a tutor of the group then -if (api_is_allowed_to_edit(false,true) OR GroupManager :: is_user_in_group($_SESSION['_user']['user_id'], $current_group['id'])) { +if (api_is_allowed_to_edit(false, true) OR GroupManager :: is_user_in_group($_SESSION['_user']['user_id'], $current_group['id'])) { $tools = ''; - // link to the forum of this group + // Link to the forum of this group $forums_of_groups = get_forums_of_group($current_group['id']); if (is_array($forums_of_groups)) { - if ( $current_group['forum_state'] != TOOL_NOT_AVAILABLE ) { + if ($current_group['forum_state'] != TOOL_NOT_AVAILABLE ) { foreach ($forums_of_groups as $key => $value) { - if ($value['forum_group_public_private'] == 'public' || (/*!empty($user_subscribe_to_current_group) && */ $value['forum_group_public_private'] == 'private') || !empty($user_is_tutor) || api_is_allowed_to_edit(false,true)) { - - $tools.= Display::return_icon('forum.gif', get_lang("GroupForum")) . ' '.get_lang("Forum").': '.$value['forum_title'].'