Elgg  Version 4.3
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_require_js('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 (strpos($relationship, 'notify:') === false) {
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']);
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:481
$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:1149
$relationship
Elgg default relationship view.
Definition: default.php:10
$type
Definition: delete.php:21
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
elgg_view_entity_icon(\ElggEntity $entity, $size= 'medium', $vars=[])
View the icon of an entity.
Definition: views.php:567
if(!$user instanceof\ElggUser||empty($description)||empty($purpose)) $methods
Definition: record.php:21
elgg_view_image_block($image, $body, $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:929
foreach($methods as $method) $container
Definition: record.php:62
$entity
Definition: record.php:12
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
$icon_class
Definition: record.php:73
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
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
$preferred_methods
Definition: record.php:28
$has_detailed_subscriptions
Definition: record.php:29
elgg echo
Translates a string.
Definition: deprecated.js:530
$vars['head']
Definition: html.php:24
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
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:179
$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:1536