Elgg  Version 1.9
access.php
Go to the documentation of this file.
1 <?php
13 if (isset($vars['class'])) {
14  $vars['class'] = "elgg-input-access {$vars['class']}";
15 } else {
16  $vars['class'] = "elgg-input-access";
17 }
18 
19 $defaults = array(
20  'disabled' => false,
21  'value' => get_default_access(),
22  'options_values' => get_write_access_array(),
23 );
24 
25 /* @var ElggEntity $entity */
26 $entity = elgg_extract('entity', $vars);
27 unset($vars['entity']);
28 
29 // should we tell users that public/logged-in access levels will be ignored?
31 if (($container instanceof ElggGroup)
32  && $container->getContentAccessMode() === ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY
33  && !elgg_in_context('group-edit')
34  && !($entity && $entity instanceof ElggGroup)) {
35  $show_override_notice = true;
36 } else {
37  $show_override_notice = false;
38 }
39 
40 if ($entity) {
41  $defaults['value'] = $entity->access_id;
42 }
43 
44 $vars = array_merge($defaults, $vars);
45 
46 if ($vars['value'] == ACCESS_DEFAULT) {
47  $vars['value'] = get_default_access();
48 }
49 
50 if (is_array($vars['options_values']) && sizeof($vars['options_values']) > 0) {
51  if ($show_override_notice) {
52  $vars['data-group-acl'] = $container->group_acl;
53  }
54  echo elgg_view('input/select', $vars);
55  if ($show_override_notice) {
56  echo "<p class='elgg-text-help'>" . elgg_echo('access:overridenotice') . "</p>";
57  }
58 }
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1464
if($entity) $vars
Definition: access.php:44
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_in_context($context)
Check if this context exists anywhere in the stack.
Definition: pageowner.php:273
elgg echo
Translates a string.
Definition: languages.js:43
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:53
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
const CONTENT_ACCESS_MODE_MEMBERS_ONLY
Definition: ElggGroup.php:16
get_default_access(ElggUser $user=null)
Gets the default access permission.
Definition: access.php:246
$defaults
Definition: access.php:19
const ACCESS_DEFAULT
Definition: elgglib.php:2120
$container
Definition: access.php:30
get_write_access_array($user_guid=0, $site_guid=0, $flush=false)
Returns an array of access permissions that the user is allowed to save content with.
Definition: access.php:484
$entity
Definition: access.php:26