Commit 16b7cfab authored by Mikael Mrozik's avatar Mikael Mrozik
Browse files

Reorder group pages (bug #804592)



If user has admin access on a group, reorder the list of pages so that the Group Homepage link
appears at the top, in both the page and the block

Change-Id: I6918a80b87de2b8004259dae8e5b5055c7db826e
Signed-off-by: default avatarMikael Mrozik <mikael@catalyst.net.nz>
parent 09580e3c
......@@ -136,7 +136,8 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
$role = group_user_access($group->id);
if ($role) {
// Get all views created in the group
$data['groupviews'] = View::view_search(null, null, (object) array('group' => $group->id));
$sort = array(array('column' => 'type=\'grouphomepage\'', 'desc' => true));
$data['groupviews'] = View::view_search(null, null, (object) array('group' => $group->id), null, null, 0, true, $sort);
// For group members, display a list of views that others have
// shared to the group
......
......@@ -2390,6 +2390,9 @@ class View {
if ($groupid && group_user_access($groupid) != 'admin') {
$where .= " AND v.type != 'grouphomepage'";
}
else if ($groupid && group_user_access($groupid) == 'admin') {
$sort = ' ORDER BY v.type = \'grouphomepage\' desc, v.title, v.id';
}
if ($userid) {
$select .= ',v.submittedtime,
g.id AS submitgroupid, g.name AS submitgroupname, h.wwwroot AS submithostwwwroot, h.name AS submithostname';
......@@ -2768,7 +2771,7 @@ class View {
if (!empty($sort)) {
$orderby = '';
foreach ($sort as $item) {
if (!preg_match('/^[a-zA-Z_0-9"]+$/', $item['column'])) {
if (!preg_match('/^[a-zA-Z_0-9\'="]+$/', $item['column'])) {
continue; // skip this item (it fails validation)
}
......@@ -2784,16 +2787,17 @@ class View {
}
}
}
$viewdata = get_records_sql_assoc('
SELECT * FROM (
SELECT
v.id, v.title, v.description, v.owner, v.ownerformat, v.group, v.institution,
v.template, v.mtime, v.ctime,
c.id AS collid, c.name
c.id AS collid, c.name, v.type
' . $from . $where . '
GROUP BY
v.id, v.title, v.description, v.owner, v.ownerformat, v.group, v.institution,
v.template, v.mtime, v.ctime, c.id, c.name
v.template, v.mtime, v.ctime, c.id, c.name, v.type
) a
ORDER BY a.' . $orderby . ', a.id ASC',
$ph, $offset, $limit
......
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