Elgg  Version master
GroupMemberPermissionsHandler.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 
21  if ($event->getValue() === false) {
22  // already not allowed, no need to check further
23  return;
24  }
25 
26  if (!elgg_get_config('comments_group_only')) {
27  return;
28  }
29 
30  $entity = $event->getEntityParam();
31  $user = $event->getUserParam();
32 
33  if (!$entity instanceof \ElggObject || !$user instanceof \ElggUser) {
34  return;
35  }
36 
37  $container = $entity->getContainerEntity();
38  if (!$container instanceof \ElggGroup) {
39  return;
40  }
41 
42  if ($container->isMember($user)) {
43  return;
44  }
45 
46  return false;
47  }
48 }
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
__invoke(\Elgg\Event $event)
Don&#39;t allow users to comment on content in a group they aren&#39;t a member of.
$entity
Definition: reset.php:8
$user
Definition: ban.php:7
$container
Definition: delete.php:23
Check if commenting on group content is allowed.
Models an event passed to event handlers.
Definition: Event.php:11