Commit 3e9b94d9 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

change get_associated_groups so including invited and requested groups is an option

user/view.php no longer includes invited and requested groups
parent c64fee7a
......@@ -163,13 +163,33 @@ function get_requested_group($userid=0) {
* either member, invited or requested.
*
* @param int $userid (optional, defaults to $USER id)
* @param boolean $all (optional defaults to true) whether to include requested and invited groups
* @return array of group db rows (with type=member|invite|request)
*/
function get_associated_groups($userid=0) {
function get_associated_groups($userid=0, $all=true) {
$userid = optional_userid($userid);
if (!$all) {
$sql = "SELECT g.*, a.type FROM {group} g JOIN (
SELECT gm.group, 'member' AS type
FROM {group_member} gm
JOIN {group} ON owner != ? AND id = gm.group
WHERE gm.member = ? AND gm.tutor = 0
UNION
SELECT gm.group, 'member' AS type
FROM {group_member} gm
JOIN {group} ON owner != ? AND id = gm.group
WHERE gm.member = ? AND gm.tutor = 1
UNION
SELECT g.id, 'owner' AS type
FROM {group} g WHERE g.owner = ?
) AS a ON a.group = g.id
WHERE g.deleted = 0
ORDER BY g.name";
return get_records_sql_assoc($sql, array($userid, $userid, $userid, $userid, $userid));
}
$sql = "SELECT g.*, a.type FROM {group} g JOIN (
SELECT gm.group, 'invite' AS type
FROM {group_member_invite} gm WHERE gm.member = ?
......
......@@ -143,7 +143,7 @@ if ($views) {
}
// Group stuff
if (!$userassocgroups = get_associated_groups($userid)) {
if (!$userassocgroups = get_associated_groups($userid, false)) {
$userassocgroups = array();
}
......
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