Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/support/2.13.0' into support/2.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Oct 5, 2023
2 parents 5c400c2 + 4eaa35f commit f1ce5c6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions front/formanswer.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
Html::helpHeader(__('Service catalog', 'formcreator'));
} else {
Html::header(
__('Form Creator', 'formcreator'),
$formanswer->fields['name'],
'',
'admin',
'PluginFormcreatorForm'
PluginFormcreatorForm::class
);
}

Expand Down
1 change: 0 additions & 1 deletion inc/abstractfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ function ($value) {
);

return $value;
return $DB->escape(json_encode($value, JSON_UNESCAPED_UNICODE));
}

public function getFieldTypeName(): string {
Expand Down
3 changes: 3 additions & 0 deletions inc/field/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ public function parseObjectProperties(
// We need english locale to search searchOptions by name
$oldLocale = $TRANSLATE->getLocale();
$TRANSLATE->setLocale("en_GB");
$_SESSION['glpilanguage'] = "en_GB";
if ($plug = isPluginItemType($itemtype)) {
Plugin::loadLang(strtolower($plug['plugin']), "en_GB");
}
Expand All @@ -900,6 +901,7 @@ public function parseObjectProperties(
if (count($searchOption) == 0) {
trigger_error("No search option found for $property", E_USER_WARNING);
$TRANSLATE->setLocale($oldLocale);
$_SESSION['glpilanguage'] = $oldLocale;
return $content;
}

Expand Down Expand Up @@ -943,6 +945,7 @@ public function parseObjectProperties(
}
// Put the old locales on succes or if an expection was thrown
$TRANSLATE->setLocale($oldLocale);
$_SESSION['glpilanguage'] = $oldLocale;
if ($plug = isPluginItemType($itemtype)) {
Plugin::loadLang(strtolower($plug['plugin']), $oldLocale);
}
Expand Down
13 changes: 9 additions & 4 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1892,15 +1892,20 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
$input[$key] = $DB->escape($input[$key]);
}

// Do not process theses fields when adding / updating forms
// They will be imported later; see the variable $subItems below
$input2 = $input;
unset($input2['users'], $input2['groups'], $input2['profiles']);

// Add or update the form
$originalId = $input[$idKey];
$item->skipChecks = true;
if ($itemId !== false) {
$input['id'] = $itemId;
$item->update($input);
$input2['id'] = $itemId;
$item->update($input2);
} else {
unset($input['id']);
$itemId = $item->add($input);
unset($input2['id']);
$itemId = $item->add($input2);
}
$item->skipChecks = false;
if ($itemId === false) {
Expand Down
6 changes: 6 additions & 0 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ public function showForm($ID, $options = []) {
. ' class="plugin_formcreator_form"'
. ' action="' . $formUrl . '"'
. ' id="plugin_formcreator_form"'
. ' data-submit-once="true"'
. '>';

$form = $this->getForm();
Expand Down Expand Up @@ -2126,6 +2127,11 @@ public function getGeneratedTargets($itemtypes = []): array {
* and the status of the ticket under process. The matrix below is subjective
* and is designed in a way to give priority to requester's action.
*
* The function traverses all generated tickets and computes a temporary status
* fron the previous temporary status and the ticket being processed.
* When all tickets are processed, the final status is known.
*
*
* Status of the ticket under process
* +----------+-- -------+---------+---------+--------+--------+
* | INCOMING | ASSIGNED | PLANNED | WAITING | SOLVED | CLOSED
Expand Down
4 changes: 3 additions & 1 deletion tests/3-unit/PluginFormcreatorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
use PluginFormcreatorTargetTicket;
use PluginFormcreatorTargetChange;
use QueuedNotification;
use PluginFormcreatorForm_Validator;
use PluginFormcreatorLinker;
use Central;
use User;
use UserEmail;
Expand Down Expand Up @@ -758,7 +760,7 @@ public function testImport() {
unset($input['uuid']);

$this->exception(
function() use($linker, $input, $testedClassName) {
function() use($testedClassName, $linker, $input) {
$testedClassName::import($linker, $input);
}
)->isInstanceOf(\GlpiPlugin\Formcreator\Exception\ImportFailureException::class)
Expand Down

0 comments on commit f1ce5c6

Please sign in to comment.