/** * Read the context directly in the PHP parameters (either POST or GET) * return nothing */ protected function ReadContext() { if (!isset(self::$aDefaultValues)) { self::$aDefaultValues = array(); $aContext = utils::ReadParam('c', array(), false, 'context_param'); foreach ($this->aNames as $sName) { $sValue = isset($aContext[$sName]) ? $aContext[$sName] : ''; // TO DO: check if some of the context parameters are mandatory (or have default values) if (!empty($sValue)) { self::$aDefaultValues[$sName] = $sValue; } // 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 if ($sName == 'org_id') { if (MetaModel::IsValidClass('Organization')) { $oSearchFilter = new DBObjectSearch('Organization'); $oSearchFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', true); $oSet = new CMDBObjectSet($oSearchFilter); $iCount = $oSet->Count(); if ($iCount == 1) { // Only one possible value for org_id, set it in the context $oOrg = $oSet->Fetch(); self::$aDefaultValues[$sName] = $oOrg->GetKey(); } } } } } $this->aValues = self::$aDefaultValues; }