diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 25fe57f3ad..eec82b1a05 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -455,7 +455,10 @@ abstract class DBObject if (($iRemote = $this->Get($sExtKeyAttCode)) && ($iRemote > 0)) // Objects in memory have negative IDs { $oExtKeyAttDef = MetaModel::GetAttributeDef(get_class($this), $sExtKeyAttCode); - $oRemote = MetaModel::GetObject($oExtKeyAttDef->GetTargetClass(), $iRemote); + // Note: "allow all data" must be enabled because the external fields are always visible + // to the current user even if this is not the case for the remote object + // This is consistent with the behavior of the lists + $oRemote = MetaModel::GetObject($oExtKeyAttDef->GetTargetClass(), $iRemote, true, true); } else { @@ -509,6 +512,9 @@ abstract class DBObject /** * Updates the value of an external field by (re)loading the object * corresponding to the external key and getting the value from it + * + * UNUSED ? + * * @param string $sAttCode Attribute code of the external field to update * @return void */ @@ -519,7 +525,10 @@ abstract class DBObject { $sTargetClass = $oAttDef->GetTargetClass(); $objkey = $this->Get($oAttDef->GetKeyAttCode()); - $oObj = MetaModel::GetObject($sTargetClass, $objkey); + // Note: "allow all data" must be enabled because the external fields are always visible + // to the current user even if this is not the case for the remote object + // This is consistent with the behavior of the lists + $oObj = MetaModel::GetObject($sTargetClass, $objkey, true, true); if (is_object($oObj)) { $value = $oObj->Get($oAttDef->GetExtAttCode()); diff --git a/portal/index.php b/portal/index.php index 94472ab2b8..f08adec32d 100644 --- a/portal/index.php +++ b/portal/index.php @@ -1,5 +1,5 @@ add("

".Dict::S('Portal:SelectService')."

\n"); $oP->add("\n"); $oSearch = DBObjectSearch::FromOQL(PORTAL_SERVICECATEGORY_QUERY); + $oSearch->AllowAllData(); // In case the user has the rights on his org only $oSet = new CMDBObjectSet($oSearch, array(), array('org_id' => $oUserOrg->GetKey())); while($oService = $oSet->Fetch()) { @@ -130,8 +131,9 @@ function SelectServiceSubCategory($oP, $oUserOrg) $iDefaultWizNext = 2; $oSearch = DBObjectSearch::FromOQL(PORTAL_SERVICE_SUBCATEGORY_QUERY); + $oSearch->AllowAllData(); // In case the user has the rights on his org only $oSet = new CMDBObjectSet($oSearch, array(), array('svc_id' => $iSvcId, 'org_id' => $oUserOrg->GetKey())); - $oServiceCategory = MetaModel::GetObject('Service', $iSvcId, false); + $oServiceCategory = MetaModel::GetObject('Service', $iSvcId, false, true /* allow all data*/); if (is_object($oServiceCategory)) { $oP->add("
\n"); @@ -202,8 +204,8 @@ EOF } } - $oServiceCategory = MetaModel::GetObject('Service', $aParameters['service_id'], false); - $oServiceSubCategory = MetaModel::GetObject('ServiceSubcategory', $aParameters['servicesubcategory_id'], false); + $oServiceCategory = MetaModel::GetObject('Service', $aParameters['service_id'], false, true /* allow all data*/); + $oServiceSubCategory = MetaModel::GetObject('ServiceSubcategory', $aParameters['servicesubcategory_id'], false, true /* allow all data*/); if (is_object($oServiceCategory) && is_object($oServiceSubCategory)) { $oRequest = new UserRequest(); @@ -310,6 +312,7 @@ function DoCreateRequest($oP, $oUserOrg) // Validate the parameters // 1) ServiceCategory $oSearch = DBObjectSearch::FromOQL(PORTAL_VALIDATE_SERVICECATEGORY_QUERY); + $oSearch->AllowAllData(); // In case the user has the rights on his org only $oSet = new CMDBObjectSet($oSearch, array(), array('id' => $aParameters['service_id'], 'org_id' => $oUserOrg->GetKey())); if ($oSet->Count() != 1) { @@ -320,6 +323,7 @@ function DoCreateRequest($oP, $oUserOrg) // 2) Service Subcategory $oSearch = DBObjectSearch::FromOQL(PORTAL_VALIDATE_SERVICESUBCATEGORY_QUERY); + $oSearch->AllowAllData(); // In case the user has the rights on his org only $oSet = new CMDBObjectSet($oSearch, array(), array('service_id' => $aParameters['service_id'], 'id' =>$aParameters['servicesubcategory_id'],'org_id' => $oUserOrg->GetKey() )); if ($oSet->Count() != 1) { @@ -355,7 +359,7 @@ function DoCreateRequest($oP, $oUserOrg) list($bRes, $aIssues) = $oRequest->CheckToWrite(); if ($bRes) { - $oRequest->DBInsert(); + $oRequest->DBInsertNoReload(); $oP->add("

".Dict::Format('UI:Title:Object_Of_Class_Created', $oRequest->GetName(), MetaModel::GetName(get_class($oRequest)))."

\n"); //DisplayObject($oP, $oRequest, $oUserOrg); @@ -935,6 +939,7 @@ catch(CoreException $e) $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError')); $oP->add("

".Dict::S('UI:FatalErrorMessage')."

\n"); $oP->error(Dict::Format('UI:Error_Details', $e->getHtmlDesc())); + //$oP->p($e->getTraceAsString()); $oP->output(); if (MetaModel::IsLogEnabledIssue()) @@ -971,6 +976,7 @@ catch(Exception $e) $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError')); $oP->add("

".Dict::S('UI:FatalErrorMessage')."

\n"); $oP->error(Dict::Format('UI:Error_Details', $e->getMessage())); + //$oP->p($e->getTraceAsString()); $oP->output(); if (MetaModel::IsLogEnabledIssue())