Add Horde_Registry#listAllApps
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 22 Jan 2010 16:27:05 +0000 (11:27 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 22 Jan 2010 16:27:05 +0000 (11:27 -0500)
Allow for listing of applications without regard to permissions. Needed
to solve chicken-or-egg problem of setting up a new install, but admin/setup
failing to load because of applications without configuration files.

This broke when fixing Bug: 8475 when we check auth before checking isAdmin()

framework/Core/lib/Horde/Registry.php
horde/admin/setup/index.php

index e5d6920..4e70ad5 100644 (file)
@@ -555,6 +555,27 @@ class Horde_Registry
     }
 
     /**
+     * Return a list of all applications, ignoring permissions.
+     *
+     * @return array
+     */
+    public function listAllApps($filter = null)
+    {
+        // Default to all installed (but possibly not configured) applications)
+        if (is_null($filter)) {
+            $filter = array('inactive', 'hidden', 'notoolbar', 'active', 'admin');
+        }
+        $apps = array();
+        foreach ($this->applications as $app => $params) {
+            if (in_array($params['status'], $filter)) {
+                $apps[] = $app;
+            }
+        }
+
+        return $apps;
+    }
+
+    /**
      * Returns all available registry APIs.
      *
      * @return array  The API list.
@@ -1121,8 +1142,7 @@ class Horde_Registry
         }
 
         /* Otherwise, allow access for admins, for apps that do not have any
-         * have any explicit permissions, or for apps that allow the given
-         * permission. */
+         * explicit permissions, or for apps that allow the given permission. */
         return Horde_Auth::isAdmin() ||
             !$GLOBALS['perms']->exists($app) ||
             $GLOBALS['perms']->hasPermission($app, Horde_Auth::getAuth(), $perms);
index e129696..2ee9b03 100644 (file)
@@ -94,7 +94,7 @@ $warning = Horde::img('alerts/warning.png');
 $error = Horde::img('alerts/error.png');
 
 $conf_url = Horde::applicationUrl('admin/setup/config.php');
-$a = $registry->listApps(array('inactive', 'hidden', 'notoolbar', 'active', 'admin'));
+$a = $registry->listAllApps();
 $apps = array();
 $i = -1;
 if (file_exists(HORDE_BASE . '/lib/bundle.php')) {