function user_display_users
Search API
7.x user.module | user_display_users() |
6.x user.module | user_display_users() |
4.x user.module | user_display_users() |
5.x user.module | user_display_users() |
Display our list of faculty/staff users in the system.
2 string references to 'user_display_users'
- schools_content_alter in modules/
schools/ schools.module - user_display_student_users in modules/
user/ user.student.inc - Similar to user_display_users, except only for student users.
File
- modules/
user/ user.module, line 2351
Code
function user_display_users() {
global $db, $screen;
$de_catalog_year = @$GLOBALS ["de_catalog_year"];
if (!$de_catalog_year) {
$de_catalog_year = @intval($_REQUEST ['de_catalog_year']);
}
$cc = 1;
// Do this using $render array, so it can be altered
// by hook_content_alter
$render = array();
$render ['#id'] = 'user_display_users';
fp_add_css(fp_get_module_path("admin") . "/css/admin.css");
fp_add_css(fp_get_module_path("user") . "/css/user.css");
if (@$_REQUEST ['clear_filters'] == 'true') {
unset($_SESSION ['users_filter_name']);
// Meaning, a letter was specified, so let's reset the filter values.
foreach ($_SESSION as $key => $val) {
if (strstr($key, "users_filter_")) {
unset($_SESSION [$key]);
}
}
}
$html = "";
$html .= "<div class='add-new-user'>" . l("<i class='fa fa-plus'></i> " . t("Create a new faculty/staff user"), "admin/users/edit-user", "faculty_cwid=new&de_catalog_year=$de_catalog_year") . "</div>";
$letter_ranges = array(
"A" => array("A", "AZZZZ"),
"B" => array("B", "BZZZZ"),
"C" => array("C", "CZZZ"),
"D" => array("D", "DZZZZ"),
"E" => array("E", "EZZZZ"),
"F" => array("F", "FZZZZ"),
"G" => array("G", "GZZZZ"),
"H" => array("H", "HZZZZ"),
"I" => array("I", "IZZZ"),
"J" => array("J", "JZZZ"),
"K" => array("K", "KZZZ"),
"L" => array("L", "LZZZ"),
"M" => array("M", "MZZZ"),
"N" => array("N", "NZZZ"),
"O" => array("O", "OZZZ"),
"P" => array("P", "PZZZ"),
"Q-R" => array("Q", "RZZZZ"),
"S" => array("S", "SZZZ"),
"T" => array("T", "TZZZZ"),
"U" => array("U", "UZZZ"),
"V-Z" => array("V", "ZZZZ"),
);
$ur = trim(@$_GET ["ur"]);
$lr = trim(@$_GET ["lr"]);
if ($ur == "" && !isset($_SESSION ['users_filter_submit'])) {
//if ($ur == "") {
$ur = "A";
$lr = "AZZZZZ"; // first time through.
}
// If we are going by filters, show that as option and select it.
if (isset($_SESSION ['users_filter_submit'])) {
$letter_ranges [t(" - Filter -")] = array("filter", "filter");
}
$html .= "<div class='user-select-letter-bar' style='padding-top: 20px;'>
";
foreach ($letter_ranges as $disp => $vals) {
$selected_class = "";
if ($ur == $vals [0]) {
$selected_class = "selected";
}
if ($vals [0] == 'filter') {
$selected_class = "selected";
$html .= "<a href='javascript:void(0);' class='admin-courses-letter-link filter-indicator $selected_class'>$disp</a> ";
continue;
}
$html .= l($disp, "admin/users/faculty", "de_catalog_year=$de_catalog_year&clear_filters=true&ur=" . $vals [0] . "&lr=" . $vals [1], array("class" => "admin-courses-letter-link $selected_class")) . " ";
}
$html .= "</div>";
$render ['upper_links'] = array(
'value' => $html,
);
if ($ur == "")
{ // meaning, no range was set. Use A - C
$ur = @$_SESSION ["ur"];
$lr = @$_SESSION ["lr"];
if ($ur == "")
{ // if still blank, assign it..
$ur = "A";
$lr = "AZZZZ";
}
}
$_SESSION ["ur"] = $ur;
$_SESSION ["lr"] = $lr;
$mark = "";
$mark .= "<div class='degrees-filter'>";
$mark .= fp_render_form("user_list_filter_form");
$mark .= "</div>";
$render ['users_filter'] = array(
'value' => $mark,
);
$extra_where_conditions = "";
$params = array();
$params [":ur"] = $ur;
$params [":lr"] = $lr;
if (isset($_SESSION ['users_filter_submit'])) {
// We clicked to filter, so the letter range should be ignored.
$params [":ur"] = "A";
$params [":lr"] = "ZZZZZZZZZZZZ";
}
$filter_name = @trim($_SESSION ['users_filter_name']);
$filter_school = @intval($_SESSION ['users_filter_school']);
$filter_dept = @trim($_SESSION ['users_filter_dept']);
$filter_role = @intval($_SESSION ['users_filter_role']);
$extra_where_conditions .= " AND u.school_id = :school_id ";
$params [":school_id"] = $filter_school;
if ($filter_name) {
$extra_where_conditions .= " AND (l_name LIKE :search1 OR f_name LIKE :search2 OR u.cwid LIKE :search3) ";
$params [":search1"] = "%$filter_name%";
$params [":search2"] = "%$filter_name%";
$params [":search3"] = "%$filter_name%";
// If we are searching by name, then we do not care about what letters we selected.
$params [":ur"] = "A";
$params [":lr"] = "ZZZZZZZZZZZZZZ";
}
if ($filter_role > 0) {
$extra_where_conditions .= " AND rid = :rid ";
$params [":rid"] = $filter_role;
}
if ($filter_dept) {
$extra_where_conditions .= " AND department_code = :dept ";
$params [":dept"] = $filter_dept;
}
watchdog("user", "Viewed admin user list. Range: $ur - $lr. Name: $filter_name. Dept: $filter_dept. Role: $filter_role. School: $filter_school", array(), WATCHDOG_DEBUG);
$result = db_query("SELECT * FROM (users u, faculty f)
LEFT JOIN user_roles r ON (r.user_id = u.user_id)
WHERE
u.is_faculty = 1
AND u.cwid = f.cwid
AND l_name BETWEEN :ur AND :lr
$extra_where_conditions
ORDER BY l_name, f_name", $params);
$html = "";
$html .= "
<table border='0' width='100%' cellpadding='3' cellspacing='0' class='user-list'>
<tr>
<th width='5%'>Actions</th>
<th>CWID</th>
<th>Name</th>
<th></th>
<th>Department</th>
<th>Roles</th>
<th>Last Login</th>
</tr>
";
$render ['users_table_top'] = array(
'value' => $html,
);
while ($cur = db_fetch_array($result)) {
$user_id = $cur ["user_id"]; // Note: will be NULL if no roles are set, due to left join in query.
$school_id = db_get_school_id_for_user_id($user_id);
$departments = fp_get_departments($school_id);
$l_name = trim(ucwords(strtolower($cur ["l_name"])));
$f_name = trim(ucwords(strtolower($cur ["f_name"])));
$faculty_cwid = trim($cur ["cwid"]);
$dept_name = @$departments [$cur ["department_code"]];
if ($dept_name == "") {
$dept_name = $cur ['department_code'];
}
$last_login = intval($cur ['last_login']);
if ($last_login == 0) {
$last_login = t("Never");
}
else {
$last_login = format_date(convert_time($last_login), 'short');
}
$ast = "";
$reason = "";
$fgcol = "black";
$roles = "";
$roles_classes = "no-roles";
$temp = system_get_roles_for_user($user_id);
if (count($temp) > 1) {
$roles_classes = "";
}
foreach ($temp as $rid => $t) {
if ($rid > 2) {
// rid 1 and 2 are anonymous and authenticated-- no need to show them.
$roles .= "<div class='list-role'>$t</div>";
$roles_classes .= " role-" . fp_get_machine_readable($t);
}
}
$render ['user_row_' . $faculty_cwid] = array(
'value' => "<tr class='$roles_classes'>
<td valign='top'>" . l("<i class='fa fa-pencil' title='Edit'></i>", "admin/users/edit-user", "faculty_cwid=$faculty_cwid&de_catalog_year=$de_catalog_year") . "</td>
<td valign='top' width='15%'>$faculty_cwid</td>
<td valign='top' width='15%'>$f_name</td>
<td valign='top' width='15%'>$l_name</td>
<td valign='top'>$dept_name</td>
<td valign='top'>$roles</td>
<td valign='top'>$last_login</td>
</tr>",
'data' => array(
'is_faculty' => 1,
'cwid' => $faculty_cwid,
'db_row' => $cur,
),
);
} // while
$render ['users_table_bottom'] = array(
'value' => "</table>",
);
$rtn = fp_render_content($render);
return $rtn;
}