瀏覽代碼

Bug fix: allow modifying an object as if in target state, before applying the stimulus (cf PortalWebpage).

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1506 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 年之前
父節點
當前提交
36b4fc2d4c
共有 1 個文件被更改,包括 12 次插入3 次删除
  1. 12 3
      core/dbobject.class.php

+ 12 - 3
core/dbobject.class.php

@@ -662,16 +662,25 @@ abstract class DBObject
 	/**
 	 * Returns the set of flags (OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY...)
 	 * for the given attribute in the current state of the object
-	 * @param string $sAttCode The code of the attribute
+	 * @param $sAttCode string $sAttCode The code of the attribute
+	 * @param $aReasons array To store the reasons why the attribute is read-only (info about the synchro replicas)
+	 * @param $sTargetState string The target state in which to evalutate the flags, if empty the current state will be used
 	 * @return integer Flags: the binary combination of the flags applicable to this attribute
 	 */	 	  	 	
-	public function GetAttributeFlags($sAttCode, &$aReasons = array())
+	public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
 	{
 		$iFlags = 0; // By default (if no life cycle) no flag at all
 		$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
 		if (!empty($sStateAttCode))
 		{
-			$iFlags = MetaModel::GetAttributeFlags(get_class($this), $this->Get($sStateAttCode), $sAttCode);
+			if ($sTargetState != '')
+			{
+				$iFlags = MetaModel::GetAttributeFlags(get_class($this), $sTargetState, $sAttCode);			
+			}
+			else
+			{
+				$iFlags = MetaModel::GetAttributeFlags(get_class($this), $this->Get($sStateAttCode), $sAttCode);
+			}
 		}
 		$aReasons = array();
 		$iSynchroFlags = $this->GetSynchroReplicaFlags($sAttCode, $aReasons);