瀏覽代碼

Finalized module userrightsprofile

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@685 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 年之前
父節點
當前提交
45543c159e
共有 2 個文件被更改,包括 15 次插入6 次删除
  1. 14 5
      addons/userrights/userrightsprofile.class.inc.php
  2. 1 1
      core/valuesetdef.class.inc.php

+ 14 - 5
addons/userrights/userrightsprofile.class.inc.php

@@ -350,8 +350,16 @@ class URP_ProfileProjection extends UserRightsBaseClass
 		MetaModel::Init_SetZListItems('advanced_search', array('dimensionid', 'profileid')); // Criteria of the advanced search form
 		MetaModel::Init_SetZListItems('advanced_search', array('dimensionid', 'profileid')); // Criteria of the advanced search form
 	}
 	}
 
 
+	protected $m_aUserProjections; // cache
+
 	public function ProjectUser(User $oUser)
 	public function ProjectUser(User $oUser)
 	{
 	{
+		if (is_array($this->m_aUserProjections))
+		{
+			// Hit!
+			return $this->m_aUserProjections;
+		}
+
 		$sExpr = $this->Get('value');
 		$sExpr = $this->Get('value');
 		if ($sExpr == '<user>')
 		if ($sExpr == '<user>')
 		{
 		{
@@ -371,7 +379,7 @@ class URP_ProfileProjection extends UserRightsBaseClass
 			$aRes = null;
 			$aRes = null;
 		}
 		}
 		elseif (strtolower(substr($sExpr, 0, 6)) == 'select')
 		elseif (strtolower(substr($sExpr, 0, 6)) == 'select')
-		{ 
+		{
 			$sColumn = $this->Get('attribute');
 			$sColumn = $this->Get('attribute');
 			// SELECT...
 			// SELECT...
 			$oValueSetDef = new ValueSetObjects($sExpr, $sColumn, array(), true /*allow all data*/);
 			$oValueSetDef = new ValueSetObjects($sExpr, $sColumn, array(), true /*allow all data*/);
@@ -382,6 +390,7 @@ class URP_ProfileProjection extends UserRightsBaseClass
 			// Constant value(s)
 			// Constant value(s)
 			$aRes = explode(';', trim($sExpr));
 			$aRes = explode(';', trim($sExpr));
 		}
 		}
+		$this->m_aUserProjections = $aRes;
 		return $aRes;
 		return $aRes;
 	}
 	}
 }
 }
@@ -1093,7 +1102,7 @@ exit;
 			foreach ($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
 			foreach ($this->m_aUserProfiles[$iUser] as $iProfile => $oProfile)
 			{
 			{
 				// user projection to be cached on a given page !
 				// user projection to be cached on a given page !
-				if (!array_key_exists($iDimension, $this->m_aProPros[$iProfile]))
+				if (!isset($this->m_aProPros[$iProfile][$iDimension]))
 				{
 				{
 					// No projection for a given profile: default to 'any'
 					// No projection for a given profile: default to 'any'
 					return null;
 					return null;
@@ -1105,7 +1114,7 @@ exit;
 					// No projection for a given profile: default to 'any'
 					// No projection for a given profile: default to 'any'
 					return null;
 					return null;
 				}
 				}
-				$aRes = array_merge($aRes, $aUserProjection);
+				$aRes = array_unique(array_merge($aRes, $aUserProjection));
 			}
 			}
 		}
 		}
 		return $aRes;
 		return $aRes;
@@ -1122,7 +1131,7 @@ exit;
 		$iPKey = $oObject->GetKey();
 		$iPKey = $oObject->GetKey();
 		$iDimension = $oDimension->GetKey();
 		$iDimension = $oDimension->GetKey();
 
 
-		if (array_key_exists($iDimension, $this->m_aClassProjs[$sClass]))
+		if (isset($this->m_aClassProjs[$sClass][$iDimension]))
 		{
 		{
 			$aObjectProjection = $this->m_aClassProjs[$sClass][$iDimension]->ProjectObject($oObject);
 			$aObjectProjection = $this->m_aClassProjs[$sClass][$iDimension]->ProjectObject($oObject);
 		}
 		}
@@ -1144,7 +1153,7 @@ exit;
 				else
 				else
 				{
 				{
 					// user projection to be cached on a given page !
 					// user projection to be cached on a given page !
-					if (array_key_exists($iDimension, $this->m_aProPros[$iProfile]))
+					if (isset($this->m_aProPros[$iProfile][$iDimension]))
 					{
 					{
 						$aUserProjection = $this->m_aProPros[$iProfile][$iDimension]->ProjectUser($oUser);
 						$aUserProjection = $this->m_aProPros[$iProfile][$iDimension]->ProjectUser($oUser);
 					}
 					}

+ 1 - 1
core/valuesetdef.class.inc.php

@@ -126,7 +126,7 @@ class ValueSetObjects extends ValueSetDefinition
 			}
 			}
 			else
 			else
 			{
 			{
-				$this->m_aValues[$oObject->GetKey()] = $oObject->GetAsHTML($this->m_sValueAttCode);
+				$this->m_aValues[$oObject->GetKey()] = $oObject->Get($this->m_sValueAttCode);
 			}
 			}
 		}
 		}
 		return true;
 		return true;