Elgg  Version 4.3
EditPermissionsHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Comments;
4 
11 
19  public function __invoke(\Elgg\Hook $hook) {
20  $entity = $hook->getEntityParam();
21  $user = $hook->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 }
Models an event passed to hook handlers.
Definition: Hook.php:11
$entity
Definition: reset.php:8
$user
Definition: ban.php:7
__invoke(\Elgg\Hook $hook)
This makes sure only authors can edit their comments.
$container
Definition: delete.php:23
Returns the correct behaviour for editing comments.
$content
Set robots.txt action.
Definition: set_robots.php:6