Elgg  Version 4.3
access.php
Go to the documentation of this file.
1 <?php
2 
9 $class = elgg_extract_class($vars, 'elgg-access');
10 
12 
13 $entity = elgg_extract('entity', $vars);
14 if ($entity instanceof ElggEntity) {
15  $access_id = $entity->access_id;
16 }
17 
18 if (!isset($access_id)) {
19  return;
20 }
21 
22 $access_id = (int) $access_id;
23 switch ($access_id) {
24  case ACCESS_PUBLIC :
25  $class[] = 'elgg-access-public';
26  break;
27 
28  case ACCESS_LOGGED_IN :
29  $class[] = 'elgg-access-loggedin';
30  break;
31 
32  case ACCESS_PRIVATE :
33  $class[] = 'elgg-access-private';
34  break;
35 
36  default:
38  $owner = false;
39  if ($collection) {
40  $owner = get_entity($collection->owner_guid);
41  }
42  if ($owner instanceof ElggGroup) {
43  $class[] = 'elgg-access-group';
44  $membership = $owner->membership;
45  if ($membership == ACCESS_PUBLIC) {
46  $class[] = 'elgg-access-group-open';
47  } else {
48  $class[] = 'elgg-access-group-closed';
49  }
50  } else {
51  if ($collection && !empty($collection->getSubtype())) {
52  $class[] = 'elgg-access-' . elgg_get_friendly_title($collection->getSubtype());
53  } else {
54  $class[] = 'elgg-access-limited';
55  }
56  }
57  break;
58 }
59 
61  '#tag_name' => 'span',
63  '#options' => [
64  'encode_text' => true,
65  ],
66  'title' => elgg_echo('access:help'),
67  'class' => $class,
68 ]);
foreach($keys as $key=> $default_value) $entity
Definition: access.php:44
$owner
Definition: upload.php:7
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:569
if(isset($vars['options_values'])) $vars['class']
Elgg access level input Displays a dropdown input field.
Definition: access.php:26
const ACCESS_PRIVATE
Definition: constants.php:12
const ACCESS_LOGGED_IN
Definition: constants.php:13
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:547
elgg_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:196
elgg echo
Translates a string.
Definition: deprecated.js:530
elgg_get_friendly_title($title)
When given a title, returns a version suitable for inclusion in a URL.
Definition: output.php:187
const ACCESS_PUBLIC
Definition: constants.php:14
$access_id
Definition: access.php:11
$class
Displays HTML with human readable representation of an access level.
Definition: access.php:9
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:69
elgg_get_access_collection(int $collection_id)
Get a specified access collection.
Definition: access.php:164