Elgg  Version 6.1
record.php
Go to the documentation of this file.
1 <?php
12 $entity = elgg_extract('entity', $vars);
13 
14 if (!$entity instanceof ElggEntity || !$user instanceof ElggUser || !$user->canEdit()) {
15  return;
16 }
17 
19 if (empty($methods)) {
20  return;
21 }
22 
23 elgg_import_esm('notifications/subscriptions/record');
24 elgg_require_css('notifications/subscriptions/record');
25 
27 
30 
31 // This volatile data is stored during a query with a custom select option
32 $relationships_concat = $entity->getVolatileData('select:relationships');
33 if (isset($relationships_concat)) {
34  $relationships = explode(',', $relationships_concat);
35  foreach ($relationships as $relationship) {
36  if (!str_contains($relationship, 'notify:')) {
37  continue;
38  }
39 
40  $parts = explode(':', $relationship);
41  if (count($parts) > 2) {
43  } else {
44  $type = $parts[1];
46  }
47  }
48 } else {
49  foreach ($methods as $method) {
50  if ($entity->hasSubscription($user->guid, $method)) {
51  $preferred_methods[$method] = $method;
52  }
53  }
54 }
55 
56 $method_options = [];
57 foreach ($methods as $method) {
58  $label = elgg_echo("notification:method:{$method}");
59  $method_options[$label] = $method;
60 }
61 
62 $container = elgg_format_element('div', ['class' => 'elgg-subscription-description'], elgg_view_image_block($icon, elgg_view_entity_url($entity)));
64  '#type' => 'checkboxes',
65  '#class' => 'elgg-subscription-methods',
66  'name' => "subscriptions[{$entity->guid}][notify]",
67  'options' => $method_options,
68  'value' => $preferred_methods,
69  'align' => 'horizontal',
70  'disabled' => $has_detailed_subscriptions,
71 ]);
72 
73 $icon_class = ['elgg-subscription-details-toggle'];
75  $icon_class[] = 'elgg-state-active';
76 }
77 
78 $container .= elgg_view('output/url', [
79  'href' => false,
80  'text' => elgg_echo('settings'),
81  'title' => elgg_echo('notifications:subscriptions:record:settings'),
82  'icon' => 'chevron-down',
83  'class' => $icon_class,
84  'data-view' => elgg_http_add_url_query_elements('notifications/subscriptions/details', [
85  'user_guid' => $user->guid,
86  'entity_guid' => $entity->guid,
87  ]),
88 ]);
89 $container .= elgg_view('output/url', [
90  'href' => false,
91  'text' => elgg_echo('settings'),
92  'icon' => 'chevron-up',
93  'class' => array_merge($icon_class, ['hidden']),
94 ]);
95 
96 echo elgg_format_element('div', ['class' => 'elgg-subscription-container'], $container);
97 
98 // placeholder for the details
99 echo elgg_format_element('div', ['class' => 'elgg-subscription-container-details']);
$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_require_css(string $view)
Register a CSS view name to be included in the HTML head.
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1112
elgg_view_image_block(string $image, string $body, array $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:898
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$relationship
Elgg default relationship view.
Definition: default.php:10
$type
Definition: delete.php:21
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
foreach($methods as $method) $container
Definition: record.php:62
$entity
Definition: record.php:12
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
elgg_view_entity_icon(\ElggEntity $entity, string $size= 'medium', array $vars=[])
View the icon of an entity.
Definition: views.php:542
elgg_import_esm(string $name)
Helper functions for external files like css/js.
$icon_class
Definition: record.php:73
elgg_http_add_url_query_elements(string $url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:183
$preferred_methods
Definition: record.php:28
$vars
Definition: theme.php:5
$has_detailed_subscriptions
Definition: record.php:29
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
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
$icon
Definition: record.php:26
$relationships_concat
Definition: record.php:32
elgg_view_entity_url(\ElggEntity $entity, array $options=[])
Helper function for outputting a link to an entity.
Definition: views.php:1444