Elgg  Version 6.1
record.php
Go to the documentation of this file.
1 <?php
14 $user = elgg_extract('entity', $vars);
15 $description = elgg_extract('description', $vars);
16 $purpose = elgg_extract('purpose', $vars);
17 if (!$user instanceof \ElggUser || empty($description) || empty($purpose)) {
18  return;
19 }
20 
22 if (empty($methods)) {
23  return;
24 }
25 
27 foreach ($methods as $method) {
28  $label = elgg_echo("notification:method:{$method}");
29  $method_options[$label] = $method;
30 }
31 
32 ?>
33 <div>
34  <div>
35  <?= $description; ?>
36  </div>
37  <?php
38  $value = array_keys(array_filter($user->getNotificationSettings($purpose)));
39  echo elgg_view_field([
40  '#type' => 'checkboxes',
41  'name' => "notification_setting[{$purpose}]",
42  'options' => $method_options,
43  'default' => 0,
44  'value' => $value,
45  'align' => 'horizontal',
46  ]);
47  ?>
48 </div>
$user
Generic view to set a notification preference for a specific purpose.
Definition: record.php:14
if($view &&elgg_view_exists($view)) $label
Definition: field.php:26
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
if(!$user instanceof\ElggUser||empty($description)||empty($purpose)) $methods
Definition: record.php:21
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:256
$value
Definition: record.php:38
$description
Definition: record.php:15
$purpose
Definition: record.php:16
$vars
Definition: theme.php:5
elgg_get_notification_methods()
Returns registered delivery methods for notifications [ &#39;email&#39; => &#39;email&#39;, &#39;sms&#39; => &#39;sms&#39;...
if(empty($methods)) $method_options
Definition: record.php:26