Commit 37e586a6 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

Add 'groups I can join' to groups search conditions (bug #1081194)



Change-Id: I77df774a700ad846a02762bcf4e2fa75609f7f04
Signed-off-by: default avatarRuslan Kabalin <r.kabalin@lancaster.ac.uk>
parent 63395f24
......@@ -32,17 +32,15 @@ require_once('pieforms/pieform.php');
define('TITLE', get_string('findgroups'));
require_once('group.php');
require_once('searchlib.php');
$filter = param_alpha('filter', 'notmember');
$filter = param_alpha('filter', 'canjoin');
$offset = param_integer('offset', 0);
$groupcategory = param_signed_integer('groupcategory', 0);
$groupsperpage = 10;
$query = param_variable('query', '');
if ($filter == 'member') {
$type = 'member';
}
else if ($filter == 'notmember') {
$type = 'notmember';
// check that the filter is valid, if not default to 'all'
if (in_array($filter, array('member', 'notmember', 'canjoin'))) {
$type = $filter;
}
else { // all or some other text
$filter = 'all';
......@@ -55,6 +53,7 @@ $elements['query'] = array(
$elements['filter'] = array(
'type' => 'select',
'options' => array(
'canjoin' => get_string('groupsicanjoin', 'group'),
'notmember' => get_string('groupsnotin', 'group'),
'member' => get_string('groupsimin', 'group'),
'all' => get_string('allgroups', 'group')
......@@ -134,9 +133,7 @@ if ($groups['data']) {
group_prepare_usergroups_for_display($groups['data'], 'find');
$params = array();
if ($filter != 'notmember') {
$params['filter'] = $filter;
}
$params['filter'] = $filter;
if ($groupcategory != 0) {
$params['groupcategory'] = $groupcategory;
}
......
......@@ -196,6 +196,7 @@ $string['groupsimin'] = 'Groups I\'m in';
$string['groupsiown'] = 'Groups I own';
$string['groupsiminvitedto'] = 'Groups I\'m invited to';
$string['groupsiwanttojoin'] = 'Groups I want to join';
$string['groupsicanjoin'] = 'Groups I can join';
$string['requestedtojoin'] = 'You have requested to join this group';
$string['groupnotfound'] = 'Group with id %s not found';
$string['groupnotfoundname'] = 'Group %s not found';
......
......@@ -721,16 +721,18 @@ class PluginSearchInternal extends PluginSearch {
$canseehidden = $USER->get('admin') || $USER->get('staff');
if ($type == 'member') {
if ($type == 'member') {
$sql .= 'AND id IN (' . $grouproles . ')';
}
else if ($type == 'notmember') {
$sql .= 'AND id NOT IN (' . $grouproles . ')';
if (!$canseehidden) {
$sql .= ' AND hidden = 0';
}
}
else if (!$canseehidden) {
else if ($type == 'canjoin') {
$sql .= 'AND jointype != ? AND id NOT IN (' . $grouproles . ')';
$values[] = 'controlled';
}
if (!$canseehidden) {
$sql .= ' AND (hidden = 0 OR id IN (' . $grouproles . '))';
}
......
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