Revert "Do app pushing entirely within Registry."
authorMichael M Slusarz <slusarz@curecanti.org>
Sun, 11 Apr 2010 18:42:48 +0000 (12:42 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Sun, 11 Apr 2010 18:44:38 +0000 (12:44 -0600)
This partially reverts commit 9fc391d83bad2e00b3a72c48e70d169362a5f54f.

framework/Core/lib/Horde/Registry.php
horde/lib/Api.php

index b1a9973..2b09d1f 100644 (file)
@@ -1234,16 +1234,17 @@ class Horde_Registry
     /**
      * Loads the preferences for the current user for the current application
      * and imports them into the global $prefs variable.
+     * $app will be the active application after calling this function.
      *
      * @param string $app  The name of the application.
+     * @throws Horde_Exception
      */
     public function loadPrefs($app = null)
     {
         if (is_null($app)) {
             $app = $this->getApp();
-            $pushed = false;
         } else {
-            $pushed = $this->pushApp($app);
+            $this->pushApp($app);
         }
 
         /* If there is no logged in user, return an empty Horde_Prefs::
@@ -1258,10 +1259,6 @@ class Horde_Registry
                 $GLOBALS['prefs']->retrieve($app);
             }
         }
-
-        if ($pushed) {
-            $this->popApp();
-        }
     }
 
     /**
index 7e3ab5d..0204a41 100644 (file)
@@ -155,8 +155,14 @@ class Horde_Api extends Horde_Registry_Api
      */
     public function getPreference($app, $pref)
     {
+        $pushed = $GLOBALS['registry']->pushApp($app);
         $GLOBALS['registry']->loadPrefs($app);
-        return $GLOBALS['prefs']->getValue($pref);
+        $value = $GLOBALS['prefs']->getValue($pref);
+        if ($pushed) {
+            $GLOBALS['registry']->popApp();
+        }
+
+        return $value;
     }
 
     /**
@@ -169,8 +175,12 @@ class Horde_Api extends Horde_Registry_Api
      */
     public function setPreference($app, $pref, $value)
     {
+        $pushed = $GLOBALS['registry']->pushApp($app);
         $GLOBALS['registry']->loadPrefs($app);
-        return $GLOBALS['prefs']->setValue($pref, $value);
+        $value = $GLOBALS['prefs']->setValue($pref, $value);
+        if ($pushed) {
+            $GLOBALS['registry']->popApp();
+        }
     }
 
     /**