'; //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'); //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) { 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 event_access_tool(TOOL_GROUP); if (! $is_allowed_in_course) api_not_allowed(true); } Display::display_header(get_lang('Groups')); // Tool introduction Display::display_introduction_section(TOOL_GROUP); /* * Self-registration and unregistration */ $my_group_id = Security::remove_XSS($_GET['group_id']); $my_msg = Security::remove_XSS($_GET['msg']); $my_group = $_POST['group']; $my_get_id1 = Security::remove_XSS($_GET['id1']); $my_get_id2 = Security::remove_XSS($_GET['id2']); $my_get_id = Security::remove_XSS($_GET['id']); 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); 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); Display :: display_confirmation_message(get_lang('StudentDeletesHimself')); } break; case 'show_msg' : Display :: display_confirmation_message($my_msg); break; } } /* * Group-admin functions */ if (api_is_allowed_to_edit(false,true)) { // Post-actions if (isset ($_POST['action'])) { switch ($_POST['action']) { case 'delete_selected' : 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'])) { GroupManager :: unsubscribe_all_users($my_group); Display :: display_confirmation_message(get_lang('SelectedGroupsEmptied')); } break; case 'fill_selected' : 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); Display :: display_confirmation_message(get_lang('CategoryOrderChanged')); break; case 'delete_one' : GroupManager :: delete_groups($my_get_id); Display :: display_confirmation_message(get_lang('GroupDel')); break; case 'empty_one' : GroupManager :: unsubscribe_all_users($my_get_id); Display :: display_confirmation_message(get_lang('GroupEmptied')); break; case 'fill_one' : GroupManager :: fill_groups($my_get_id); Display :: display_confirmation_message(get_lang('GroupFilledGroups')); break; case 'delete_category' : GroupManager :: delete_category($my_get_id); Display :: display_confirmation_message(get_lang('CategoryDeleted')); break; } } } echo '
'.$category['description'].'
'; } else { $group_list = GroupManager :: get_group_list(); $in_category = true; } //if (count($group_list) > 0 && $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 (); foreach ($group_list as $index => $this_group) { //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); // create a new table-row $row = array (); // 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) || $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; $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']) { $group_name .= ' ('.get_lang('OneMyGroups').')'; } elseif ($this_group['is_member']) { $group_name .= ' ('.get_lang('MyGroup').')'; } if(api_is_allowed_to_edit() && !empty($this_group['session_name'])) { $group_name .= ' ('.$this_group['session_name'].')'; } $group_name .= $session_img; $row[] = $group_name.'