Elgg  Version 4.x
access.php
Go to the documentation of this file.
1 <?php
16 function elgg_get_ignore_access(): bool {
17  return _elgg_services()->session->getIgnoreAccess();
18 }
19 
38 function get_access_array(int $user_guid = 0): array {
39  return _elgg_services()->accessCollections->getAccessArray($user_guid);
40 }
41 
54 function get_default_access(ElggUser $user = null, array $input_params = []): int {
55  // site default access
56  $default_access = _elgg_services()->config->default_access;
57 
58  // user default access if enabled
59  if (_elgg_services()->config->allow_user_default_access) {
60  $user = $user ? $user : _elgg_services()->session->getLoggedInUser();
61  if ($user) {
62  $user_access = $user->getPrivateSetting('elgg_default_access');
63  if ($user_access !== null) {
64  $default_access = $user_access;
65  }
66  }
67  }
68 
69  $params = [
70  'user' => $user,
71  'default_access' => $default_access,
72  'input_params' => $input_params,
73  ];
74  return _elgg_services()->hooks->trigger('default', 'access', $params, $default_access);
75 }
76 
96  return _elgg_services()->accessCollections->hasAccessToEntity($entity, $user);
97 }
98 
125 function get_write_access_array(int $user_guid = 0, $ignored = 0, bool $flush = false, array $input_params = []): array {
126  return _elgg_services()->accessCollections->getWriteAccessArray($user_guid, $flush, $input_params);
127 }
128 
143 function can_edit_access_collection(int $collection_id, int $user_guid = null): bool {
144  return _elgg_services()->accessCollections->canEdit($collection_id, $user_guid);
145 }
146 
165 function create_access_collection(string $name, int $owner_guid = 0, $subtype = null) {
166  return _elgg_services()->accessCollections->create($name, $owner_guid, $subtype);
167 }
168 
177 function delete_access_collection(int $collection_id): bool {
178  return _elgg_services()->accessCollections->delete($collection_id);
179 }
180 
193 function get_access_collection(int $collection_id) {
194  return _elgg_services()->accessCollections->get($collection_id);
195 }
196 
207 function add_user_to_access_collection(int $user_guid, int $collection_id): bool {
208  return _elgg_services()->accessCollections->addUser($user_guid, $collection_id);
209 }
210 
221 function remove_user_from_access_collection(int $user_guid, int $collection_id): bool {
222  return _elgg_services()->accessCollections->removeUser($user_guid, $collection_id);
223 }
224 
232 function elgg_get_access_collections(array $options = []) {
233  return _elgg_services()->accessCollections->getEntityCollections($options);
234 }
235 
245 function get_members_of_access_collection(int $collection_id, bool $guids_only = false, array $options = []) {
246  if (!isset($options['limit'])) {
247  $options['limit'] = false;
248  }
249 
250  if (!$guids_only) {
251  return _elgg_services()->accessCollections->getMembers($collection_id, $options);
252  }
253 
254  $options['callback'] = function($row) {
255  return (int) $row->guid;
256  };
257 
258  return _elgg_services()->accessCollections->getMembers($collection_id, $options);
259 }
260 
278 function get_readable_access_level(int $entity_access_id): string {
279  return _elgg_services()->accessCollections->getReadableAccessLevel($entity_access_id);
280 }
$user_guid
Definition: login_as.php:10
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
get_access_collection(int $collection_id)
Get a specified access collection.
Definition: access.php:193
foreach($keys as $key=> $default_value) $entity
Definition: access.php:44
get_write_access_array(int $user_guid=0, $ignored=0, bool $flush=false, array $input_params=[])
Returns an array of access permissions that the user is allowed to save content with.
Definition: access.php:125
$subtype
Definition: delete.php:22
$input_params
Definition: livesearch.php:14
$options
Elgg admin footer.
Definition: footer.php:6
elgg_get_ignore_access()
Functions for Elgg&#39;s access system for entities, metadata, and annotations.
Definition: access.php:16
$params
Definition: access.php:29
$owner_guid
can_edit_access_collection(int $collection_id, int $user_guid=null)
Can the user change this access collection?
Definition: access.php:143
elgg_get_access_collections(array $options=[])
Returns access collections.
Definition: access.php:232
$user
Definition: ban.php:7
delete_access_collection(int $collection_id)
Deletes a specified access collection and its membership.
Definition: access.php:177
remove_user_from_access_collection(int $user_guid, int $collection_id)
Removes a user from an access collection.
Definition: access.php:221
get_readable_access_level(int $entity_access_id)
Return the name of an ACCESS_* constant or an access collection, but only if the logged in user has w...
Definition: access.php:278
get_members_of_access_collection(int $collection_id, bool $guids_only=false, array $options=[])
Get all of members of an access collection.
Definition: access.php:245
add_user_to_access_collection(int $user_guid, int $collection_id)
Adds a user to an access collection.
Definition: access.php:207
get_access_array(int $user_guid=0)
Returns an array of access IDs a user is permitted to see.
Definition: access.php:38
has_access_to_entity(\ElggEntity $entity,\ElggUser $user=null)
Can a user access an entity.
Definition: access.php:95
_elgg_services()
Get the global service provider.
Definition: elgglib.php:777
get_default_access(ElggUser $user=null, array $input_params=[])
Gets the default access permission.
Definition: access.php:54
create_access_collection(string $name, int $owner_guid=0, $subtype=null)
Creates a new access collection.
Definition: access.php:165
if(!$user instanceof ElggUser) $default_access