From 5a696e6195712e62a84fc98258a29a6f8aa0b173 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 14 Nov 2013 15:42:36 +0100 Subject: [PATCH] Adding search form, adding tutors and members list in group overview see BT#6985 --- main/group/group_overview.php | 125 +++++-------- main/inc/lib/groupmanager.lib.php | 302 +++++++++++++++++++++++------- 2 files changed, 277 insertions(+), 150 deletions(-) diff --git a/main/group/group_overview.php b/main/group/group_overview.php index 1ed170a58e..de6e495a3a 100644 --- a/main/group/group_overview.php +++ b/main/group/group_overview.php @@ -27,86 +27,20 @@ $current_course_tool = TOOL_GROUP; api_protect_course_script(true); $nameTools = get_lang('GroupOverview'); +$courseId = api_get_course_int_id(); /* Libraries */ - include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; include_once api_get_path(LIBRARY_PATH).'export.lib.inc.php'; +$keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null; + if (isset($_GET['action'])) { switch ($_GET['action']) { case 'export_all': - $data = array(); - - $data[] = array( - 'category', - 'group', - 'description', - 'announcements_state', - 'calendar_state', - 'chat_state', - 'doc_state', - 'forum_state', - 'work_state', - 'wiki_state', - 'max_student', - 'self_reg_allowed', - 'self_unreg_allowed', - 'groups_per_user' - ); - - $groupCategories = array(); - $categories = GroupManager::get_categories(); - - foreach ($categories as $categoryInfo) { - $data[] = array( - $categoryInfo['title'], - null, - $categoryInfo['description'], - $categoryInfo['announcements_state'], - $categoryInfo['calendar_state'], - $categoryInfo['chat_state'], - $categoryInfo['doc_state'], - $categoryInfo['forum_state'], - $categoryInfo['work_state'], - $categoryInfo['wiki_state'], - $categoryInfo['max_student'], - $categoryInfo['self_reg_allowed'], - $categoryInfo['self_unreg_allowed'], - $categoryInfo['groups_per_user'] - ); - } - - $groups = GroupManager::get_group_list(); - - foreach ($groups as $index => $groupInfo) { - $categoryTitle = null; - $categoryInfo = GroupManager::get_category($groupInfo['category_id']); - $groupSettings = GroupManager::get_group_properties($groupInfo['id']); - if (!empty($categoryInfo)) { - $categoryTitle = $categoryInfo['title']; - } - - $data[] = array( - $categoryTitle, - $groupSettings['name'], - $groupSettings['description'], - $groupSettings['announcements_state'], - $groupSettings['calendar_state'], - $groupSettings['chat_state'], - $groupSettings['doc_state'], - $groupSettings['forum_state'], - $groupSettings['work_state'], - $groupSettings['wiki_state'], - $groupSettings['maximum_number_of_students'], - $groupSettings['self_registration_allowed'], - $groupSettings['self_unregistration_allowed'], - ); - } - + $data = GroupManager::exportCategoriesAndGroupsToArray(); Export::export_table_csv($data); exit; - break; case 'export': $groupId = isset($_GET['id']) ? intval($_GET['id']) : null; @@ -134,9 +68,11 @@ if (isset($_GET['action'])) { case 'csv': Export::export_table_csv($data); exit; + break; case 'xls': Export::export_table_xls($data); exit; + break; } break; } @@ -172,32 +108,61 @@ echo '
'; echo ''. Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM).''; } + echo ''. + Display::return_icon('import_csv.png', get_lang('Import'), '', ICON_SIZE_MEDIUM).''; + + echo ''. + Display::return_icon('export_csv.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).''; + echo ''. Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).''; + + $form = new FormValidator('search_groups', 'get', null, null, array('class' => 'form-search')); + $form->addElement('text', 'keyword'); + $form->addElement('button', 'submit', get_lang('Search')); + $form->display(); echo '
'; $categories = GroupManager::get_categories(); -foreach ($categories as $index => $category) { +foreach ($categories as $category) { if (api_get_setting('allow_group_categories') == 'true') { echo '

'.$category['title'].'

'; } - $groups = GroupManager::get_group_list($category['id']); + if (!empty($keyword)) { + $groups = GroupManager::getGroupListFilterByName($keyword, $category['id'], $courseId); + } else { + $groups = GroupManager::get_group_list($category['id']); + } + echo '