From a395f5b63c2fd139f593b2b8043cb118dd9d6e90 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 21 Nov 2018 11:25:24 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B01583=20-=20No=20filter=20applied=20if=20?= =?UTF-8?q?only=20one=20org=20defined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/applicationcontext.class.inc.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/application/applicationcontext.class.inc.php b/application/applicationcontext.class.inc.php index 450746ab2..9ae18666b 100644 --- a/application/applicationcontext.class.inc.php +++ b/application/applicationcontext.class.inc.php @@ -142,20 +142,26 @@ class ApplicationContext } // Hmm, there must be a better (more generic) way to handle the case below: // When there is only one possible (allowed) organization, the context must be - // fixed to this org + // fixed to this org unless there is only one organization in the system then + // no filter is applied if ($sName == 'org_id') { if (MetaModel::IsValidClass('Organization')) { $oSearchFilter = new DBObjectSearch('Organization'); - $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true); $oSet = new CMDBObjectSet($oSearchFilter); $iCount = $oSet->CountWithLimit(2); - if ($iCount == 1) + if ($iCount > 1) { - // Only one possible value for org_id, set it in the context - $oOrg = $oSet->Fetch(); - self::$aDefaultValues[$sName] = $oOrg->GetKey(); + $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true); + $oSet = new CMDBObjectSet($oSearchFilter); + $iCount = $oSet->CountWithLimit(2); + if ($iCount == 1) + { + // Only one possible value for org_id, set it in the context + $oOrg = $oSet->Fetch(); + self::$aDefaultValues[$sName] = $oOrg->GetKey(); + } } } }