From 4690d4f9013e47e4dc9030b73960ff781bfb2c91 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Thu, 16 Sep 2010 13:25:09 +0000 Subject: [PATCH] #272 Could not delete a user account SVN:trunk[883] --- application/user.preferences.class.inc.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/application/user.preferences.class.inc.php b/application/user.preferences.class.inc.php index 5c922fb42..ee0f2ff4d 100644 --- a/application/user.preferences.class.inc.php +++ b/application/user.preferences.class.inc.php @@ -134,7 +134,14 @@ class appUserPreferences extends DBObject $oObj = new appUserPreferences(); $oObj->Set('userid', UserRights::GetUserId()); $oObj->Set('preferences', array()); // Default preferences: an empty array - $oObj->DBInsert(); + try + { + $oObj->DBInsert(); + } + catch(Exception $e) + { + // Ignore errors + } } self::$oUserPrefs = $oObj; } @@ -154,9 +161,17 @@ class appUserPreferences extends DBObject ); MetaModel::Init_Params($aParams); - MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"User", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeExternalKey("userid", array("targetclass"=>"User", "allowed_values"=>null, "sql"=>"userid", "is_null_allowed"=>false, "on_target_delete"=>DEL_AUTO, "depends_on"=>array()))); MetaModel::Init_AddAttribute(new AttributePropertySet("preferences", array("allowed_values"=>null, "sql"=>"preferences", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array()))); } - + + /** + * Overloading this function here to secure a fix done right before the release + * The real fix should be to implement this verb in DBObject + */ + public function DBDeleteTracked(CMDBChange $oChange, $bSkipStrongSecurity = null) + { + $this->DBDelete(); + } } ?>