listApps() public method

Return a list of the installed and registered applications.
public listApps ( array $filter = null, boolean $assoc = false, integer $perms = Horde_Perms::SHOW ) : array
$filter array An array of the statuses that should be returned. Defaults to non-hidden.
$assoc boolean Return hash with app names as keys and config parameters as values?
$perms integer The permission level to check for in the list. If null, skips permission check.
return array List of apps registered with Horde. If no applications are defined returns an empty array.
Ejemplo n.º 1
0
 /**
  * Returns an array with all the child nodes
  *
  * @return DAV\INode[]
  */
 public function getChildren()
 {
     $apps = $this->_collections;
     foreach ($this->_registry->listApps() as $app) {
         if ($this->_registry->hasMethod('browse', $app)) {
             $apps[] = new Horde_Dav_Collection($app, array(), $this->_registry, $this->_mimedb);
         }
     }
     return $apps;
 }
Ejemplo n.º 2
0
 /**
  * Returns the available permissions for a given level.
  *
  * @param string $name  The permission's name.
  *
  * @return array  An array of available permissions and their titles or
  *                false if not sub permissions exist for this level.
  * @throws Horde_Perms_Exception
  */
 public function getAvailable($name)
 {
     if ($name == Horde_Perms::ROOT) {
         $name = '';
     }
     if (empty($name)) {
         /* No name passed, so top level permissions are requested. These
          * can only be applications. */
         $apps = $this->_registry->listApps(array('notoolbar', 'active', 'hidden'), true);
         foreach (array_keys($apps) as $app) {
             $apps[$app] = $this->_registry->get('name', $app) . ' (' . $app . ')';
         }
         asort($apps);
         return $apps;
     }
     /* Name has been passed, explode the name to get all the levels in
      * permission being requisted, with the app as the first level. */
     $levels = explode(':', $name);
     /* First level is always app. */
     $app = $levels[0];
     /* Call the app's permission function to return the permissions
      * specific to this app. */
     $perms = $this->getApplicationPermissions($app);
     if (!count($perms)) {
         return false;
     }
     /* Get the part of the app's permissions based on the permission
      * name requested. */
     $children = Horde_Array::getElement($perms['tree'], $levels);
     if ($children === false || !is_array($children) || !count($children)) {
         /* No array of children available for this permission name. */
         return false;
     }
     $perms_list = array();
     foreach (array_keys($children) as $perm_key) {
         $perms_list[$perm_key] = $perms['title'][$name . ':' . $perm_key];
     }
     return $perms_list;
 }
Ejemplo n.º 3
0
 /**
  * Returns an unsorted file list of the specified directory.
  *
  * @param string $path          The path of the directory.
  * @param string|array $filter  Regular expression(s) to filter
  *                              file/directory name on.
  * @param boolean $dotfiles     Show dotfiles?
  * @param boolean $dironly      Show only directories?
  *
  * @return array  File list.
  * @throws Horde_Vfs_Exception
  */
 protected function _listFolder($path, $filter = null, $dotfiles = true, $dironly = false)
 {
     $list = array();
     if ($path == '/') {
         try {
             $apps = $this->_registry->listApps(null, false, Horde_Perms::READ);
         } catch (Horde_Exception $e) {
             throw new Horde_Vfs_Exception($e->getMessage());
         }
         foreach ($apps as $app) {
             if ($this->_registry->hasMethod('browse', $app)) {
                 $file = array('name' => $app, 'date' => time(), 'type' => '**dir', 'size' => -1);
                 $list[] = $file;
             }
         }
         return $list;
     }
     if (substr($path, 0, 1) == '/') {
         $path = substr($path, 1);
     }
     $pieces = explode('/', $path);
     try {
         $items = $this->_registry->callByPackage($pieces[0], 'browse', array('path' => $path, 'properties' => array('name', 'browseable', 'contenttype', 'contentlength', 'modified')));
     } catch (Horde_Exception $e) {
         throw new Horde_Vfs_Exception($e->getMessage());
     }
     if (!is_array(reset($items))) {
         /* We return an object's content. */
         throw new Horde_Vfs_Exception('Unknown error');
     }
     foreach ($items as $sub_path => $i) {
         if ($dironly && !$i['browseable']) {
             continue;
         }
         $name = basename($sub_path);
         if ($this->_filterMatch($filter, $name)) {
             continue;
         }
         $type = class_exists('Horde_Mime_Magic') ? Horde_Mime_Magic::mimeToExt(empty($i['contenttype']) ? 'application/octet-stream' : $i['contenttype']) : '**none';
         $file = array('name' => $name, 'date' => empty($i['modified']) ? 0 : $i['modified'], 'type' => $i['browseable'] ? '**dir' : $type, 'size' => empty($i['contentlength']) ? 0 : $i['contentlength']);
         $list[] = $file;
     }
     return $list;
 }
Ejemplo n.º 4
0
 /**
  * Return all active api interfaces.
  *
  * @return array  An array of interface names.
  */
 public function horde_listApis()
 {
     $apis = $this->_registry->horde->listAPIs();
     // Note support not added until 5.1. Need to check the feature.
     // @TODO: H6, add this check to all apps. BC break to check it now,
     // since we didn't have this feature earlier.
     if ($key = array_search('notes', $apis)) {
         if (!$this->hasFeature('activesync', 'notes')) {
             unset($apis[$key]);
         }
     }
     $inactive = $this->_registry->listApps(array('inactive'));
     $active_apis = array();
     foreach ($apis as $api) {
         if (!$this->_registry->isInactive($this->_registry->hasInterface($api))) {
             $active_apis[] = $api;
         }
     }
     return $active_apis;
 }