diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index ee5f5ae88..8d412b04d 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -117,7 +117,7 @@ class UIExtKeyWidget $sAttrFieldPrefix = ($this->bSearchMode) ? '' : 'attr_'; $sHTMLValue = "
"; - $sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL(true)); + $sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL()); if($this->bSearchMode) { $sWizHelper = 'null'; @@ -382,7 +382,11 @@ EOF $oFilter->ChangeClass($sRemoteClass); } $oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode); - $oBlock = new DisplayBlock($oFilter, 'list', false, array('query_params' => array('this' => $oObj))); + + // Current extkey value, so we can display event if it is not available anymore (eg. archived). + $iCurrentExtKeyId = (is_null($oObj)) ? 0 : $oObj->Get($this->sAttCode); + + $oBlock = new DisplayBlock($oFilter, 'list', false, array('query_params' => array('this' => $oObj, 'current_extkey_id' => $iCurrentExtKeyId))); $oBlock->Display($oP, $this->iId.'_results', array('this' => $oObj, 'cssCount'=> '#count_'.$this->iId, 'menu' => false, 'selection_mode' => true, 'selection_type' => 'single', 'table_id' => 'select_'.$this->sAttCode)); // Don't display the 'Actions' menu on the results } @@ -399,9 +403,13 @@ EOF { throw new Exception('Implementation: null value for allowed values definition'); } + + // Current extkey value, so we can display event if it is not available anymore (eg. archived). + $iCurrentExtKeyId = (is_null($oObj) || $this->sAttCode === '') ? 0 : $oObj->Get($this->sAttCode); + $oValuesSet = new ValueSetObjects($sFilter, 'friendlyname'); // Bypass GetName() to avoid the encoding by htmlentities $oValuesSet->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode); - $aValues = $oValuesSet->GetValues(array('this' => $oObj), $sContains); + $aValues = $oValuesSet->GetValues(array('this' => $oObj, 'current_extkey_id' => $iCurrentExtKeyId), $sContains); foreach($aValues as $sKey => $sFriendlyName) { $oP->add(trim($sFriendlyName)."\t".$sKey."\n"); @@ -536,9 +544,9 @@ EOF } try { - $oFilter = DBObjectSearch::FromOQL($sFilter); + $oFilter = DBObjectSearch::FromOQL($sFilter); $oFilter->SetModifierProperty('UserRightsGetSelectFilter', 'bSearchMode', $this->bSearchMode); - $oSet = new DBObjectSet($oFilter, array(), array('this' => $oObj)); + $oSet = new DBObjectSet($oFilter, array(), array('this' => $oObj, 'current_extkey_id' => $currValue)); } catch(MissingQueryArgument $e) { @@ -653,4 +661,3 @@ EOF } } -?> diff --git a/core/valuesetdef.class.inc.php b/core/valuesetdef.class.inc.php index 97ce58cac..e9846f77d 100644 --- a/core/valuesetdef.class.inc.php +++ b/core/valuesetdef.class.inc.php @@ -148,9 +148,15 @@ class ValueSetObjects extends ValueSetDefinition if ($iAdditionalValue > 0) { $oSearchAdditionalValue = new DBObjectSearch($oFilter->GetClass()); - $oSearchAdditionalValue->AddCondition('id', $iAdditionalValue); + $oSearchAdditionalValue->AddConditionExpression( new BinaryExpression( + new FieldExpression('id', $oSearchAdditionalValue->GetClassAlias()), + '=', + new VariableExpression('current_extkey_id')) + ); $oSearchAdditionalValue->AllowAllData(); $oSearchAdditionalValue->SetArchiveMode(true); + $oSearchAdditionalValue->SetInternalParams( array('current_extkey_id' => $iAdditionalValue) ); + $oFilter = new DBUnionSearch(array($oFilter, $oSearchAdditionalValue)); }