Elgg  Version master
EditPermissionsHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Comments;
4 
11 
19  public function __invoke(\Elgg\Event $event) {
20  $entity = $event->getEntityParam();
21  $user = $event->getUserParam();
22 
23  if (!$entity instanceof \ElggComment || !$user instanceof \ElggUser) {
24  return;
25  }
26 
27  $return = function () use ($entity, $user) {
28  return $entity->owner_guid === $user->guid;
29  };
30 
31  $content = $entity->getContainerEntity();
32  if (!$content instanceof \ElggEntity) {
33  return $return();
34  }
35 
36  $container = $content->getContainerEntity();
37 
38  // use default access for group editors to moderate comments
39  if ($container instanceof \ElggGroup && $container->canEdit($user->guid)) {
40  return;
41  }
42 
43  return $return();
44  }
45 }
__invoke(\Elgg\Event $event)
This makes sure only authors can edit their comments.
$entity
Definition: reset.php:8
$user
Definition: ban.php:7
$container
Definition: delete.php:23
Returns the correct behaviour for editing comments.
$content
Set robots.txt action.
Definition: set_robots.php:6
Models an event passed to event handlers.
Definition: Event.php:11