diff --git a/application/ajaxwebpage.class.inc.php b/application/ajaxwebpage.class.inc.php index fb0b59cdd..1ccb602dd 100644 --- a/application/ajaxwebpage.class.inc.php +++ b/application/ajaxwebpage.class.inc.php @@ -193,7 +193,7 @@ EOF if (!empty($this->s_deferred_content)) { echo "\n"; } if (!empty($this->m_sReadyScript)) @@ -229,6 +229,20 @@ EOF parent::add($sHtml); } } + + /** + * Add any text or HTML fragment (identified by an ID) at the end of the body of the page + * This is useful to add hidden content, DIVs or FORMs that should not + * be embedded into each other. + */ + public function add_at_the_end($s_html, $sId = '') + { + if ($sId != '') + { + $this->add_script("$('#{$sId}').remove();"); // Remove any previous instance of the same Id + } + $this->s_deferred_content .= $s_html; + } /** * Adds a script to be executed when the DOM is ready (typical JQuery use) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 275db41dd..7ebb499b8 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -214,7 +214,8 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay { if ($oAttDef instanceof AttributeCaseLog) { - $this->DisplayCaseLog($oPage, $sAttCode, '', '', $bEditMode); + $sComment = (isset($aExtraParams['fieldsComments'][$sAttCode])) ? $aExtraParams['fieldsComments'][$sAttCode] : ''; + $this->DisplayCaseLog($oPage, $sAttCode, $sComment, $sPrefix, $bEditMode); } } @@ -253,7 +254,14 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay $oPage->SetCurrentTab($oAttDef->GetLabel().$sCount); if ($bEditMode) { - $iFlags = $this->GetAttributeFlags($sAttCode); + if ($this->IsNew()) + { + $iFlags = $this->GetInitialStateAttributeFlags($sAttCode); + } + else + { + $iFlags = $this->GetAttributeFlags($sAttCode); + } $sInputId = $this->m_iFormId.'_'.$sAttCode; if (get_class($oAttDef) == 'AttributeLinkedSet') { @@ -448,7 +456,18 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay $sComments = isset($aFieldsComments[$sAttCode]) ? $aFieldsComments[$sAttCode] : ' '; $sInfos = ' '; - $iFlags = $this->GetAttributeFlags($sAttCode); + if ($this->IsNew()) + { + $iFlags = $this->GetInitialStateAttributeFlags($sAttCode); + } + else + { + $iFlags = $this->GetAttributeFlags($sAttCode); + } + if (($iFlags & OPT_ATT_MANDATORY) && $this->IsNew()) + { + $iFlags = $iFlags & ~OPT_ATT_READONLY; // Mandatory fields cannot be read-only when creating an object + } $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); if ( (!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0)) { @@ -1728,8 +1747,9 @@ EOF } $aTransitions = $this->EnumTransitions(); - if (count($aTransitions)) + if (!isset($aExtraParams['custom_operation']) && count($aTransitions)) { + // transitions are displayed only for the standard new/modify actions, not for modify_all or any other case... $oSetToCheckRights = DBObjectSet::FromObject($this); $aStimuli = Metamodel::EnumStimuli($sClass); foreach($aTransitions as $sStimulusCode => $aTransitionDef) @@ -1748,9 +1768,31 @@ EOF } $sButtonsPosition = MetaModel::GetConfig()->Get('buttons_position'); - $iTransactionId = utils::GetNewTransactionId(); + $iTransactionId = isset($aExtraParams['transaction_id']) ? $aExtraParams['transaction_id'] : utils::GetNewTransactionId(); $oPage->SetTransactionId($iTransactionId); $oPage->add("