Elgg  Version 4.3
gatekeepers.php
Go to the documentation of this file.
1 <?php
7 
20 function elgg_group_tool_gatekeeper($option, $group_guid = null) {
21  $group_guid = $group_guid ?: elgg_get_page_owner_guid();
22 
23  $group = get_entity($group_guid);
24  if (!$group instanceof \ElggGroup) {
25  return;
26  }
27 
28  if ($group->isToolEnabled($option)) {
29  return;
30  }
31 
32  $ex = new GroupToolGatekeeperException();
33  $ex->setRedirectUrl($group->getURL());
34  $ex->setParams([
35  'entity' => $group,
36  'tool' => $option,
37  ]);
38 
39  throw $ex;
40 }
41 
50  if (\Elgg\Application::isCli()) {
51  return;
52  }
53 
54  _elgg_services()->urlSigner->assertValid(elgg_get_current_url());
55 }
56 
64 function elgg_gatekeeper() {
65  _elgg_services()->gatekeeper->assertAuthenticatedUser();
66 }
67 
76  _elgg_services()->gatekeeper->assertAuthenticatedAdmin();
77 }
78 
99 function elgg_entity_gatekeeper($guid, $type = null, $subtype = null, $validate_can_edit = false) {
100  $entity = _elgg_services()->gatekeeper->assertExists($guid, $type, $subtype);
101  _elgg_services()->gatekeeper->assertAccessibleEntity($entity, null, $validate_can_edit);
102 }
103 
113  _elgg_services()->gatekeeper->assertXmlHttpRequest();
114 }
elgg_entity_gatekeeper($guid, $type=null, $subtype=null, $validate_can_edit=false)
Can the viewer see this entity?
Definition: gatekeepers.php:99
Holds all gatekeeper functions.
elgg_signed_request_gatekeeper()
Validates if the HMAC signature of the current request is valid Issues 403 response if signature is i...
Definition: gatekeepers.php:49
Thrown when the requested group tool isn&#39;t enabled for a group.
$type
Definition: delete.php:21
elgg_get_page_owner_guid()
Elgg page owner library.
Definition: pageowner.php:12
$entity
Definition: reset.php:8
elgg_get_current_url()
Returns the current page&#39;s complete URL.
elgg_group_tool_gatekeeper($option, $group_guid=null)
Checks if a group has a specific tool enabled.
Definition: gatekeepers.php:20
$subtype
Definition: delete.php:22
elgg_gatekeeper()
Used at the top of a page to mark it as logged in users only.
Definition: gatekeepers.php:64
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
elgg_ajax_gatekeeper()
Require that the current request be an XHR.
elgg_admin_gatekeeper()
Used at the top of a page to mark it as admin only.
Definition: gatekeepers.php:75
$guid
Reset an ElggUpgrade.
Definition: reset.php:6
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:69