Elgg  Version 1.9
access.php
Go to the documentation of this file.
1 <?php
9 //sort out the access level for display
10 if (isset($vars['entity']) && elgg_instanceof($vars['entity'])) {
11  $access_id = $vars['entity']->access_id;
12  $access_class = 'elgg-access';
13  $access_id_string = get_readable_access_level($access_id);
14  $access_id_string = htmlspecialchars($access_id_string, ENT_QUOTES, 'UTF-8', false);
15 
16  // if within a group or shared access collection display group name and open/closed membership status
17  // @todo have a better way to do this instead of checking against subtype / class.
18  $container = $vars['entity']->getContainerEntity();
19 
20  if ($container && $container instanceof ElggGroup) {
21  // we decided to show that the item is in a group, rather than its actual access level
22  // not required. Group ACLs are prepended with "Group: " when written.
23  //$access_id_string = elgg_echo('groups:group') . $container->name;
24  $membership = $container->membership;
25 
26  if ($membership == ACCESS_PUBLIC) {
27  $access_class .= ' elgg-access-group-open';
28  } else {
29  $access_class .= ' elgg-access-group-closed';
30  }
31 
32  // @todo this is plugin specific code in core. Should be removed.
33  } elseif ($container && $container->getSubtype() == 'shared_access') {
34  $access_class .= ' shared_collection';
35  } elseif ($access_id == ACCESS_PRIVATE) {
36  $access_class .= ' elgg-access-private';
37  }
38 
39  $help_text = elgg_echo('access:help');
40 
41  echo "<span title=\"$help_text\" class=\"$access_class\">$access_id_string</span>";
42 }
if($entity) $vars
Definition: access.php:44
elgg_instanceof($entity, $type=null, $subtype=null, $class=null)
Checks if $entity is an ElggEntity and optionally for type and subtype.
Definition: entities.php:1886
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
const ACCESS_PRIVATE
Definition: elgglib.php:2121
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:940
const ACCESS_PUBLIC
Definition: elgglib.php:2123
$container
Definition: access.php:30