Commit 09b228c6 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Make all the dropdowns on "My Groups" work again.

May need more testing with more data, but they don't cause errors any more.
parent 64c97603
......@@ -39,56 +39,60 @@ $offset = param_integer('offset', 'all');
$groupsperpage = 20;
$offset = (int)($offset / $groupsperpage) * $groupsperpage;
// casting is only needed for invite, request and owner and only in postgres
// Strangely, casting is only needed for invite, request and admin and only in
// postgres
if (is_mysql()) {
$invitesql = "'invite'";
$requestsql = "'request'";
$ownersql = "'owner'";
$adminsql = "'admin'";
}
else {
$invitesql = "CAST('invite' AS TEXT)";
$requestsql = "CAST('request' AS TEXT)";
$ownersql = "CAST('owner' AS TEXT)";
$adminsql = "CAST('admin' AS TEXT)";
}
// different filters join on the different kinds of association
if ($filter == 'owner') {
$sql = '
// Different filters join on the different kinds of association
if ($filter == 'admin') {
$sql = "
INNER JOIN (
SELECT g.id, ' . $ownersql . ' AS type
SELECT g.id, $adminsql AS membershiptype
FROM {group} g
WHERE g.owner = ?
) t ON t.id = g.id';
INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ?)
INNER JOIN {group_role_instance} gri ON (gri.group = g.id AND gri.roletype = 'admin' AND gri.id = gm.roleinstance)
) t ON t.id = g.id";
$values = array($USER->get('id'));
}
else if ($filter == 'member') {
$sql = '
$sql = "
INNER JOIN (
SELECT g.id, \'owner\' AS type
SELECT g.id, 'owner' AS membershiptype
FROM {group} g
WHERE g.owner = ?
UNION SELECT g.id, \'member\' AS type
INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ?)
INNER JOIN {group_role_instance} gri ON (gri.group = g.id AND gri.roletype = 'admin' AND gri.id = gm.roleinstance)
UNION SELECT g.id, 'member' AS type
FROM {group} g
INNER JOIN {group_member} gm ON (g.id = gm.group AND gm.member = ?)
WHERE g.owner != gm.member
) t ON t.id = g.id';
INNER JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ?)
INNER JOIN {group_role_instance} gri ON (gri.group = g.id AND gri.roletype != 'admin' AND gri.id = gm.roleinstance)
) t ON t.id = g.id";
$values = array($USER->get('id'), $USER->get('id'));
}
else if ($filter == 'invite') {
$sql = '
$sql = "
INNER JOIN (
SELECT g.id, ' . $invitesql . ' AS type
SELECT g.id, $invitesql AS membershiptype
FROM {group} g
INNER JOIN {group_member_invite} gmi ON (gmi.group = g.id AND gmi.member = ?)
) t ON t.id = g.id';
) t ON t.id = g.id";
$values = array($USER->get('id'));
}
else if ($filter == 'request') {
$sql = '
$sql = "
INNER JOIN (
SELECT g.id, ' . $requestsql . ' AS type
SELECT g.id, $requestsql AS membershiptype
FROM {group} g
INNER JOIN {group_member_request} gmr ON (gmr.group = g.id AND gmr.member = ?)
) t ON t.id = g.id';
) t ON t.id = g.id";
$values = array($USER->get('id'));
}
else { // all or some other text
......@@ -124,7 +128,7 @@ $form = pieform(array(
'type' => 'select',
'options' => array(
'all' => get_string('allmygroups', 'group'),
'owner' => get_string('groupsiown', 'group'),
'admin' => get_string('groupsiown', 'group'),
'member' => get_string('groupsimin', 'group'),
'invite' => get_string('groupsiminvitedto', 'group'),
'request' => get_string('groupsiwanttojoin', 'group')
......
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