Elgg  Version 4.3
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 
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  'value' => 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:1149
const ELGG_VALUE_INTEGER
Value types.
Definition: constants.php:126
Extends QueryBuilder with JOIN clauses.
Definition: JoinClause.php:12
Database abstraction query builder.
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
elgg_set_form_footer($footer= '')
Sets form footer and defers its rendering until the form view and extensions have been rendered...
Definition: views.php:1083
elgg_list_entities(array $options=[], $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:589
$footer
Definition: users.php:70
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
$user
Definition: users.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:547
$list
Definition: users.php:27
merge($parts=null, $boolean= 'AND')
Merges multiple composite expressions with a boolean.
const ELGG_VALUE_STRING
Definition: constants.php:127
elgg echo
Translates a string.
Definition: deprecated.js:530
$vars['head']
Definition: html.php:24
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:179
$qb
Definition: queue.php:11