Elgg  Version 2.3
access.php
Go to the documentation of this file.
1 <?php
2 
9 $access_class = 'elgg-access';
10 
11 //sort out the access level for display
12 if (isset($vars['entity']) && elgg_instanceof($vars['entity'])) {
13  $access_id = $vars['entity']->access_id;
14 
15  // if within a group or shared access collection display group name and open/closed membership status
16  // @todo have a better way to do this instead of checking against subtype / class.
17  $container = $vars['entity']->getContainerEntity();
18 
19  if ($container && $container instanceof ElggGroup) {
20  // we decided to show that the item is in a group, rather than its actual access level
21  // not required. Group ACLs are prepended with "Group: " when written.
22  //$access_id_string = elgg_echo('groups:group') . $container->name;
23  $membership = $container->membership;
24 
25  if ($membership == ACCESS_PUBLIC) {
26  $access_class .= ' elgg-access-group-open';
27  } else {
28  $access_class .= ' elgg-access-group-closed';
29  }
30 
31  // @todo this is plugin specific code in core. Should be removed.
32  } elseif ($container && $container->getSubtype() == 'shared_access') {
33  $access_class .= ' shared_collection';
34  } elseif ($access_id == ACCESS_PRIVATE) {
35  $access_class .= ' elgg-access-private';
36  }
37 } else if (isset($vars['value'])) {
38  $access_id = $vars['value'];
39 }
40 
41 if (!isset($access_id)) {
42  return true;
43 }
44 
46 
48  '#tag_name' => 'span',
49  'title' => elgg_echo('access:help'),
50  'class' => $access_class,
51  '#text' => $access_id_string,
52  '#options' => [
53  'encode_text' => true,
54  ],
55 ]);
if(isset($vars['entity'])&&elgg_instanceof($vars['entity'])) else if(isset($vars['value'])) if(!isset($access_id)) $access_id_string
Definition: access.php:45
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:208
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an and optionally for type and subtype.
Definition: entities.php:736
if($entity) $container
Definition: access.php:61
const ACCESS_PRIVATE
Definition: elgglib.php:2082
elgg echo
Translates a string.
Definition: languages.js:48
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:484
$vars['class']
Definition: access.php:29
const ACCESS_PUBLIC
Definition: elgglib.php:2084
$access_class
Displays HTML with human readable representation of an access level.
Definition: access.php:9