From 2bddbe22ffcb8b7eb30bddb19d4260324fc14975 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 22 Jul 2015 08:48:17 +0200 Subject: [PATCH] Improve user page see BT#6050 --- main/group/group.php | 70 +++++++++++++++++++------------ main/group/group_category.php | 13 +++--- main/group/group_creation.php | 13 +++--- main/group/group_edit.php | 15 ++----- main/group/group_overview.php | 5 ++- main/group/group_space.php | 8 ---- main/group/member_settings.php | 15 ++----- main/group/settings.php | 20 ++++----- main/group/tutor_settings.php | 19 ++++----- main/inc/lib/groupmanager.lib.php | 13 +++--- main/user/class.php | 4 +- 11 files changed, 95 insertions(+), 100 deletions(-) diff --git a/main/group/group.php b/main/group/group.php index 80cf23c123..57e202b215 100755 --- a/main/group/group.php +++ b/main/group/group.php @@ -38,12 +38,6 @@ $(document).ready( function() { $nameTools = get_lang('GroupManagement'); $course_id = api_get_course_int_id(); -/* Header */ -Display::display_header(get_lang('Groups')); - -// Tool introduction -Display::display_introduction_section(TOOL_GROUP); - /* * Self-registration and un-registration */ @@ -54,41 +48,43 @@ $my_get_id1 = isset($_GET['id1']) ? Security::remove_XSS($_GET['id1']) : null; $my_get_id2 = isset($_GET['id2']) ? Security::remove_XSS($_GET['id2']) : null; $my_get_id = isset($_GET['id']) ? Security::remove_XSS($_GET['id']) : null; +$currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(); + if (isset($_GET['action']) && $is_allowed_in_course) { switch ($_GET['action']) { case 'set_visible': if (api_is_allowed_to_edit()) { GroupManager::setVisible($my_get_id); - Display:: display_confirmation_message(get_lang('ItemUpdated')); + Display::addFlash(Display::return_message(get_lang('ItemUpdated'))); + header("Location: $currentUrl"); + exit; } break; case 'set_invisible': if (api_is_allowed_to_edit()) { GroupManager::setInvisible($my_get_id); - Display:: display_confirmation_message(get_lang('ItemUpdated')); + Display::addFlash(Display::return_message(get_lang('ItemUpdated'))); + header("Location: $currentUrl"); + exit; } break; case 'self_reg': if (GroupManager::is_self_registration_allowed($userId, $my_group_id)) { GroupManager::subscribe_users($userId, $my_group_id); - Display :: display_confirmation_message(get_lang('GroupNowMember')); + Display::addFlash(Display::return_message(get_lang('GroupNowMember'))); + header("Location: $currentUrl"); + exit; } break; case 'self_unreg': if (GroupManager::is_self_unregistration_allowed($userId, $my_group_id)) { GroupManager::unsubscribe_users($userId, $my_group_id); - Display :: display_confirmation_message(get_lang('StudentDeletesHimself')); + + Display::addFlash(Display::return_message(get_lang('StudentDeletesHimself'))); + header("Location: $currentUrl"); + exit; } break; - case 'show_msg': - Display::display_confirmation_message($my_msg); - break; - case 'warning_message': - Display::display_warning_message($my_msg); - break; - case 'success_message': - Display::display_confirmation_message($my_msg); - break; } } @@ -104,19 +100,25 @@ if (api_is_allowed_to_edit(false, true)) { case 'delete_selected': if (is_array($_POST['group'])) { GroupManager::delete_groups($my_group); - Display :: display_confirmation_message(get_lang('SelectedGroupsDeleted')); + Display::addFlash(Display::return_message(get_lang('SelectedGroupsDeleted'))); + header("Location: $currentUrl"); + exit; } break; case 'empty_selected': if (is_array($_POST['group'])) { GroupManager :: unsubscribe_all_users($my_group); - Display :: display_confirmation_message(get_lang('SelectedGroupsEmptied')); + Display::addFlash(Display::return_message(get_lang('SelectedGroupsEmptied'))); + header("Location: $currentUrl"); + exit; } break; case 'fill_selected': if (is_array($_POST['group'])) { GroupManager :: fill_groups($my_group); - Display :: display_confirmation_message(get_lang('SelectedGroupsFilled')); + Display::addFlash(Display::return_message(get_lang('SelectedGroupsFilled'))); + header("Location: $currentUrl"); + exit; } break; } @@ -127,24 +129,38 @@ if (api_is_allowed_to_edit(false, true)) { switch ($_GET['action']) { case 'swap_cat_order': GroupManager :: swap_category_order($my_get_id1, $my_get_id2); - Display :: display_confirmation_message(get_lang('CategoryOrderChanged')); + Display::addFlash(Display::return_message(get_lang('CategoryOrderChanged'))); + header("Location: $currentUrl"); + exit; break; case 'delete_one': GroupManager :: delete_groups($my_get_id); - Display :: display_confirmation_message(get_lang('GroupDel')); + Display::addFlash(Display::return_message(get_lang('GroupDel'))); + header("Location: $currentUrl"); + exit; break; case 'fill_one': GroupManager :: fill_groups($my_get_id); - Display :: display_confirmation_message(get_lang('GroupFilledGroups')); + Display::addFlash(Display::return_message(get_lang('GroupFilledGroups'))); + header("Location: $currentUrl"); + exit; break; case 'delete_category': GroupManager :: delete_category($my_get_id); - Display :: display_confirmation_message(get_lang('CategoryDeleted')); + Display::addFlash(Display::return_message(get_lang('CategoryDeleted'))); + header("Location: $currentUrl"); + exit; break; } } } +/* Header */ +Display::display_header(get_lang('Groups')); + +// Tool introduction +Display::display_introduction_section(TOOL_GROUP); + echo '
'; if (api_is_allowed_to_edit(false, true)) { @@ -180,7 +196,7 @@ if (api_is_allowed_to_edit(false, true)) { $group_cats = GroupManager::get_categories(api_get_course_id()); echo '
'; -echo UserManager::getUserSubscriptionTab(4); +echo UserManager::getUserSubscriptionTab(3); /* List all categories */ if (api_get_setting('allow_group_categories') == 'true') { diff --git a/main/group/group_category.php b/main/group/group_category.php index 72a816b7da..0f10726d54 100755 --- a/main/group/group_category.php +++ b/main/group/group_category.php @@ -218,6 +218,8 @@ $form->addElement('html', '
'); // Submit $form->addButtonSave(get_lang('PropModify'), 'submit'); +$currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(); + // If form validates -> save data if ($form->validate()) { $values = $form->exportValues(); @@ -248,9 +250,9 @@ if ($form->validate()) { $max_member, $values['groups_per_user'] ); - $msg = urlencode(get_lang('GroupPropertiesModified')); - header('Location: group.php?action=show_msg&msg='.$msg.'&category='.$values['id']); - break; + Display::addFlash(Display::return_message(get_lang('GroupPropertiesModified'))); + header("Location: ".$currentUrl."&category=".$values['id']); + exit; case 'add_category': GroupManager :: create_category( $values['title'], @@ -267,8 +269,9 @@ if ($form->validate()) { $max_member, $values['groups_per_user'] ); - $msg = urlencode(get_lang('CategoryCreated')); - header('Location: group.php?action=show_msg&msg='.$msg); + Display::addFlash(Display::return_message(get_lang('CategoryCreated'))); + header("Location: ".$currentUrl); + exit; break; } } diff --git a/main/group/group_creation.php b/main/group/group_creation.php index 9630ba64dc..b8511298e8 100755 --- a/main/group/group_creation.php +++ b/main/group/group_creation.php @@ -10,6 +10,7 @@ $current_course_tool = TOOL_GROUP; // Notice for unauthorized people. api_protect_course_script(true); +$currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(); /* Create the groups */ @@ -46,8 +47,8 @@ if (isset($_POST['action'])) { $group['places'] ); } - $msg = urlencode(count($groups).' '.get_lang('GroupsAdded')); - header('Location: group.php?action=show_msg&msg='.$msg); + Display::addFlash(Display::return_message(get_lang('GroupsAdded'))); + header("Location: ".$currentUrl); exit; break; case 'create_subgroups': @@ -55,14 +56,14 @@ if (isset($_POST['action'])) { $_POST['base_group'], $_POST['number_of_groups'] ); - $msg = urlencode($_POST['number_of_groups'].' '.get_lang('GroupsAdded')); - header('Location: group.php?action=show_msg&msg='.$msg); + Display::addFlash(Display::return_message(get_lang('GroupsAdded'))); + header("Location: ".$currentUrl); exit; break; case 'create_class_groups': $ids = GroupManager::create_class_groups($_POST['group_category']); - $msg = urlencode(count($ids).' '.get_lang('GroupsAdded')); - header('Location: group.php?action=show_msg&msg='.$msg); + Display::addFlash(Display::return_message(get_lang('GroupsAdded'))); + header("Location: ".$currentUrl); exit; break; } diff --git a/main/group/group_edit.php b/main/group/group_edit.php index ee2ef1ee1f..677fc65958 100755 --- a/main/group/group_edit.php +++ b/main/group/group_edit.php @@ -282,9 +282,11 @@ if ($form->validate()) { // Returning to the group area (note: this is inconsistent with the rest of chamilo) $cat = GroupManager :: get_category_from_group($current_group['id']); if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { - header('Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang('GroupTooMuchMembers')); + Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning')); + header('Location: group.php?'.api_get_cidreq(true, false)); } else { - header('Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); + Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success')); + header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$cat['id']); } exit; } @@ -308,15 +310,6 @@ if (!empty($_GET['keyword']) && !empty($_GET['submit'])) { Display :: display_header($nameTools, 'Group'); -//@todo fix this -if (isset($_GET['show_message_warning'])) { - echo Display::display_warning_message($_GET['show_message_warning']); -} - -if (isset($_GET['show_message_sucess'])) { - echo Display::display_normal_message($_GET['show_message_sucess']); -} - $form->setDefaults($defaults); $form->display(); diff --git a/main/group/group_overview.php b/main/group/group_overview.php index afe9e128f4..669e824269 100755 --- a/main/group/group_overview.php +++ b/main/group/group_overview.php @@ -86,7 +86,9 @@ if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') { // Action links echo '
'; echo ''. - Display::return_icon('new_group.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).''; + Display::return_icon('add.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).''; + + echo GroupManager::getSearchForm(); if (api_get_setting('allow_group_categories') == 'true') { echo ''. @@ -114,7 +116,6 @@ echo ''; echo GroupManager::getOverview($courseId, $keyword); diff --git a/main/group/group_space.php b/main/group/group_space.php index 968174f464..790819b397 100755 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -91,14 +91,6 @@ if (GroupManager :: is_self_unregistration_allowed($user_id, $current_group['id' } echo ' 
'; -if (isset($_GET['action'])) { - switch ($_GET['action']) { - case 'show_msg': - Display::display_normal_message(Security::remove_XSS($_GET['msg'])); - break; - } -} - /* Main Display Area */ $edit_url = ''; diff --git a/main/group/member_settings.php b/main/group/member_settings.php index a7fc3dc8f3..38f2d9a6f0 100755 --- a/main/group/member_settings.php +++ b/main/group/member_settings.php @@ -196,9 +196,11 @@ if ($form->validate()) { count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT ) { - header('Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang('GroupTooMuchMembers')); + Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning')); + header('Location: group.php?'.api_get_cidreq(true, false)); } else { - header('Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); + Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success')); + header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$cat['id']); } exit; } @@ -226,15 +228,6 @@ if (!empty($_GET['keyword']) && !empty($_GET['submit'])) { Display::display_header($nameTools, 'Group'); -//@todo fix this -if (isset($_GET['show_message_warning'])) { - echo Display::display_warning_message($_GET['show_message_warning']); -} - -if (isset($_GET['show_message_sucess'])) { - echo Display::display_normal_message($_GET['show_message_sucess']); -} - $form->setDefaults($defaults); echo GroupManager::getSettingBar('member'); diff --git a/main/group/settings.php b/main/group/settings.php index 425aec067d..33104f9289 100755 --- a/main/group/settings.php +++ b/main/group/settings.php @@ -172,10 +172,15 @@ if ($form->validate()) { $self_unregistration_allowed, $categoryId ); - if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { - header('Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang('GroupTooMuchMembers')); + if (isset($_POST['group_members']) && + count($_POST['group_members']) > $max_member && + $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT + ) { + Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning')); + header('Location: group.php?'.api_get_cidreq(true, false)); } else { - header('Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); + Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success')); + header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$cat['id']); } exit; } @@ -202,15 +207,6 @@ if (!empty($_GET['keyword']) && !empty($_GET['submit'])) { Display :: display_header($nameTools, 'Group'); -//@todo fix this -if (isset($_GET['show_message_warning'])) { - echo Display::display_warning_message($_GET['show_message_warning']); -} - -if (isset($_GET['show_message_sucess'])) { - echo Display::display_normal_message($_GET['show_message_sucess']); -} - $form->setDefaults($defaults); echo GroupManager::getSettingBar('settings'); echo '
'; diff --git a/main/group/tutor_settings.php b/main/group/tutor_settings.php index 7481c06ca9..977363e185 100755 --- a/main/group/tutor_settings.php +++ b/main/group/tutor_settings.php @@ -168,10 +168,15 @@ if ($form->validate()) { // Returning to the group area (note: this is inconsistent with the rest of chamilo) $cat = GroupManager::get_category_from_group($current_group['id']); - if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { - header('Location: group.php?'.api_get_cidreq(true, false).'&action=warning_message&msg='.get_lang('GroupTooMuchMembers')); + if (isset($_POST['group_members']) && + count($_POST['group_members']) > $max_member && + $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT + ) { + Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning')); + header('Location: group.php?'.api_get_cidreq(true, false)); } else { - header('Location: group.php?'.api_get_cidreq(true, false).'&action=success_message&msg='.get_lang('GroupSettingsModified').'&category='.$cat['id']); + Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success')); + header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$cat['id']); } exit; } @@ -188,14 +193,6 @@ if (!empty($_GET['keyword']) && !empty($_GET['submit'])) { Display :: display_header($nameTools, 'Group'); -//@todo fix this -if (isset($_GET['show_message_warning'])) { - echo Display::display_warning_message($_GET['show_message_warning']); -} - -if (isset($_GET['show_message_sucess'])) { - echo Display::display_normal_message($_GET['show_message_sucess']); -} $form->setDefaults($defaults); echo GroupManager::getSettingBar('tutor'); diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index f0e4146cf6..2d919ab989 100755 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -969,12 +969,15 @@ class GroupManager $res = Database::query($sql); $cat1 = Database::fetch_object($res); $cat2 = Database::fetch_object($res); - $sql = "UPDATE $table_group_cat SET display_order=$cat2->display_order + if ($cat1 && $cat2) { + $sql = "UPDATE $table_group_cat SET display_order=$cat2->display_order WHERE id = $cat1->id AND c_id = $course_id "; - Database::query($sql); - $sql = "UPDATE $table_group_cat SET display_order=$cat1->display_order - WHERE id = $cat2->id AND c_id = $course_id "; - Database::query($sql); + Database::query($sql); + + $sql = "UPDATE $table_group_cat SET display_order=$cat1->display_order + WHERE id = $cat2->id AND c_id = $course_id "; + Database::query($sql); + } } /** diff --git a/main/user/class.php b/main/user/class.php index 7500a32e41..7604cb15f1 100755 --- a/main/user/class.php +++ b/main/user/class.php @@ -20,7 +20,7 @@ $tool_name = get_lang("Classes"); $htmlHeadXtra[] = api_get_jqgrid_js(); // Extra entries in breadcrumb -$interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("ToolUser")); +$interbreadcrumb[] = array ("url" => "user.php?".api_get_cidreq(), "name" => get_lang("ToolUser")); $type = isset($_GET['type']) ? Security::remove_XSS($_GET['type']) : 'registered'; $groupFilter = isset($_GET['group_filter']) ? intval($_GET['group_filter']) : 0; @@ -62,7 +62,7 @@ if (api_is_allowed_to_edit()) { echo '
'; } -echo UserManager::getUserSubscriptionTab(5); +echo UserManager::getUserSubscriptionTab(4); if (api_is_allowed_to_edit()) { $action = isset($_GET['action']) ? $_GET['action'] : null;