Преглед изворни кода

Protect against a non-existent "MapContextParams" function

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1886 a333f486-631f-4898-b8df-5754b55c2be0
dflaven пре 13 година
родитељ
комит
6b942d23d7
2 измењених фајлова са 17 додато и 14 уклоњено
  1. 8 8
      application/applicationcontext.class.inc.php
  2. 9 6
      application/displayblock.class.inc.php

+ 8 - 8
application/applicationcontext.class.inc.php

@@ -221,17 +221,17 @@ class ApplicationContext
 			if (is_callable($aCallSpec))
 			{
 				$sAttCode = call_user_func($aCallSpec, $key); // Returns null when there is no mapping for this parameter					
-			}
 
-			if (MetaModel::IsValidAttCode($sClass, $sAttCode))
-			{
-				$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
-				if ($oAttDef->IsWritable())
+				if (MetaModel::IsValidAttCode($sClass, $sAttCode))
 				{
-					$value = $this->GetCurrentValue($key, null);
-					if (!is_null($value))
+					$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
+					if ($oAttDef->IsWritable())
 					{
-						$oObj->Set($sAttCode, $value);
+						$value = $this->GetCurrentValue($key, null);
+						if (!is_null($value))
+						{
+							$oObj->Set($sAttCode, $value);
+						}
 					}
 				}
 			}

+ 9 - 6
application/displayblock.class.inc.php

@@ -281,15 +281,18 @@ class DisplayBlock
 				$sClass = $this->m_oFilter->GetClass();
 				$aFilterCodes = array_keys(MetaModel::GetClassFilterDefs($sClass));
 				$aCallSpec = array($sClass, 'MapContextParam');
-				foreach($oAppContext->GetNames() as $sContextParam)
+				if (is_callable($aCallSpec))
 				{
-					$sParamCode = call_user_func($aCallSpec, $sContextParam); //Map context parameter to the value/filter code depending on the class
-					if (!is_null($sParamCode))
+					foreach($oAppContext->GetNames() as $sContextParam)
 					{
-						$sParamValue = $oAppContext->GetCurrentValue($sContextParam, null);
-						if (!is_null($sParamValue))
+						$sParamCode = call_user_func($aCallSpec, $sContextParam); //Map context parameter to the value/filter code depending on the class
+						if (!is_null($sParamCode))
 						{
-							$aExtraParams[$sParamCode] = $sParamValue;
+							$sParamValue = $oAppContext->GetCurrentValue($sContextParam, null);
+							if (!is_null($sParamValue))
+							{
+								$aExtraParams[$sParamCode] = $sParamValue;
+							}
 						}
 					}
 				}