Elgg  Version master
timed_muting.php
Go to the documentation of this file.
1 <?php
8 $user = elgg_extract('entity', $vars);
9 if (!$user instanceof \ElggUser) {
10  return;
11 }
12 
13 $start = $user->timed_muting_start;
14 $end = $user->timed_muting_end;
15 
17  [
18  '#type' => 'fieldset',
19  '#help' => elgg_echo('usersettings:notifications:timed_muting:help'),
20  'align' => 'horizontal',
21  'fields' => [
22  [
23  '#type' => 'date',
24  '#label' => elgg_echo('usersettings:notifications:timed_muting:start'),
25  'name' => 'timed_muting_start',
26  'value' => $start,
27  'timestamp' => true,
28  ],
29  [
30  '#type' => 'date',
31  '#label' => elgg_echo('usersettings:notifications:timed_muting:end'),
32  'name' => 'timed_muting_end',
33  'value' => $end,
34  'timestamp' => true,
35  ],
36  ],
37  ],
38 ];
39 
40 if (!empty($start) && !empty($end) && $start < time() && $end > time()) {
41  $fields[] = [
42  '#html' => elgg_view_message('warning', elgg_echo('usersettings:notifications:timed_muting:warning'), ['title' => false]),
43  ];
44 }
45 
46 echo elgg_view_field([
47  '#type' => 'fieldset',
48  'legend' => elgg_echo('usersettings:notifications:timed_muting'),
49  'fields' => $fields,
50 ]);
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1112
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$fields
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
if(!$user instanceof\ElggUser) $start
$vars
Definition: theme.php:5
elgg_view_message(string $type, string $body, array $vars=[])
Wrapper function for the message display pattern.
Definition: views.php:940
$end
$user
Set a time window where you don&#39;t wish to receive notifications.
Definition: timed_muting.php:8