Fixed bug: grant matrix apparently not updated (but it was) when modifying/creating a user account

SVN:trunk[706]
This commit is contained in:
Romain Quetiez
2010-08-26 17:23:31 +00:00
parent 8e018e4d54
commit 283cbeddc0
3 changed files with 112 additions and 43 deletions

View File

@@ -836,11 +836,6 @@ abstract class DBObject
return $this->m_iKey;
}
// To be optionaly overloaded
protected function OnInsert()
{
}
// Insert of record for the new object into the database
// Returns the key of the newly created object
public function DBInsertNoReload()
@@ -899,6 +894,8 @@ abstract class DBObject
$this->m_bIsInDB = true;
$this->m_bDirty = false;
$this->AfterInsert();
// Activate any existing trigger
$sClass = get_class($this);
$oSet = new DBObjectSet(new DBObjectSearch('TriggerOnObjectCreate'));
@@ -941,11 +938,6 @@ abstract class DBObject
$this->m_iKey = self::GetNextTempId(get_class($this));
}
// To be optionaly overloaded
protected function OnUpdate()
{
}
// Update a record
public function DBUpdate()
{
@@ -992,6 +984,8 @@ abstract class DBObject
$this->DBWriteLinks();
$this->m_bDirty = false;
$this->AfterUpdate();
// Reload to get the external attributes
if ($bHasANewExternalKeyValue)
{
@@ -1013,16 +1007,20 @@ abstract class DBObject
return $this->DBInsert();
}
}
// Delete a record
public function DBDelete()
{
$oFilter = new DBObjectSearch(get_class($this));
$oFilter->AddCondition('id', $this->m_iKey, '=');
$this->OnDelete();
$sSQL = MetaModel::MakeDeleteQuery($oFilter);
CMDBSource::Query($sSQL);
$this->AfterDelete();
$this->m_bIsInDB = false;
$this->m_iKey = null;
}
@@ -1106,6 +1104,35 @@ abstract class DBObject
return $aScalarArgs;
}
// To be optionaly overloaded
protected function OnInsert()
{
}
// To be optionaly overloaded
protected function AfterInsert()
{
}
// To be optionaly overloaded
protected function OnUpdate()
{
}
// To be optionaly overloaded
protected function AfterUpdate()
{
}
// To be optionaly overloaded
protected function OnDelete()
{
}
// To be optionaly overloaded
protected function AfterDelete()
{
}
// Return an empty set for the parent of all
public static function GetRelationQueries($sRelCode)

View File

@@ -164,7 +164,7 @@ abstract class User extends cmdbAbstractObject
'stimuli' => $sStimuli,
);
}
$aDisplayConfig = array();
$aDisplayConfig['class'] = array('label' => Dict::S('UI:UserManagement:Class'), 'description' => Dict::S('UI:UserManagement:Class+'));
$aDisplayConfig['read'] = array('label' => Dict::S('UI:UserManagement:Action:Read'), 'description' => Dict::S('UI:UserManagement:Action:Read+'));
@@ -274,14 +274,18 @@ class UserRights
// Installation: create the very first user
public static function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US')
{
return self::$m_oAddOn->CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage);
$bRes = self::$m_oAddOn->CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage);
self::FlushPrivileges(true /* reset admin cache */);
return $bRes;
}
// Installation (e.g: give default values for users)
public static function Setup()
{
// to be discussed...
return self::$m_oAddOn->Setup();
$bRes = self::$m_oAddOn->Setup();
self::FlushPrivileges(true /* reset admin cache */);
return $bRes;
}
protected static function IsLoggedIn()
@@ -575,6 +579,7 @@ class UserRights
return self::$m_oAddOn->IsActionAllowedOnAttribute($oUser, $sClass, $sAttCode, $iActionCode, $oInstanceSet);
}
static $m_aAdmins = array();
public static function IsAdministrator($oUser = null)
{
if (!self::CheckLogin()) return false;
@@ -583,11 +588,20 @@ class UserRights
{
$oUser = self::$m_oUser;
}
return self::$m_oAddOn->IsAdministrator($oUser);
$iUser = $oUser->GetKey();
if (!isset(self::$m_aAdmins[$iUser]))
{
self::$m_aAdmins[$iUser] = self::$m_oAddOn->IsAdministrator($oUser);
}
return self::$m_aAdmins[$iUser];
}
public static function FlushPrivileges()
public static function FlushPrivileges($bResetAdminCache = false)
{
if ($bResetAdminCache)
{
self::$m_aAdmins = array();
}
return self::$m_oAddOn->FlushPrivileges();
}