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 
20  '#help' => elgg_echo('usersettings:notifications:timed_muting:help'),
21  'align' => 'horizontal',
22  'fields' => [
23  [
24  '#type' => 'date',
25  '#label' => elgg_echo('usersettings:notifications:timed_muting:start'),
26  'name' => 'timed_muting_start',
27  'value' => $start,
28  'timestamp' => true,
29  ],
30  [
31  '#type' => 'date',
32  '#label' => elgg_echo('usersettings:notifications:timed_muting:end'),
33  'name' => 'timed_muting_end',
34  'value' => $end,
35  'timestamp' => true,
36  ],
37  ],
38  ],
39 ];
40 
41 if (!empty($start) && !empty($end) && $start < time() && $end > time()) {
42  $fields[] = [
43  '#html' => elgg_view_message('warning', elgg_echo('usersettings:notifications:timed_muting:warning'), ['title' => false]),
44  ];
45 }
46 
47 echo elgg_view_field([
48  '#type' => 'fieldset',
49  '#label' => elgg_echo('usersettings:notifications:timed_muting'),
50  '#class' => 'ptl',
51  'fields' => $fields,
52 ]);
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