Horde_Perms_Base::getShortName PHP Method

getShortName() public method

Returns the short name of an object, the last portion of the full name.
public getShortName ( string $name ) : string
$name string The name of the object.
return string The object's short name.
    public function getShortName($name)
    {
        /* If there are several components to the name, explode and
         * get the last one, otherwise just return the name. */
        if (strpos($name, ':') !== false) {
            $tmp = explode(':', $name);
            return array_pop($tmp);
        }
        return $name;
    }

Usage Example

Esempio n. 1
0
 /**
  * Given a permission name, returns the title for that permission by
  * looking it up in the applications's permission api.
  *
  * @param string $name  The permissions's name.
  *
  * @return string  The title for the permission.
  */
 public function getTitle($name)
 {
     if ($name === Horde_Perms::ROOT) {
         return Horde_Core_Translation::t("All Permissions");
     }
     $levels = explode(':', $name);
     if (count($levels) == 1) {
         return $this->_registry->get('name', $name) . ' (' . $name . ')';
     }
     array_pop($levels);
     // This is the permission name
     /* First level is always app. */
     $app = $levels[0];
     $app_perms = $this->getApplicationPermissions($app);
     return isset($app_perms['title'][$name]) ? $app_perms['title'][$name] . ' (' . $this->_perms->getShortName($name) . ')' : $this->_perms->getShortName($name);
 }