Просмотр исходного кода

#247 Missing query argument (CSV export failing, or Emailed URL not working for lists)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@758 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 лет назад
Родитель
Сommit
f5c70b7bfe
2 измененных файлов с 30 добавлено и 18 удалено
  1. 28 16
      core/dbobjectsearch.class.php
  2. 2 2
      core/valuesetdef.class.inc.php

+ 28 - 16
core/dbobjectsearch.class.php

@@ -507,19 +507,21 @@ class DBObjectSearch
 		return $this->m_oSearchCondition->Render($this->m_aParams, false);
 	}
 
-	public function serialize()
+	public function serialize($bDevelopParams = false, $aContextParams = null)
 	{
-		$sOql = $this->ToOql();
-		return base64_encode($sOql);
+		$sOql = $this->ToOql($bDevelopParams, $aContextParams);
+		return base64_encode(serialize(array($sOql, $this->m_aParams)));
 	}
 	
 	static public function unserialize($sValue)
 	{
-		$sOql = base64_decode($sValue);
+		$aData = unserialize(base64_decode($sValue));
+		$sOql = $aData[0];
+		$aParams = $aData[1];
 		// We've tried to use gzcompress/gzuncompress, but for some specific queries
 		// it was not working at all (See Trac #193)
 		// gzuncompress was issuing a warning "data error" and the return object was null
-		return self::FromOQL($sOql);
+		return self::FromOQL($sOql, $aParams);
 	}
 
 	// SImple BUt Structured Query Languag - SubuSQL
@@ -600,23 +602,28 @@ class DBObjectSearch
 		return $aRes;
 	}
 
-	public function ToOQL(&$aParams = null)
+	public function ToOQL($bDevelopParams = false, $aContextParams = null)
 	{
 		// Currently unused, but could be useful later
 		$bRetrofitParams = false;
 
-		if (is_null($aParams))
+		if ($bDevelopParams)
 		{
-			// Leave it as is, the rendering will be made with parameters in clear
+			if (is_null($aContextParams))
+			{
+				$aParams = array_merge($this->m_aParams);
+			}
+			else
+			{
+				$aParams = array_merge($aContextParams, $this->m_aParams);
+			}
 		}
 		else
 		{
-			if (count($this->m_aParams) > 0)
-			{
-				$aParams = array_merge($aParams, $this->m_aParams);
-			}
+			// Leave it as is, the rendering will be made with parameters in clear
+			$aParams = null;
 		}
-
+	
 		$sSelectedClasses = implode(', ', array_keys($this->m_aSelectedClasses));
 		$sRes = 'SELECT '.$sSelectedClasses.' FROM';
 
@@ -739,14 +746,14 @@ class DBObjectSearch
 
 	// Do not filter out depending on user rights
 	// In particular when we are currently in the process of evaluating the user rights...
-	static public function FromOQL_AllData($sQuery)
+	static public function FromOQL_AllData($sQuery, $aParams = null)
 	{
-		$oRes = self::FromOQL($sQuery);
+		$oRes = self::FromOQL($sQuery, $aParams);
 		$oRes->AllowAllData();
 		return $oRes;
 	}
 
-	static public function FromOQL($sQuery)
+	static public function FromOQL($sQuery, $aParams = null)
 	{
 		if (empty($sQuery)) return null;
 
@@ -861,6 +868,11 @@ class DBObjectSearch
 			$oResultFilter->m_oSearchCondition = $oResultFilter->OQLExpressionToCondition($sQuery, $oConditionTree, $aAliases);
 		}
 
+		if (!is_null($aParams))
+		{
+			$oResultFilter->m_aParams = $aParams;
+		}
+
 		if ($bOQLCacheEnabled)
 		{
 			self::$m_aOQLQueries[$sQuery] = clone $oResultFilter;

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

@@ -109,11 +109,11 @@ class ValueSetObjects extends ValueSetDefinition
 		
 		if ($this->m_bAllowAllData)
 		{
-			$oFilter = DBObjectSearch::FromOQL_AllData($this->m_sFilterExpr, $aArgs);
+			$oFilter = DBObjectSearch::FromOQL_AllData($this->m_sFilterExpr);
 		}
 		else
 		{
-			$oFilter = DBObjectSearch::FromOQL($this->m_sFilterExpr, $aArgs);
+			$oFilter = DBObjectSearch::FromOQL($this->m_sFilterExpr);
 		}
 		if (!$oFilter) return false;