Elgg  Version 3.0
group.php
Go to the documentation of this file.
1 <?php
23 function elgg_group_tool_gatekeeper($option, $group_guid = null) {
24  $group_guid = $group_guid ?: elgg_get_page_owner_guid();
25 
26  $group = get_entity($group_guid);
27  if (!$group instanceof \ElggGroup) {
28  return;
29  }
30 
31  if ($group->isToolEnabled($option)) {
32  return;
33  }
34 
35  $ex = new \Elgg\Http\Exception\GroupToolGatekeeperException();
36  $ex->setRedirectUrl($group->getURL());
37  $ex->setParams([
38  'entity' => $group,
39  'tool' => $option,
40  ]);
41 
42  throw $ex;
43 }
44 
56  $container = $params['container'];
57  $user = $params['user'];
58 
59  if ($container instanceof ElggGroup && $user) {
60  /* @var \ElggGroup $container */
61  if ($container->isMember($user)) {
62  return true;
63  }
64  }
65 
66  return $result;
67 }
68 
80 function _elgg_groups_test($hook, $type, $value) {
82  return $value;
83 }
84 
92 function _elgg_groups_init() {
93  elgg_register_plugin_hook_handler('container_permissions_check', 'all', '_elgg_groups_container_override');
94  elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_groups_test');
95 }
96 
100 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
101  $events->registerHandler('init', 'system', '_elgg_groups_init');
102 };
$params
Saves global plugin settings.
Definition: save.php:13
_elgg_groups_container_override($hook, $type, $result, $params)
Allow group members to write to the group container.
Definition: group.php:55
Events service.
$type
Definition: delete.php:21
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:634
elgg_group_tool_gatekeeper($option, $group_guid=null)
Checks if a group has a specific tool enabled.
Definition: group.php:23
Base class for events and hooks.
$container
Definition: delete.php:23
_elgg_groups_test($hook, $type, $value)
Runs unit tests for the group entities.
Definition: group.php:80
$user
Definition: ban.php:7
$value
Definition: debugging.php:7
class
Definition: placeholder.php:21
_elgg_groups_init()
init the groups library
Definition: group.php:92
elgg_get_page_owner_guid($guid=0)
Gets the guid of the entity that owns the current page.
Definition: pageowner.php:22
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87