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

Add sorting by owner name in view_search



Adds an 'ownername' sort option to view_search, so that results can be
sorted alphabetically by the name of the user, group, or institution
who owns the view.

Change-Id: I78086fb37e3bbc1313a7671f3aa508ed1c0cc93a
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent dc58ab00
......@@ -3032,6 +3032,14 @@ class View {
';
$orderby .= 'GREATEST(lastcomment, v.mtime)';
}
else if ($item['column'] == 'ownername') {
// Join on usr, group, and institution and order by name
$from .= 'LEFT OUTER JOIN {usr} su ON su.id = v.owner
LEFT OUTER JOIN {group} sg ON sg.id = v.group
LEFT OUTER JOIN {institution} si ON si.name = v.institution
';
$orderby .= "COALESCE(sg.name, si.displayname, CASE WHEN su.preferredname IS NOT NULL AND su.preferredname != '' THEN su.preferredname ELSE su.firstname || ' ' || su.lastname END)";
}
else {
$orderby .= 'v.' . $item['column'];
}
......
Supports Markdown
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