Elgg  Version 4.3
GroupMemberPermissionsHandler.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 
21  if ($hook->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 = $hook->getEntityParam();
31  $user = $hook->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 }
Models an event passed to hook handlers.
Definition: Hook.php:11
$entity
Definition: reset.php:8
$user
Definition: ban.php:7
$container
Definition: delete.php:23
Check if commenting on group content is allowed.
__invoke(\Elgg\Hook $hook)
Don&#39;t allow users to comment on content in a group they aren&#39;t a member of.
elgg_get_config($name, $default=null)
Get an Elgg configuration value.