Elgg  Version 5.1
users.php
Go to the documentation of this file.
1 <?php
10 
11 $user = elgg_extract('entity', $vars);
12 if (!$user instanceof \ElggUser) {
13  return;
14 }
15 
16 echo elgg_view_field([
17  '#type' => 'hidden',
18  'name' => 'guid',
19  'value' => $user->guid,
20 ]);
21 
22 echo elgg_view('output/longtext', [
23  'value' => elgg_echo('usersettings:notifications:users:description'),
24 ]);
25 
26 // Returns a list of all friends, as well as anyone else who the user is subscribed to
28  'selects' => ['GROUP_CONCAT(ers.relationship) as relationships'],
29  'types' => 'user',
30  'joins' => [
31  new JoinClause('entity_relationships', 'ers', function(QueryBuilder $qb, $joined_alias, $main_alias) use ($user) {
32  return $qb->merge([
33  $qb->compare("{$joined_alias}.guid_two", '=', "{$main_alias}.guid"),
34  $qb->compare("{$joined_alias}.guid_one", '=', $user->guid, ELGG_VALUE_INTEGER),
35  ], 'AND');
36  }),
37  ],
38  'wheres' => [
39  function(QueryBuilder $qb) {
40  return $qb->merge([
41  $qb->compare('ers.relationship', '=', 'friend', ELGG_VALUE_STRING),
42  $qb->compare('ers.relationship', 'LIKE', 'notify:%', ELGG_VALUE_STRING),
43  ], 'OR');
44  },
45  ],
46  'sort_by' => [
47  'property' => 'name',
48  'direction' => 'ASC',
49  ],
50  'group_by' => 'e.guid',
51  'offset_key' => 'subscriptions_users',
52  'item_view' => 'notifications/subscriptions/record',
53  'user' => $user,
54  'limit' => 10,
55  'list_class' => 'elgg-subscriptions',
56  'item_class' => 'elgg-subscription-record',
57  'pagination_behaviour' => 'ajax-replace',
58 ]);
59 
60 if (empty($list)) {
61  echo elgg_view('page/components/no_results', [
62  'no_results' => elgg_echo('notifications:subscriptions:no_results'),
63  ]);
64  return;
65 }
66 
67 echo $list;
68 
69 // form footer
71  '#type' => 'submit',
72  'text' => elgg_echo('save'),
73 ]);
74 
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1133
const ELGG_VALUE_INTEGER
Value types.
Definition: constants.php:111
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
Extends QueryBuilder with JOIN clauses.
Definition: JoinClause.php:11
Database abstraction query builder.
$footer
Definition: users.php:70
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
elgg_set_form_footer(string $footer= '')
Sets form footer and defers its rendering until the form view and extensions have been rendered...
Definition: views.php:1067
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
$user
Definition: users.php:11
$list
Definition: users.php:27
elgg_list_entities(array $options=[], callable $getter=null, callable $viewer=null)
Returns a string of rendered entities.
Definition: entities.php:548
merge($parts=null, $boolean= 'AND')
Merges multiple composite expressions with a boolean.
$vars
Definition: theme.php:5
const ELGG_VALUE_STRING
Definition: constants.php:112
$qb
Definition: queue.php:11