Skip to content

Commit

Permalink
fix(targetticket,targetchange,targetproblem): not imported template
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Feb 5, 2024
1 parent 08d3871 commit f9b9fba
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions inc/targetchange.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ public static function import(PluginFormcreatorLinker $linker, array $input = []
$input[$fieldSetting['field']] = $question->getID();
}

// Find template by name
$targetTemplateType = (new self())->getTemplateItemtypeName();
$targetTemplate = new $targetTemplateType();
$targetTemplate->getFromDBByCrit([
'name' => $input['_tickettemplate'],
]);
if ($targetTemplate->isNewItem()) {
$typeName = strtolower(self::getTypeName());
throw new ImportFailureException(sprintf(__('Failed to add or update the %1$s %2$s: It uses a non existent template ', 'formceator'), $typeName, $input['name']));
}
$input['tickettemplates_id'] = $targetTemplate->getID();

// Add or update
$originalId = $input[$idKey];
$item->skipChecks = true;
Expand Down
12 changes: 12 additions & 0 deletions inc/targetproblem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,18 @@ public static function import(PluginFormcreatorLinker $linker, array $input = []
$input[$fieldSetting['field']] = $question->getID();
}

// Find template by name
$targetTemplateType = (new self())->getTemplateItemtypeName();
$targetTemplate = new $targetTemplateType();
$targetTemplate->getFromDBByCrit([
'name' => $input['_tickettemplate'],
]);
if ($targetTemplate->isNewItem()) {
$typeName = strtolower(self::getTypeName());
throw new ImportFailureException(sprintf(__('Failed to add or update the %1$s %2$s: It uses a non existent template ', 'formceator'), $typeName, $input['name']));
}
$input['tickettemplates_id'] = $targetTemplate->getID();

// Add or update
$originalId = $input[$idKey];
$item->skipChecks = true;
Expand Down
12 changes: 12 additions & 0 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,18 @@ public static function import(PluginFormcreatorLinker $linker, array $input = []
$input[$fieldSetting['field']] = $question->getID();
}

// Find template by name
$targetTemplateType = (new self())->getTemplateItemtypeName();
$targetTemplate = new $targetTemplateType();
$targetTemplate->getFromDBByCrit([
'name' => $input['_tickettemplate'],
]);
if ($targetTemplate->isNewItem()) {
$typeName = strtolower(self::getTypeName());
throw new ImportFailureException(sprintf(__('Failed to add or update the %1$s %2$s: It uses a non existent template ', 'formceator'), $typeName, $input['name']));
}
$input['tickettemplates_id'] = $targetTemplate->getID();

// Add or update
$originalId = $input[$idKey];
$item->skipChecks = true;
Expand Down

0 comments on commit f9b9fba

Please sign in to comment.