* API/Preferences: fixed can NOT unset last (forced) preference of an app, also fixed not working deleting of prefs when deleting a user or group

This commit is contained in:
Ralf Becker 2014-01-23 12:37:44 +00:00
parent 87d2363235
commit 0fcae564f2

View File

@ -572,7 +572,7 @@ class preferences
{ {
if ($accountid > 0) if ($accountid > 0)
{ {
$this->delete($this->table,array('preference_owner' => $accountid),__LINE__,__FILE__); $this->db->delete($this->table,array('preference_owner' => $accountid),__LINE__,__FILE__);
} }
} }
@ -585,7 +585,7 @@ class preferences
{ {
if ($accountid < 0) if ($accountid < 0)
{ {
$this->delete($this->table,array('preference_owner' => $accountid+self::DEFAULT_ID),__LINE__,__FILE__); $this->db->delete($this->table,array('preference_owner' => $accountid+self::DEFAULT_ID),__LINE__,__FILE__);
} }
} }
@ -701,13 +701,20 @@ class preferences
if (!$GLOBALS['egw']->acl->check('session_only_preferences',1,'preferences')) if (!$GLOBALS['egw']->acl->check('session_only_preferences',1,'preferences'))
{ {
//error_log(__METHOD__."(type=$type) saved, because old_prefs[$account_id] != prefs=".array2string($prefs));
$this->db->transaction_begin(); $this->db->transaction_begin();
foreach($prefs as $app => $value) foreach($prefs as $app => $value)
{ {
if (!is_array($value)) if (!is_array($value))
{ {
continue; $this->db->delete($this->table, array(
'preference_owner' => $account_id,
'preference_app' => $app,
), __LINE__, __FILE__);
unset($prefs[$app]);
} }
else
{
$this->quote($value); // this quote-ing is for serialize, not for the db $this->quote($value); // this quote-ing is for serialize, not for the db
$this->db->insert($this->table,array( $this->db->insert($this->table,array(
@ -717,6 +724,7 @@ class preferences
'preference_app' => $app, 'preference_app' => $app,
),__LINE__,__FILE__); ),__LINE__,__FILE__);
} }
}
$this->db->transaction_commit(); $this->db->transaction_commit();
// no need to invalidate session cache, if we write the prefs to the session too // no need to invalidate session cache, if we write the prefs to the session too
@ -724,6 +732,7 @@ class preferences
$egw->preferences = $this; $egw->preferences = $this;
$_SESSION[egw_session::EGW_OBJECT_CACHE] = serialize($egw); $_SESSION[egw_session::EGW_OBJECT_CACHE] = serialize($egw);
} }
//else error_log(__METHOD__."(type=$type) NOT saved because old_prefs[$account_id] == prefs=".array2string($prefs));
$_SESSION[egw_session::EGW_INFO_CACHE]['user']['preferences'] = $GLOBALS['egw_info']['user']['preferences'] = $this->data; $_SESSION[egw_session::EGW_INFO_CACHE]['user']['preferences'] = $GLOBALS['egw_info']['user']['preferences'] = $this->data;
return $this->data; return $this->data;