Quellcode durchsuchen

- Fixed bug (Trac #49) display of user's grant matrix not refreshed properly. Actually it was not a display issue but the cache was not flushed at the right time and the flush was just loading more entries in the cache without clearing the current ones.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@219 a333f486-631f-4898-b8df-5754b55c2be0
dflaven vor 15 Jahren
Ursprung
Commit
3b30baf550
1 geänderte Dateien mit 27 neuen und 6 gelöschten Zeilen
  1. 27 6
      addons/userrights/userrightsprofile.class.inc.php

+ 27 - 6
addons/userrights/userrightsprofile.class.inc.php

@@ -18,6 +18,25 @@ define('ADMIN_PROFILE_ID', 1);
 
 class UserRightsBaseClass extends cmdbAbstractObject
 {
+	// Whenever something changes, reload the privileges
+	
+	public function DBInsertTracked(CMDBChange $oChange)
+	{
+		parent::DBInsertTracked($oChange);
+		UserRights::FlushPrivileges();
+	}
+
+	public function DBUpdateTracked(CMDBChange $oChange)
+	{
+		parent::DBUpdateTracked($oChange);
+		UserRights::FlushPrivileges();
+	}
+
+	public function DBDeleteTracked(CMDBChange $oChange)
+	{
+		parent::DBDeleteTracked($oChange);
+		UserRights::FlushPrivileges();
+	}
 }
 
 
@@ -131,9 +150,6 @@ class URP_Users extends UserRightsBaseClass
 
 	function DisplayBareRelations(web_page $oPage)
 	{
-		// We may have just added a user, then we have to reset any existing cache
-		UserRights::FlushPrivileges();
-
 		parent::DisplayBareRelations($oPage);
 
 		$oPage->SetCurrentTabContainer('Related Objects');
@@ -258,9 +274,6 @@ class URP_Profiles extends UserRightsBaseClass
 
 	function DisplayBareRelations(web_page $oPage)
 	{
-		// We may have just added a user, then we have to reset any existing cache
-		UserRights::FlushPrivileges();
-
 		parent::DisplayBareRelations($oPage);
 
 		$oPage->SetCurrentTabContainer('Related Objects');
@@ -851,6 +864,8 @@ class UserRightsProfile extends UserRightsAddOnAPI
 		// Could be loaded in a shared memory (?)
 
 		$oUserSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Users"));
+		$this->m_aUsers = array();
+		$this->m_aLogin2UserId = array();  
 		while ($oUser = $oUserSet->Fetch())
 		{
 			$this->m_aUsers[$oUser->GetKey()] = $oUser;
@@ -858,24 +873,29 @@ class UserRightsProfile extends UserRightsAddOnAPI
 		}
 
 		$oDimensionSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Dimensions"));
+		$this->m_aDimensions = array(); 
 		while ($oDimension = $oDimensionSet->Fetch())
 		{
 			$this->m_aDimensions[$oDimension->GetKey()] = $oDimension; 
 		}
 		
 		$oClassProjSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ClassProjection"));
+		$this->m_aClassProjs = array(); 
 		while ($oClassProj = $oClassProjSet->Fetch())
 		{
 			$this->m_aClassProjs[$oClassProj->Get('class')][$oClassProj->Get('dimensionid')] = $oClassProj; 
 		}
 
 		$oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Profiles"));
+		$this->m_aProfiles = array(); 
 		while ($oProfile = $oProfileSet->Fetch())
 		{
 			$this->m_aProfiles[$oProfile->GetKey()] = $oProfile; 
 		}
 
 		$oUserProfileSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_UserProfile"));
+		$this->m_aUserProfiles = array();
+		$this->m_aAdmins = array();
 		while ($oUserProfile = $oUserProfileSet->Fetch())
 		{
 			$this->m_aUserProfiles[$oUserProfile->Get('userid')][$oUserProfile->Get('profileid')] = $oUserProfile;
@@ -886,6 +906,7 @@ class UserRightsProfile extends UserRightsAddOnAPI
 		}
 
 		$oProProSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ProfileProjection"));
+		$this->m_aProPros = array(); 
 		while ($oProPro = $oProProSet->Fetch())
 		{
 			$this->m_aProPros[$oProPro->Get('profileid')][$oProPro->Get('dimensionid')] = $oProPro;