'group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => 'group_space.php?'.api_get_cidReq(), 'name' => $current_group['name']); $is_group_member = GroupManager::is_tutor_of_group(api_get_user_id(), $group_id); if (!api_is_allowed_to_edit(false, true) && !$is_group_member) { api_not_allowed(true); } /** * List all users registered to the course */ function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword) { if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos($username, $keyword) !== false || api_strripos($official_code, $keyword) !== false ) { return true; } else { return false; } } /** * Function to sort users after getting the list in the DB. * Necessary because there are 2 or 3 queries. Called by usort() */ function sort_users($user_a, $user_b) { global $_configuration; if (isset($_configuration['order_user_list_by_official_code']) && $_configuration['order_user_list_by_official_code'] ) { $cmp = api_strcmp($user_a['official_code'], $user_b['official_code']); if ($cmp !== 0) { return $cmp; } else { $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']); if ($cmp !== 0) { return $cmp; } else { return api_strcmp($user_a['username'], $user_b['username']); } } } if (api_sort_by_first_name()) { $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']); if ($cmp !== 0) { return $cmp; } else { $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']); if ($cmp !== 0) { return $cmp; } else { return api_strcmp($user_a['username'], $user_b['username']); } } } else { $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']); if ($cmp !== 0) { return $cmp; } else { $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']); if ($cmp !== 0) { return $cmp; } else { return api_strcmp($user_a['username'], $user_b['username']); } } } } /** * Function to check if the number of selected group members is valid */ function check_group_members($value) { if ($value['max_student'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { return true; } if (isset($value['max_student']) && isset($value['group_members']) && $value['max_student'] < count($value['group_members'])) { return array('group_members' => get_lang('GroupTooMuchMembers')); } return true; } /* MAIN CODE */ $htmlHeadXtra[] = ''; // Build form $form = new FormValidator('group_edit', 'post', api_get_self().'?'.api_get_cidreq()); $form->addElement('hidden', 'action'); $form->addElement('hidden', 'max_student', $current_group['max_student']); $complete_user_list = GroupManager::fill_groups_list($current_group['id']); $possible_users = array(); if (!empty($complete_user_list)) { usort($complete_user_list, 'sort_users'); foreach ($complete_user_list as $index => $user) { $officialCode = !empty($user['official_code']) ? ' - '.$user['official_code'] : null; $name = api_get_person_name( $user['firstname'], $user['lastname'] ).' ('.$user['username'].')'.$officialCode; global $_configuration; if (isset($_configuration['order_user_list_by_official_code']) && $_configuration['order_user_list_by_official_code'] ) { $officialCode = !empty($user['official_code']) ? $user['official_code']." - " : '? - '; $name = $officialCode." ".api_get_person_name( $user['firstname'], $user['lastname'] ).' ('.$user['username'].')'; } $possible_users[$user['user_id']] = $name; } } // Group members $group_member_list = GroupManager::get_subscribed_users($current_group['id']); $selected_users = array (); if (!empty($group_member_list)) { foreach ($group_member_list as $index => $user) { $selected_users[] = $user['user_id']; } } $group_members_element = $form->addElement( 'advmultiselect', 'group_members', get_lang('GroupMembers'), $possible_users, 'style="width: 280px;"' ); $group_members_element->setElementTemplate(' {javascript}
{label_2} | {label_3} | |
---|---|---|
{unselected} | {add} {remove} |
{selected} |