|
|
|
@ -39,25 +39,25 @@ $course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
// 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 c_id = $course_id AND id = '".GroupManager::DEFAULT_GROUP_CATEGORY."'"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$num = Database::num_rows($res); |
|
|
|
|
if ($num == 0) { |
|
|
|
|
$sql = "INSERT INTO ".$cat_table." ( c_id, id , title , description , forum_state, wiki_state, max_student, self_reg_allowed, self_unreg_allowed, groups_per_user, display_order) |
|
|
|
|
VALUES ($course_id, '2', '".lang2db(get_lang('DefaultGroupCategory'))."', '', '1', '1', '8', '0', '0', '0', '0');"; |
|
|
|
|
Database::query ($sql); |
|
|
|
|
} |
|
|
|
|
$cat_table = Database::get_course_table(TABLE_GROUP_CATEGORY); |
|
|
|
|
$sql = "SELECT * FROM $cat_table WHERE c_id = $course_id AND id = '".GroupManager::DEFAULT_GROUP_CATEGORY."'"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$num = Database::num_rows($res); |
|
|
|
|
if ($num == 0) { |
|
|
|
|
$sql = "INSERT INTO ".$cat_table." ( c_id, id , title , description , forum_state, wiki_state, max_student, self_reg_allowed, self_unreg_allowed, groups_per_user, display_order) |
|
|
|
|
VALUES ($course_id, '2', '".lang2db(get_lang('DefaultGroupCategory'))."', '', '1', '1', '8', '0', '0', '0', '0');"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* 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); |
|
|
|
|
} |
|
|
|
|
// 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')); |
|
|
|
@ -66,7 +66,7 @@ Display::display_header(get_lang('Groups')); |
|
|
|
|
Display::display_introduction_section(TOOL_GROUP); |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* Self-registration and unregistration |
|
|
|
|
* Self-registration and un-registration |
|
|
|
|
*/ |
|
|
|
|
$my_group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : null; |
|
|
|
|
$my_msg = isset($_GET['msg']) ? Security::remove_XSS($_GET['msg']) : null; |
|
|
|
@ -76,29 +76,29 @@ Display::display_introduction_section(TOOL_GROUP); |
|
|
|
|
$my_get_id = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : null; |
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
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; |
|
|
|
|
case 'warning_message': |
|
|
|
|
Display :: display_warning_message($my_msg); |
|
|
|
|
break; |
|
|
|
|
Display :: display_warning_message($my_msg); |
|
|
|
|
break; |
|
|
|
|
case 'success_message': |
|
|
|
|
Display :: display_confirmation_message($my_msg); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
Display :: display_confirmation_message($my_msg); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
@ -107,73 +107,79 @@ if (isset($_GET['action'])) { |
|
|
|
|
|
|
|
|
|
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'])) { |
|
|
|
|
// 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'])) { |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'fill_selected': |
|
|
|
|
if (is_array($_POST['group'])) { |
|
|
|
|
GroupManager :: fill_groups($my_group); |
|
|
|
|
Display :: display_confirmation_message(get_lang('SelectedGroupsFilled')); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 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 '<div class="actions">'; |
|
|
|
|
if (api_is_allowed_to_edit(false, true)) { |
|
|
|
|
echo '<a href="group_creation.php?'.api_get_cidreq().'">'.Display::return_icon('new_group.png', get_lang('NewGroupCreate'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
if (CourseManager::count_rows_course_table(Database::get_course_table(TABLE_GROUP),api_get_session_id(), api_get_course_int_id()) > 0) { |
|
|
|
|
echo '<a href="group_overview.php?'.api_get_cidreq().'">'.Display::return_icon('group_summary.png', get_lang('GroupOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
if (api_get_setting('allow_group_categories') == 'true') { |
|
|
|
|
echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.Display::return_icon('new_folder.png', get_lang('AddCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} else { |
|
|
|
|
echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.Display::return_icon('settings.png', get_lang('PropModify'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '<a href="../user/user.php?'.api_get_cidreq().'">'.Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '<a href="group_creation.php?'.api_get_cidreq().'">'. |
|
|
|
|
Display::return_icon('new_group.png', get_lang('NewGroupCreate'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
if (CourseManager::count_rows_course_table(Database::get_course_table(TABLE_GROUP), api_get_session_id(), api_get_course_int_id()) > 0) { |
|
|
|
|
echo '<a href="group_overview.php?'.api_get_cidreq().'">'. |
|
|
|
|
Display::return_icon('group_summary.png', get_lang('GroupOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
if (api_get_setting('allow_group_categories') == 'true') { |
|
|
|
|
echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'. |
|
|
|
|
Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} else { |
|
|
|
|
echo '<a href="group_category.php?'.api_get_cidreq().'&id=2">'. |
|
|
|
|
Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
echo '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'. |
|
|
|
|
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
echo '<a href="../user/user.php?'.api_get_cidreq().'">'. |
|
|
|
|
Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$group_cats = GroupManager :: get_categories(api_get_course_id()); |
|
|
|
|
$group_cats = GroupManager::get_categories(api_get_course_id()); |
|
|
|
|
|
|
|
|
|
if (api_get_setting('allow_group_categories') == 'true' && count($group_cats) > 1) { |
|
|
|
|
echo ' <a href="?'.api_get_cidreq().'&show_all=1">'.Display::return_icon('group.png',get_lang('ShowAll'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
@ -191,7 +197,8 @@ if (api_get_setting('allow_group_categories') == 'true') { |
|
|
|
|
|
|
|
|
|
$actions = null; |
|
|
|
|
if (api_is_allowed_to_edit(false, true)) { |
|
|
|
|
$actions .= '<a href="group_category.php?'.api_get_cidreq().'&id='.$category['id'].'" title="'.get_lang('Edit').'">'.Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
$actions .= '<a href="group_category.php?'.api_get_cidreq().'&id='.$category['id'].'" title="'.get_lang('Edit').'">'. |
|
|
|
|
Display::return_icon('edit.png', get_lang('EditGroup'),'',ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
$actions .= '<a href="group.php?'.api_get_cidreq().'&action=delete_category&id='.$category['id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
|
|
|
if ($index != 0) { |
|
|
|
|
$actions .= ' <a href="group.php?'.api_get_cidreq().'&action=swap_cat_order&id1='.$category['id'].'&id2='.$group_cats[$index -1]['id'].'">'.Display::return_icon('up.png',' ','',ICON_SIZE_SMALL).'</a>'; |
|
|
|
@ -212,8 +219,6 @@ if (api_get_setting('allow_group_categories') == 'true') { |
|
|
|
|
GroupManager ::process_groups($group_list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* FOOTER */ |
|
|
|
|
|
|
|
|
|
if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') { |
|
|
|
|
Display::display_footer(); |
|
|
|
|
} |
|
|
|
|