";
}
}*/
/*
DISPLAY USERS LIST
Also shows a "next page" button if there are
more than 50 users.
There's a bug in here somewhere - some users count as more than one if they are in more than one group
--> code for > 50 users should take this into account
(Roan, Feb 2004)
*/
/*
* @todo seems not to affect anything in the code
if (CourseManager::has_virtual_courses_from_code($course_id, $user_id)) {
$real_course_code = $_course['sysCode'];
$real_course_info = Database::get_course_info($real_course_code);
$message = get_lang("RegisteredInRealCourse")." ".$real_course_info["title"]." (".$real_course_info["official_code"].")";
echo "
".$message."
";
}*/
/*
DISPLAY LIST OF USERS
*/
/**
* * Get the users to display on the current page.
*/
function get_number_of_users() {
$counter = 0;
if (!empty($_SESSION["id_session"])){
$a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, $_SESSION['id_session']);
} else {
$a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], false);
}
foreach ($a_course_users as $user_id => $o_course_user) {
if ((isset($_GET['keyword']) && search_keyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
$counter++;
}
}
return $counter;
}
function search_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;
}
}
/**
* Get the users to display on the current page.
*/
function get_user_data($from, $number_of_items, $column, $direction) {
global $origin;
global $is_western_name_order;
global $sort_by_first_name;
$a_users = array();
// limit
if (!isset($_GET['keyword']) || empty($_GET['keyword'])) {
$limit = 'LIMIT '.intval($from).','.intval($number_of_items);
}
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
// order by
if (api_is_allowed_to_edit()) {
$column--;
}
switch ($column) {
case 1:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
} else {
$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
}
break;
case 2:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
} else {
$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
}
break;
case 5:
$order_by = 'ORDER BY user.official_code '.$direction;
break;
default:
if ($sort_by_first_name) {
$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
} else {
$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
}
break;
}
if (!empty($_SESSION["id_session"])) {
$a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, $_SESSION['id_session'], $limit, $order_by);
} else {
$a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], false, 0, $limit, $order_by);
}
foreach ($a_course_users as $user_id => $o_course_user) {
if ((isset ($_GET['keyword']) && search_keyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
$groups_name = GroupManager :: get_user_group_name($user_id);
$temp = array();
if (api_is_allowed_to_edit(null, true)) {
if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
$temp[] = $user_id;
}
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!api_is_anonymous()) {
$photo = '
';
}
$temp[] = $photo;
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
}
$temp[] = $o_course_user['role'];
$temp[] = implode(', ', $groups_name);//Group
$temp[] = $o_course_user['official_code'];
}
$a_users[$user_id] = $temp;
}
}
return $a_users;
}
/**
* Build the active-column of the table to lock or unlock a certain user
* lock = the user can no longer use this account
* @author Patrick Cool , Ghent University
* @param int $active the current state of the account
* @param int $user_id The user id
* @param string $url_params
* @return string Some HTML-code with the lock/unlock button
*/
function active_filter($active, $url_params, $row) {
global $_user;
if ($active=='1') {
$action='AccountActive';
$image='accept';
}
if ($active=='0') {
$action='AccountInactive';
$image='error';
}
$result = '';
if ($row[count($row)-1]<>$_user['user_id']) { // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
$result = '
';
}
return $result;
}
/**
* Build the modify-column of the table
* @param int $user_id The user id
* @return string Some HTML-code
*/
function modify_filter($user_id) {
global $origin, $_user, $_course, $is_allowed_to_track, $charset;
$result="