/**
* 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::
$GLOBALS['prefs']->retrieve($app);
}
}
-
- if ($pushed) {
- $this->popApp();
- }
}
/**
*/
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;
}
/**
*/
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();
+ }
}
/**