Elgg  Version 3.0
groups.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
7 $limit = (int) elgg_extract('limit', $vars, elgg_get_config('default_limit'));
10 
12  'query' => $query,
13  'type' => 'group',
14  'limit' => $limit,
15  'sort' => 'name',
16  'order' => 'ASC',
17  'fields' => ['metadata' => ['name']],
18  'item_view' => 'search/entity',
19  'input_name' => $input_name,
20 ];
21 
22 $target_guid = (int) elgg_extract('match_target', $vars);
23 if ($target_guid) {
25 } else {
27 }
28 
29 if (!$target || !$target->canEdit()) {
30  forward('', '403');
31 }
32 
33 if (elgg_extract('match_owner', $vars, false)) {
34  $options['owner_guid'] = (int) $target->guid;
35 }
36 
37 if (elgg_extract('match_membership', $vars, false)) {
38  $options['wheres'][] = function (QueryBuilder $qb, $main_alias) use ($target) {
39  $rel = $qb->subquery('entity_relationships');
40  $rel->select('guid_two')
41  ->where($qb->compare('relationship', '=', 'member', ELGG_VALUE_STRING))
42  ->andWhere($qb->compare('guid_one', '=', $target->guid, ELGG_VALUE_GUID));
43 
44  return $qb->compare("{$main_alias}.guid", 'in', $rel->getSQL());
45  };
46 }
47 
48 $body = elgg_list_entities($options, 'elgg_search');
49 
$query
Definition: groups.php:8
const ELGG_VALUE_GUID
Definition: constants.php:140
Database abstraction query builder.
$target_guid
Definition: groups.php:22
elgg forward
Meant to mimic the php forward() function by simply redirecting the user to another page...
Definition: elgglib.js:417
canEdit($user_guid=0)
Can a user edit this entity?
elgg_list_entities(array $options=[], $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:577
elgg_view_page($title, $body, $page_shell= 'default', $vars=[])
Assembles and outputs a full page.
Definition: views.php:360
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
if(!($comment instanceof\ElggComment)||!$comment->canEdit()) $target
Definition: edit.php:17
elgg echo
Translates a string.
Definition: languages.js:43
$input_name
Definition: groups.php:9
$options
Definition: groups.php:11
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
subquery($table, $alias=null)
Creates a new SelectQueryBuilder for join/where subqueries using the DB connection of the primary Que...
const ELGG_VALUE_STRING
Definition: constants.php:139
$limit
Definition: groups.php:7
$vars['type']
Definition: save.php:11
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:29
if(!$target||!$target->canEdit()) if(elgg_extract('match_owner', $vars, false)) if(elgg_extract('match_membership', $vars, false)) $body
Definition: groups.php:48
elgg_get_config($name, $default=null)
Get an Elgg configuration value.
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87