new method preferences->default_prefs($app=null,$name=null) to access default prefs, taking into account forced preferences

This commit is contained in:
Ralf Becker 2012-03-01 18:03:13 +00:00
parent 3fdf5fdfd0
commit 1c386e2d6b
2 changed files with 21 additions and 2 deletions

View File

@ -623,8 +623,8 @@ abstract class bo_tracking
}
else
{
// for the notification copy, we use the default-prefs plus the language from the the tracker config
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->default;
// for the notification copy, we use default (and forced) prefs plus the language from the the tracker config
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->default_prefs();
$GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $user_or_lang;
}
if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != translation::$userlang) // load the right language if needed

View File

@ -396,6 +396,25 @@ class preferences
return $this->data;
}
/**
* Get default preferences (also taking forced preferences into account!)
*
* @param string $app=null
* @param string $name=null
* @return mixed
*/
function default_prefs($app=null,$name=null)
{
// boetemplate::complete_array_merge() is identical to PHP >= 5.3 array_replace_recursive()
$default = boetemplate::complete_array_merge($this->default, $this->forced);
if ($app) $default = $default[$app];
if ($name && is_array($default)) $default = $default[$name];
return $default;
}
/**
* Checking new timezone ('tz') pref and setting old tz_offset pref from it
*