Elgg  Version 3.0
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 
23 
24 switch ($access_id) {
25  case ACCESS_PUBLIC :
26  $class[] = 'elgg-access-public';
27  break;
28 
29  case ACCESS_LOGGED_IN :
30  $class[] = 'elgg-access-loggedin';
31  break;
32 
33  case ACCESS_PRIVATE :
34  $class[] = 'elgg-access-private';
35  break;
36 
37  default:
38  $collection = get_access_collection($access_id);
39  $owner = false;
40  if ($collection) {
41  $owner = get_entity($collection->owner_guid);
42  }
43  if ($owner instanceof ElggGroup) {
44  $class[] = 'elgg-access-group';
45  $membership = $owner->membership;
46  if ($membership == ACCESS_PUBLIC) {
47  $class[] = 'elgg-access-group-open';
48  } else {
49  $class[] = 'elgg-access-group-closed';
50  }
51  } else {
52  if ($collection && !empty($collection->getSubtype())) {
53  $class[] = 'elgg-access-' . elgg_get_friendly_title($collection->getSubtype());
54  } else {
55  $class[] = 'elgg-access-limited';
56  }
57  }
58  break;
59 }
60 
62  '#tag_name' => 'span',
63  'title' => elgg_echo('access:help'),
64  'class' => $class,
65  '#text' => $access_id_string,
66  '#options' => [
67  'encode_text' => true,
68  ],
69 ]);
foreach($keys as $key=> $default_value) $entity
Definition: access.php:47
$access_id
Definition: access.php:11
get_access_collection($collection_id)
Get a specified access collection.
Definition: access.php:308
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
const ACCESS_PRIVATE
Definition: constants.php:12
$owner
Definition: crop.php:7
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:168
elgg echo
Translates a string.
Definition: languages.js:43
get_readable_access_level($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:397
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:1131
$vars['class']
Definition: access.php:29
elgg_get_friendly_title($title)
When given a title, returns a version suitable for inclusion in a URL.
Definition: output.php:258
if($entity instanceof ElggEntity) if(!isset($access_id)) $access_id_string
Definition: access.php:22
const ACCESS_PUBLIC
Definition: constants.php:14
$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:87