]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #3939 if user does not have permissions to see the name of the access collectio...
authorcash <cash.costello@gmail.com>
Mon, 2 Jan 2012 00:29:17 +0000 (19:29 -0500)
committercash <cash.costello@gmail.com>
Mon, 2 Jan 2012 00:29:17 +0000 (19:29 -0500)
engine/lib/access.php
languages/en.php
views/default/output/access.php

index 08b9283cde590371c6713224dcc508b12cdb3566..7be92fbfc449b0cc42f88560e7fa8b7ee80346f9 100644 (file)
@@ -838,7 +838,7 @@ function elgg_list_entities_from_access_id(array $options = array()) {
  *
  * @param int $entity_access_id The entity's access id
  *
- * @return string 'Public', 'Private', etc. or false if error.
+ * @return string 'Public', 'Private', etc.
  * @since 1.7.0
  * @todo I think this probably wants get_access_array() instead of get_write_access_array(),
  * but those two functions return different types of arrays.
@@ -849,15 +849,12 @@ function get_readable_access_level($entity_access_id) {
        //get the access level for object in readable string
        $options = get_write_access_array();
 
-       //@todo Really?  Use array_key_exists()
-       foreach ($options as $key => $option) {
-               if ($key == $access) {
-                       $entity_acl = htmlentities($option, ENT_QUOTES, 'UTF-8');
-                       return $entity_acl;
-                       break;
-               }
+       if (array_key_exists($access, $options)) {
+               return $options[$access];
        }
-       return false;
+
+       // return 'Limited' if the user does not have access to the access collection
+       return elgg_echo('access:limited:label');
 }
 
 /**
index 2f8ab41c97d08cc76fb308cffbeff22d9d3ce041..acc8e0bc0fdf5626947c04cd4e24133513dae82a 100644 (file)
@@ -270,6 +270,8 @@ $english = array(
        'PUBLIC' => "Public",
        'access:friends:label' => "Friends",
        'access' => "Access",
+       'access:limited:label' => "Limited",
+       'access:help' => "The access level",
 
 /**
  * Dashboard and widgets
index 811948323ad43ceb7e404955617d0c5b02487549..91c5c721e79698b74ac6d5131a1b1691c2aa651c 100644 (file)
@@ -11,6 +11,7 @@ if (isset($vars['entity']) && elgg_instanceof($vars['entity'])) {
        $access_id = $vars['entity']->access_id;
        $access_class = 'elgg-access';
        $access_id_string = get_readable_access_level($access_id);
+       $access_id_string = htmlentities($access_id_string, ENT_QUOTES, 'UTF-8');
 
        // if within a group or shared access collection display group name and open/closed membership status
        // @todo have a better way to do this instead of checking against subtype / class.
@@ -35,5 +36,7 @@ if (isset($vars['entity']) && elgg_instanceof($vars['entity'])) {
                $access_class .= ' elgg-access-private';
        }
 
-       echo "<span class=\"$access_class\">$access_id_string</span>";
+       $help_text = elgg_echo('access:help');
+
+       echo "<span title=\"$help_text\" class=\"$access_class\">$access_id_string</span>";
 }