N°3629 - Activity panel: Fix case logs not saved during object creation

This commit is contained in:
Molkobain
2021-02-22 18:42:02 +01:00
parent 26bbdc1a57
commit 2bf23f0618
2 changed files with 19 additions and 14 deletions

View File

@@ -2754,9 +2754,14 @@ EOF
/**
* @param \WebPage $oPage
* @param string $sClass
* @param null $oObjectToClone
* @param \DBObject|null $oSourceObject Object to use for the creation form, can be either the class to instantiate, an object to clone or an object to use (eg. already prefilled / modeled object)
* @param array $aArgs
* @param array $aExtraParams
* @param array $aExtraParams Extra parameters depending on the context, below is a WIP attempt at documenting them:
* [
* ...
* 'keep_source_object' => true|false, // Whether the $oSourceObject should be kept or cloned. Default is true.
* ...
* ]
*
* @return mixed
* @throws \CoreException
@@ -2765,17 +2770,16 @@ EOF
* @throws \MySQLException
* @throws \MySQLHasGoneAwayException
*/
public static function DisplayCreationForm(WebPage $oPage, $sClass, $oObjectToClone = null, $aArgs = array(), $aExtraParams = array())
public static function DisplayCreationForm(WebPage $oPage, $sClass, $oSourceObject = null, $aArgs = array(), $aExtraParams = array())
{
$sClass = ($oObjectToClone == null) ? $sClass : get_class($oObjectToClone);
$sClass = ($oSourceObject == null) ? $sClass : get_class($oSourceObject);
if ($oObjectToClone == null)
{
if ($oSourceObject == null) {
$oObj = DBObject::MakeDefaultInstance($sClass);
}
else
{
$oObj = clone $oObjectToClone;
} elseif (isset($aExtraParams['keep_source_object']) && (true === isset($aExtraParams['keep_source_object']))) {
$oObj = $oSourceObject;
} else {
$oObj = clone $oSourceObject;
}
// Pre-fill the object with default values, when there is only on possible choice

View File

@@ -801,13 +801,14 @@ EOF
$oAppContext->InitObjectFromContext($oObjToClone);
// 2nd - set values from the page argument 'default'
$oObjToClone->UpdateObjectFromArg('default');
$aPrefillFormParam = array( 'user' => $_SESSION["auth_user"],
$aPrefillFormParam = array(
'user' => $_SESSION["auth_user"],
'context' => $oAppContext->GetAsHash(),
'default' => utils::ReadParam('default', array(), '', 'raw_data'),
'origin' => 'console'
'origin' => 'console',
);
// 3rd - prefill API
$oObjToClone->PrefillForm('creation_from_0',$aPrefillFormParam);
$oObjToClone->PrefillForm('creation_from_0', $aPrefillFormParam);
// Display the creation form
$sClassLabel = MetaModel::GetName($sRealClass);
@@ -817,7 +818,7 @@ EOF
// Note: some code has been duplicated to the case 'apply_new' when a data integrity issue has been found
$oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel));
$oP->SetContentLayout(PageContentFactory::MakeForObjectDetails($oObjToClone, cmdbAbstractObject::ENUM_OBJECT_MODE_CREATE));
cmdbAbstractObject::DisplayCreationForm($oP, $sRealClass, $oObjToClone, array(), array('wizard_container' => 1)); // wizard_container: Display the title above the form
cmdbAbstractObject::DisplayCreationForm($oP, $sRealClass, $oObjToClone, array(), array('wizard_container' => 1, 'keep_source_object' => true)); // wizard_container: Display the title above the form
}
else
{