diff --git a/views/json/resources/livesearch/group_owner_transfer.php b/views/json/resources/livesearch/group_owner_transfer.php index ca41b74a..a5d65838 100644 --- a/views/json/resources/livesearch/group_owner_transfer.php +++ b/views/json/resources/livesearch/group_owner_transfer.php @@ -2,10 +2,11 @@ /** * Livesearch endpoint to search for users who are a member of the provided group * - * @uses get_input('limit') (int) number of results to return - * @uses get_input('term') (string) search term (for username and displayname) - * @uses get_input('name') (string) the input name to be used when submitting the selected value - * @uses get_input('group_guid') (int) the GUID of the group to search members in + * @uses $vars['limit'] (int) number of results to return + * @uses $vars['term'] (string) search term (for username and displayname) + * @uses $vars['name'] (string) the input name to be used when submitting the selected value + * @uses $vars['group_guid'] (int) the GUID of the group to search members in + * @uses $vars['include_banned'] (bool) include banned users in search results * * @throws Elgg\EntityNotFoundException if the group_guid doesn't match a group */ @@ -15,10 +16,11 @@ elgg_gatekeeper(); -$limit = get_input('limit', elgg_get_config('default_limit')); -$query = get_input('term', get_input('q')); -$input_name = get_input('name'); -$group_guid = (int) get_input('group_guid'); +$limit = (int) elgg_extract('limit', $vars, elgg_get_config('default_limit')); +$query = elgg_extract('term', $vars, elgg_extract('q', $vars)); +$input_name = elgg_extract('name', $vars); +$group_guid = (int) elgg_extract('group_guid', $vars); +$include_banned = (bool) elgg_extract('include_banned', $vars, false); $group = get_entity($group_guid); if (!$group instanceof ElggGroup) { @@ -61,8 +63,16 @@ function(QueryBuilder $qb, $main_alias) use ($group_guid) { return $qb->merge($subs, 'OR'); }, ], + 'metadata_name_value_pairs' => [], ]; +if (!$include_banned) { + $options['metadata_name_value_pairs'][] = [ + 'name' => 'banned', + 'value' => 'no', + ]; +} + $body = elgg_list_entities($options, 'elgg_search'); echo elgg_view_page('', $body); diff --git a/views/json/resources/livesearch/non_group_members.php b/views/json/resources/livesearch/non_group_members.php index 11bbe09a..72eae901 100644 --- a/views/json/resources/livesearch/non_group_members.php +++ b/views/json/resources/livesearch/non_group_members.php @@ -1,11 +1,21 @@ $query, @@ -16,19 +26,27 @@ 'fields' => ['metadata' => ['name', 'username']], 'item_view' => 'search/entity', 'input_name' => $input_name, + 'metadata_name_value_pairs' => [], ]; if ($group_guid) { - $options['wheres'][] = function(\Elgg\Database\QueryBuilder $qb) use ($group_guid) { + $options['wheres'][] = function(\Elgg\Database\QueryBuilder $qb, $main_alias) use ($group_guid) { $subquery = $qb->subquery('entity_relationships', 'er'); $subquery->select('er.guid_one') ->where($qb->compare('er.relationship', '=', 'member', ELGG_VALUE_STRING)) ->andWhere($qb->compare('er.guid_two', '=', $group_guid, ELGG_VALUE_INTEGER)); - return $qb->compare("e.guid", 'NOT IN', $subquery->getSQL()); + return $qb->compare("{$main_alias}.guid", 'NOT IN', $subquery->getSQL()); }; } +if (!$include_banned) { + $options['metadata_name_value_pairs'][] = [ + 'name' => 'banned', + 'value' => 'no', + ]; +} + $body = elgg_list_entities($options, 'elgg_search'); echo elgg_view_page('', $body);