Browse Source

#272 Could not delete a user account

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@883 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 years ago
parent
commit
c56e4f45e5
1 changed files with 18 additions and 3 deletions
  1. 18 3
      application/user.preferences.class.inc.php

+ 18 - 3
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();
+	}
 }
 ?>