From bfadbc4098ae8865fd4276ae0883ad8df9d63c60 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Fri, 19 Feb 2016 12:30:19 +0000 Subject: [PATCH] Prerequisites for custom fields SVN:trunk[3918] --- addons/userrights/userrightsprofile.class.inc.php | 1 + core/dbsearch.class.php | 8 +++++--- core/metamodel.class.php | 4 ++-- pages/run_query.php | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index e05c88d1c..a7e87d19c 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -503,6 +503,7 @@ class UserRightsProfile extends UserRightsAddOnAPI $aRet = array(); $oSearch = new DBObjectSearch('URP_UserProfile'); $oSearch->AllowAllData(); + $oSearch->NoContextParameters(); $oSearch->Addcondition('userid', $oUser->GetKey(), '='); $oProfiles = new DBObjectSet($oSearch); while ($oUserProfile = $oProfiles->Fetch()) diff --git a/core/dbsearch.class.php b/core/dbsearch.class.php index df149dc47..e325fbeb8 100644 --- a/core/dbsearch.class.php +++ b/core/dbsearch.class.php @@ -40,6 +40,7 @@ require_once('dbunionsearch.class.php'); abstract class DBSearch { protected $m_bDataFiltered = false; + protected $m_bNoContextParameters = false; protected $m_aModifierProperties = array(); // By default, some information may be hidden to the current user @@ -60,6 +61,8 @@ abstract class DBSearch public function AllowAllData() {$this->m_bAllowAllData = true;} public function IsAllDataAllowed() {return $this->m_bAllowAllData;} + public function NoContextParameters() {$this->m_bNoContextParameters = true;} + public function HasContextParameters() {return $this->m_bNoContextParameters;} public function IsDataFiltered() {return $this->m_bDataFiltered; } public function SetDataFiltered() {$this->m_bDataFiltered = true;} @@ -354,13 +357,12 @@ abstract class DBSearch * @param int $iLimitCount * @param int $iLimitStart * @param bool $bGetCount - * @param bool $bNoArguments * @return string * @throws CoreException * @throws Exception * @throws MissingQueryArgument */ - public function MakeSelectQuery($aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 0, $iLimitStart = 0, $bGetCount = false, $bNoArguments = false) + public function MakeSelectQuery($aOrderBy = array(), $aArgs = array(), $aAttToLoad = null, $aExtendedDataSpec = null, $iLimitCount = 0, $iLimitStart = 0, $bGetCount = false) { // Check the order by specification, and prefix with the class alias // and make sure that the ordering columns are going to be selected @@ -413,7 +415,7 @@ abstract class DBSearch $oSQLQuery = $this->GetSQLQuery($aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount); - if ($bNoArguments) + if ($this->m_bNoContextParameters) { // Only internal parameters $aScalarArgs = $this->GetInternalParams(); diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 4006fa0ec..a4b63de73 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -4485,8 +4485,8 @@ abstract class MetaModel { $oFilter->AllowAllData(); } - - $sSQL = $oFilter->MakeSelectQuery(array(), array(), null, null, 0, 0, false, true); // bNoMagicArguments = true + $oFilter->NoContextParameters(); + $sSQL = $oFilter->MakeSelectQuery(); self::$aQueryCacheGetObject[$sQuerySign] = $sSQL; self::$aQueryCacheGetObjectHits[$sQuerySign] = 0; } diff --git a/pages/run_query.php b/pages/run_query.php index babc4d728..ab6bb59b6 100644 --- a/pages/run_query.php +++ b/pages/run_query.php @@ -162,7 +162,7 @@ try foreach($oFilter->GetQueryParams() as $sParam => $foo) { // Skip magic parameters - $iPos = strpos($sArgName, '->'); + $iPos = strpos($sParam, '->'); if ($iPos === false) { $sRefName = $sParam;