Elgg  Version master
AutoSubscribeHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Comments;
4 
13 
21  public function __invoke(\Elgg\Event $event): void {
22  $object = $event->getObject();
23  if (!$object instanceof \ElggComment) {
24  return;
25  }
26 
27  $owner = $object->getOwnerEntity();
28  $container = $object->getContainerEntity();
29  if (!$owner instanceof \ElggUser || !$container instanceof \ElggEntity) {
30  return;
31  }
32 
33  if ($container->hasMutedNotifications($owner->guid)) {
34  // user already said to not receive notifications, so don't force it
35  return;
36  }
37 
38  $comment_preferences = $owner->getNotificationSettings('create_comment');
39  $enabled_methods = array_keys(array_filter($comment_preferences));
40  if (empty($enabled_methods)) {
41  return;
42  }
43 
44  $container->addSubscription($owner->guid, $enabled_methods);
45  }
46 }
$owner
Definition: upload.php:7
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
__invoke(\Elgg\Event $event)
Subscribe the user to the comment container.
$container
Definition: delete.php:23
if($email instanceof\Elgg\Email) $object
Definition: body.php:24
When a comment is created subscribe the owner to the container (original content) of the comment if t...
Models an event passed to event handlers.
Definition: Event.php:11