'; //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 '
'; if (api_is_allowed_to_edit(false,true)) { echo Display::return_icon('groupadd.gif', get_lang('NewGroupCreate')) . ''.get_lang('NewGroupCreate').' '; if( Database::count_rows(Database::get_course_table(TABLE_GROUP)) > 0) { //echo ''.Display::return_icon('group_view.gif').' '.get_lang('GroupOverview').' '; echo Display::return_icon('group.gif', get_lang('GroupOverview')) .''.get_lang('GroupOverview').' '; } if (api_get_setting('allow_group_categories') == 'true') { echo Display::return_icon('folder_new.gif', get_lang('AddCategory')) . ''.get_lang('AddCategory').' '; } else { //echo ''.Display::return_icon('edit_group.gif').' '.get_lang('PropModify').' '; echo Display::return_icon('settings.gif', get_lang('PropModify')) . ''.get_lang('PropModify').' '; } //echo Display::return_icon('csv.gif', get_lang('ExportAsCSV')).''.get_lang('ExportAsCSV').' '; echo Display::return_icon('excel.gif', get_lang('ExportAsXLS')).' '.get_lang('ExportAsXLS').''; //echo ''.Display::return_icon('group_add_big.gif').' '.get_lang('NewGroupCreate').' '; } $group_cats = GroupManager :: get_categories(); if (api_get_setting('allow_group_categories') == 'true' && count($group_cats) > 1) { //echo '

'.get_lang('ShowAll').'

'; echo Display::return_icon('group.gif').' '.get_lang('ShowAll').''; } echo '
'; /* * List all categories */ foreach ($group_cats as $index => $category) { global $charset; $group_list = array (); $in_category = false; if (api_get_setting('allow_group_categories') == 'true') { if (isset ($_GET['show_all']) || (isset ($_GET['category']) && $_GET['category'] == $category['id'])) { echo ''; echo ' '.$category['title'].''; $in_category = true; } else { echo ''; echo ' '.$category['title'].''; } $group_list = GroupManager :: get_group_list($category['id']); echo ' ('.count($group_list).' '.get_lang('ExistingGroups').')'; if (api_is_allowed_to_edit(false,true)) { echo ''.get_lang('Edit').' '; echo ''.get_lang('Delete').' '; if ($index != 0) { echo ' '; } if ($index != count($group_cats) - 1) { echo ' '; } } 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.'
'.stripslashes(trim($this_group['description'])); } else { $row[] = $this_group['name'].'
'.stripslashes(trim($this_group['description'])); } // self-registration / unregistration if (!api_is_allowed_to_edit(false,true)) { if (GroupManager :: is_self_registration_allowed($_user['user_id'], $this_group['id'])) { $row[] = ''.get_lang('GroupSelfRegInf').''; } elseif (GroupManager :: is_self_unregistration_allowed($_user['user_id'], $this_group['id'])) { $row[] = ''.get_lang('GroupSelfUnRegInf').''; } else { $row[] = '-'; } } // number of members in group $row[] = $this_group['number_of_members']; // max number of members in group $row[] = ($this_group['maximum_number_of_members'] == MEMBER_PER_GROUP_NO_LIMIT ? '-' : $this_group['maximum_number_of_members']); // tutor name $tutor_info = ''; if(count($tutorsids_of_group)>0) { foreach($tutorsids_of_group as $tutor_id){ $tutor = api_get_user_info($tutor_id); if (api_get_setting("show_email_addresses") == "true") { $tutor_info .= Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])).', '; } else { if (api_is_allowed_to_edit()=='true') { $tutor_info .= Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])).', '; } else { $tutor_info .= api_get_person_name($tutor['firstName'], $tutor['lastName']).', '; } } } } $tutor_info = api_substr($tutor_info,0,api_strlen($tutor_info)-2); $row[] = $tutor_info; // edit-links if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && intval($this_group['session_id'])!=intval($_SESSION['id_session']))) { $edit_actions = ''.get_lang('Edit').' '; $edit_actions .= ''.get_lang('Delete').' '; $edit_actions .= ''.get_lang('EmptyGroup').' '; $edit_actions .= ''.get_lang('FillGroup').''; $row[] = $edit_actions; } if (!empty($this_group['nbMember'])) { $totalRegistered = $totalRegistered + $this_group['nbMember']; } $group_data[] = $row; } // while loop if (isset ($_GET['show_all'])) { $paging_options = array ('per_page' => count($group_data)); } else { $paging_options = array (); } $table = new SortableTableFromArrayConfig($group_data, 1); isset($_GET['category'])?$my_cat = Security::remove_XSS($_GET['category']): $my_cat = null; $table->set_additional_parameters(array('category'=>$my_cat)); $column = 0; if (api_is_allowed_to_edit(false,true) and count($group_list) > 1) { $table->set_header($column++,'', false); } $table->set_header($column++,get_lang('ExistingGroups')); if (!api_is_allowed_to_edit(false,true)) // If self-registration allowed { $table->set_header($column++,get_lang('GroupSelfRegistration')); } $table->set_header($column++,get_lang('Registered')); $table->set_header($column++,get_lang('Max')); $table->set_header($column++,get_lang('GroupTutor')); if (api_is_allowed_to_edit(false,true)) // only for course administrator { $table->set_header($column++,get_lang('Modify'), false); $form_actions = array(); $form_actions['delete_selected'] = get_lang('Delete'); $form_actions['fill_selected'] = get_lang('FillGroup'); $form_actions['empty_selected'] = get_lang('EmptyGroup'); if (count($group_list) > 1) { $table->set_form_actions($form_actions,'group'); } } $table->display(); } /* elseif ($in_category) { echo get_lang('NoGroupsAvailable'); } */ } /* ============================================================================== FOOTER ============================================================================== */ if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') { Display::display_footer(); } ?>