Elgg  Version 3.0
access.php
Go to the documentation of this file.
1 <?php
2 
14 $entity = elgg_extract('entity', $vars);
15 if (!$entity instanceof ElggEntity) {
16  return;
17 }
18 
19 $access = elgg_extract('access', $vars);
20 if (!isset($access)) {
21  $access = $entity->access_id;
22 }
23 
24 if ($access === false || !elgg_is_logged_in()) {
25  return;
26 }
27 
28 switch ($access) {
29  case ACCESS_PUBLIC :
30  case ACCESS_LOGGED_IN :
31  $icon_name = 'globe';
32  break;
33  case ACCESS_PRIVATE :
34  $icon_name = 'lock';
35  break;
36  default:
37  $icon_name = 'cog';
38  $collection = get_access_collection($access);
39  if ($collection && ($collection->getSubtype() == 'friends')) {
40  $icon_name = 'user';
41  }
42  break;
43 }
44 
45 $content = elgg_view('output/access', [
46  'value' => $access,
47 ]);
48 
49 echo elgg_view('object/elements/imprint/element', [
50  'icon_name' => elgg_extract('access_icon', $vars, $icon_name),
51  'content' => $content,
52  'class' => 'elgg-listing-access',
53 ]);
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:48
foreach($keys as $key=> $default_value) $entity
Definition: access.php:47
if(!$entity instanceof ElggEntity) $access
Definition: access.php:19
get_access_collection($collection_id)
Get a specified access collection.
Definition: access.php:308
const ACCESS_PRIVATE
Definition: constants.php:12
const ACCESS_LOGGED_IN
Definition: constants.php:13
elgg echo
Translates a string.
Definition: languages.js:43
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
if(!isset($access)) if($access===false||!elgg_is_logged_in()) switch($access) $content
Definition: access.php:45
const ACCESS_PUBLIC
Definition: constants.php:14
$icon_name
Definition: element.php:3
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246