if (isset($_POST['id']) && intval($groups_per_user) != GroupManager::GROUP_PER_MEMBER_NO_LIMIT && GroupManager::get_current_max_groups_per_user($_POST['id']) > intval($groups_per_user)) { return false; } return true; } if (api_get_setting('allow_group_categories') == 'true') { if (isset($_GET['id'])) { $category = GroupManager::get_category($_GET['id']); $nameTools = get_lang('EditGroupCategory') . ': ' . $category['title']; } else { $nameTools = get_lang('AddCategory'); // Default values for new category $category = array('groups_per_user' => 1, 'doc_state' => GroupManager::TOOL_PRIVATE, 'work_state' => GroupManager::TOOL_PRIVATE, 'wiki_state' => GroupManager::TOOL_PRIVATE, 'chat_state' => GroupManager::TOOL_PRIVATE, 'calendar_state' => GroupManager::TOOL_PRIVATE, 'announcements_state' => GroupManager::TOOL_PRIVATE, 'forum_state' => GroupManager::TOOL_PRIVATE, 'max_student' => 0); } } else { $category = GroupManager::get_category($_GET['id']); $nameTools = get_lang('PropModify'); } $htmlHeadXtra[] = '<script> $(document).ready( function() { $("#max_member").on("focus", function() { $("#max_member_selected").attr("checked", true); }); }); </script>'; $interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups')); $course_id = api_get_course_int_id(); // Build the form if (isset($_GET['id'])) { // Update settings of existing category $action = 'update_settings';
/** * Export all categories/group from a course to an array. * This function works only in a context of a course. * @return array */ public static function exportCategoriesAndGroupsToArray() { $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'); $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 $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']); } return $data; }
/** * Export all categories/group from a course to an array. * This function works only in a context of a course. * @param int $groupId * @param bool $loadUsers * @return array */ public static function exportCategoriesAndGroupsToArray($groupId = null, $loadUsers = false) { $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'); $count = 1; if ($loadUsers) { $data[0][] = 'students'; $data[0][] = 'tutors'; } if ($loadUsers == false) { $categories = GroupManager::get_categories(); foreach ($categories as $categoryInfo) { $data[$count] = 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']); $count++; } } $groups = GroupManager::get_group_list(); foreach ($groups as $groupInfo) { $categoryTitle = null; $categoryInfo = GroupManager::get_category($groupInfo['category_id']); $groupSettings = GroupManager::get_group_properties($groupInfo['id']); if (!empty($categoryInfo)) { $categoryTitle = $categoryInfo['title']; } $users = GroupManager::getStudents($groupInfo['id']); $userList = array(); foreach ($users as $user) { $user = api_get_user_info($user['user_id']); $userList[] = $user['username']; } $tutors = GroupManager::getTutors($groupInfo['id']); $tutorList = array(); foreach ($tutors as $user) { $user = api_get_user_info($user['user_id']); $tutorList[] = $user['username']; } $userListToString = null; if (!empty($userList)) { $userListToString = implode(',', $userList); } $tutorListToString = null; if (!empty($tutorList)) { $tutorListToString = implode(',', $tutorList); } $data[$count] = 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'], null); if ($loadUsers) { $data[$count][] = $userListToString; $data[$count][] = $tutorListToString; } if (!empty($groupId)) { if ($groupId == $groupInfo['id']) { break; } } $count++; } return $data; }