Commit 832defd7 authored by Matt Clarkson's avatar Matt Clarkson Committed by Robert Lyon
Browse files

Bug 1789297: module/lti: Hide LTI groups

behatnotneeded

Change-Id: Id1516e11a68e1de36d982bb7afbfb59c055fce58
parent 041ec5f4
......@@ -2276,7 +2276,9 @@ function group_get_associated_groups($userid, $filter='all', $limit=20, $offset=
}
}
$count = count_records_sql('SELECT COUNT(*) FROM {group} g ' . $sql . ' WHERE g.deleted = ?'.$catsql, $values);
$sql .= ' LEFT JOIN {lti_assessment} a ON g.id = a.group ';
$count = count_records_sql('SELECT COUNT(*) FROM {group} g ' . $sql . ' WHERE g.deleted = ? AND a.id IS NULL '.$catsql, $values);
// almost the same as query used in find - common parts should probably be pulled out
// gets the groups filtered by above
......@@ -2292,7 +2294,7 @@ function group_get_associated_groups($userid, $filter='all', $limit=20, $offset=
FROM {group} g
LEFT JOIN {group_member} gm ON (gm.group = g.id)' .
$sql . '
WHERE g.deleted = ?' .
WHERE g.deleted = ? AND a.id IS NULL ' .
$catsql . '
GROUP BY g.id, g.name, g.description, g.public, g.jointype, g.request, g.grouptype, g.submittableto,
g.hidemembers, g.hidemembersfrommembers, g.groupparticipationreports, g.urlid, t.membershiptype, t.reason, t.role, g.editwindowstart, g.editwindowend
......@@ -2352,8 +2354,9 @@ function group_get_user_groups($userid=null, $roles=null, $sort=null, $limit=nul
JOIN {group_member} gm ON gm.group = g.id
JOIN {grouptype_roles} gtr ON g.grouptype = gtr.grouptype AND gm.role = gtr.role
LEFT OUTER JOIN {group_member} gm1 ON gm1.group = gm.group AND gm1.member = ?
LEFT JOIN {lti_assessment} a ON a.group = g.id
WHERE gm.member = ?
AND g.deleted = 0
AND g.deleted = 0 AND a.id IS NULL
ORDER BY g.name, gm.role = 'admin' DESC, gm.role, g.id",
array($loggedinid, $userid)
);
......
......@@ -4138,17 +4138,18 @@ class View {
if ($userid) {
$select .= ',v.submittedtime, v.submittedstatus,
g.id AS submitgroupid, g.name AS submitgroupname, g.urlid AS submitgroupurlid,
h.wwwroot AS submithostwwwroot, h.name AS submithostname';
h.wwwroot AS submithostwwwroot, h.name AS submithostname, a.id AS ltiassessment';
$collselect .= ', c.submittedtime, c.submittedstatus,
g.id AS submitgroupid, g.name AS submitgroupname, g.urlid AS submitgroupurlid,
h.wwwroot AS submithostwwwroot, h.name AS submithostname';
h.wwwroot AS submithostwwwroot, h.name AS submithostname, a.id AS ltiassessment';
$emptycollselect .= ', c.submittedtime, c.submittedstatus,
NULL AS submitgroupid, NULL AS submitgroupname, NULL AS submitgroupurlid,
NULL AS submithostwwwroot, NULL AS submithostname';
NULL AS submithostwwwroot, NULL AS submithostname, NULL AS ltiassessment';
$fromstr = '
LEFT OUTER JOIN {group} g ON (v.submittedgroup = g.id AND g.deleted = 0)
LEFT OUTER JOIN {host} h ON (v.submittedhost = h.wwwroot)';
LEFT OUTER JOIN {host} h ON (v.submittedhost = h.wwwroot)
LEFT JOIN {lti_assessment} a ON g.id = a.group ';
$from .= $fromstr;
$collfrom .= $fromstr;
......@@ -4217,7 +4218,12 @@ class View {
if (!empty($data['submittedstatus'])) {
$status = $data['submittedstatus'];
if (!empty($data['submitgroupid'])) {
$url = group_homepage_url((object) array('id' => $data['submitgroupid'], 'urlid' => $data['submitgroupurlid']));
if ($data['ltiassessment']) {
$url = '#';
}
else {
$url = group_homepage_url((object) array('id' => $data['submitgroupid'], 'urlid' => $data['submitgroupurlid']));
}
$name = hsc($data['submitgroupname']);
}
else if (!empty($data['submithostwwwroot'])) {
......
......@@ -853,12 +853,13 @@ class PluginSearchInternal extends PluginSearch {
$sql = "
FROM
{group}
{group} g
LEFT JOIN {lti_assessment} a ON g.id = a.group
WHERE (
name " . db_ilike() . " '%' || ? || '%'
OR description " . db_ilike() . " '%' || ? || '%'
OR shortname " . db_ilike() . " '%' || ? || '%'
) AND deleted = 0 ";
) AND deleted = 0 AND a.id IS NULL ";
$values = array($query_string, $query_string, $query_string);
if (!$grouproles = join(',', array_keys($USER->get('grouproles')))) {
......@@ -868,18 +869,18 @@ class PluginSearchInternal extends PluginSearch {
$canseehidden = $USER->get('admin') || $USER->get('staff');
if ($type == 'member') {
$sql .= 'AND id IN (' . $grouproles . ')';
$sql .= 'AND g.id IN (' . $grouproles . ')';
}
else if ($type == 'notmember') {
$sql .= 'AND id NOT IN (' . $grouproles . ')';
$sql .= 'AND g.id NOT IN (' . $grouproles . ')';
}
else if ($type == 'canjoin') {
$sql .= 'AND (jointype != ? AND NOT (jointype = ? AND request = 0)) AND id NOT IN (' . $grouproles . ')';
$sql .= 'AND (jointype != ? AND NOT (jointype = ? AND request = 0)) AND g.id NOT IN (' . $grouproles . ')';
$values = array_merge($values, array('controlled', 'approve'));
}
if (!$canseehidden) {
$sql .= ' AND (hidden = 0 OR id IN (' . $grouproles . '))';
$sql .= ' AND (hidden = 0 OR g.id IN (' . $grouproles . '))';
}
if (!empty($category)) {
......@@ -898,7 +899,7 @@ class PluginSearchInternal extends PluginSearch {
$count = get_field_sql('SELECT COUNT(*) '.$sql, $values);
if ($count > 0) {
$sql = 'SELECT * ' . $sql . ' ORDER BY name';
$sql = 'SELECT g.* ' . $sql . ' ORDER BY name';
$data = get_records_sql_array($sql, $values, $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