Commit e2e4b64b authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Show institution student ids on institution users page

parent fbe3a7e6
...@@ -137,6 +137,9 @@ function get_institutional_admin_search_results($search, $limit) { ...@@ -137,6 +137,9 @@ function get_institutional_admin_search_results($search, $limit) {
if ($results['count']) { if ($results['count']) {
foreach ($results['data'] as &$result) { foreach ($results['data'] as &$result) {
$result['name'] = display_name($result); $result['name'] = display_name($result);
if (!empty($result['studentid'])) {
$result['name'] .= ' (' . $result['studentid'] . ')';
}
} }
} }
return $results; return $results;
......
...@@ -382,12 +382,14 @@ class PluginSearchInternal extends PluginSearch { ...@@ -382,12 +382,14 @@ class PluginSearchInternal extends PluginSearch {
$values = array($query,$query); $values = array($query,$query);
} }
$studentid = '';
if (!is_null($institution->member)) { if (!is_null($institution->member)) {
$sql .= ' $sql .= '
LEFT OUTER JOIN {usr_institution} member ON (member.usr = u.id LEFT OUTER JOIN {usr_institution} member ON (member.usr = u.id
AND member.institution = ' . db_quote($institution->name) . ')'; AND member.institution = ' . db_quote($institution->name) . ')';
$where .= ' $where .= '
AND ' . ($institution->member ? ' NOT ' : '') . ' member.usr IS NULL'; AND ' . ($institution->member ? ' NOT ' : '') . ' member.usr IS NULL';
$studentid = ', member.studentid';
} }
if (!is_null($institution->requested) || !is_null($institution->invited)) { if (!is_null($institution->requested) || !is_null($institution->invited)) {
$sql .= ' $sql .= '
...@@ -399,6 +401,7 @@ class PluginSearchInternal extends PluginSearch { ...@@ -399,6 +401,7 @@ class PluginSearchInternal extends PluginSearch {
} else { } else {
$where .= ' AND (req.confirmedusr = 0 OR req.confirmedusr IS NULL)'; $where .= ' AND (req.confirmedusr = 0 OR req.confirmedusr IS NULL)';
} }
$studentid = ', req.studentid';
} }
if (!is_null($institution->invited)) { if (!is_null($institution->invited)) {
if ($institution->requested == 1) { if ($institution->requested == 1) {
...@@ -415,7 +418,7 @@ class PluginSearchInternal extends PluginSearch { ...@@ -415,7 +418,7 @@ class PluginSearchInternal extends PluginSearch {
$data = get_records_sql_array(' $data = get_records_sql_array('
SELECT SELECT
u.id, u.firstname, u.lastname, u.username, u.preferredname, u.id, u.firstname, u.lastname, u.username, u.preferredname,
u.admin, u.staff ' . $sql . $where . ' u.admin, u.staff' . $studentid . $sql . $where . '
ORDER BY u.firstname ASC', ORDER BY u.firstname ASC',
$values, $values,
0, 0,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment