diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php index 7c17e32e72..624a246b4e 100644 --- a/phpgwapi/inc/class.preferences.inc.php +++ b/phpgwapi/inc/class.preferences.inc.php @@ -423,7 +423,7 @@ } $pref = &$this->$type; - if ($all = (is_string($var) && $var == '')) + if (($all = (is_string($var) && $var == ''))) { unset($pref[$app_name]); unset($this->data[$app_name]); @@ -459,6 +459,16 @@ reset ($this->data); return $this->data; } + + /** + * delete all prefs of a given user + * + * @param int $accountid + */ + function delete_user($accountid) + { + $this->delete($this->table,array('preference_owner' => $accountid),__LINE__,__FILE__); + } /** * add complex array data preference to $app_name a particular app @@ -804,7 +814,7 @@ return $this->data['email']['address']; } // if email-address is set in the account, return it - if ($email = $GLOBALS['egw']->accounts->id2name($account_id,'account_email')) + if (($email = $GLOBALS['egw']->accounts->id2name($account_id,'account_email'))) { return $email; } @@ -873,9 +883,6 @@ // at location [email][ex_accounts][X][...pref names] => pref values // make this look like "prefs[email] so the code below code below will do its job transparently - // store original prefs - $orig_prefs = array(); - $orig_prefs = $prefs; // obtain the desired sub-array of extra account prefs $sub_prefs = array(); $sub_prefs['email'] = $prefs['email']['ex_accounts'][$acctnum]; diff --git a/preferences/inc/hook_deleteaccount.inc.php b/preferences/inc/hook_deleteaccount.inc.php index feeda2d874..ad7ed9a351 100755 --- a/preferences/inc/hook_deleteaccount.inc.php +++ b/preferences/inc/hook_deleteaccount.inc.php @@ -12,13 +12,8 @@ /* $Id$ */ - // Delete all records for a user + // Delete all prefs of a user if((int)$GLOBALS['hook_values']['account_id'] > 0) { - $table_locks = Array('phpgw_preferences'); - - $GLOBALS['egw']->db->lock($table_locks); - $GLOBALS['egw']->db->query('DELETE FROM phpgw_preferences WHERE preference_owner='.(int)$GLOBALS['hook_values']['account_id'],__LINE__,__FILE__); - $GLOBALS['egw']->db->unlock(); + $GLOBALS['egw']->preferences->delete_user($GLOBALS['hook_values']['account_id']); } -?>