Elgg  Version master
gatekeepers.php
Go to the documentation of this file.
1 <?php
7 
20 function elgg_group_tool_gatekeeper(string $tool_name, int $group_guid = null): void {
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($tool_name)) {
29  return;
30  }
31 
32  $ex = new GroupToolGatekeeperException();
33  $ex->setRedirectUrl($group->getURL());
34  $ex->setParams([
35  'entity' => $group,
36  'tool' => $tool_name,
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(): void {
65  _elgg_services()->gatekeeper->assertAuthenticatedUser();
66 }
67 
76  _elgg_services()->gatekeeper->assertAuthenticatedAdmin();
77 }
78 
99 function elgg_entity_gatekeeper(int $guid, string $type = null, string $subtype = null, bool $validate_can_edit = false): void {
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 }
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.
elgg_entity_gatekeeper(int $guid, string $type=null, string $subtype=null, bool $validate_can_edit=false)
Can the viewer see this entity?
Definition: gatekeepers.php:99
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
$type
Definition: delete.php:22
elgg_get_page_owner_guid()
Elgg page owner library.
Definition: pageowner.php:12
elgg_group_tool_gatekeeper(string $tool_name, int $group_guid=null)
Checks if a group has a specific tool enabled.
Definition: gatekeepers.php:20
$entity
Definition: reset.php:8
get_entity(int $guid)
Loads and returns an entity object from a guid.
Definition: entities.php:68
elgg_get_current_url()
Returns the current page&#39;s complete URL.
$subtype
Definition: delete.php:23
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:346
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