Skip to content

Commit d4ffca2

Browse files
committed
fix(condition): incomplete export
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent ca2450c commit d4ffca2

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

inc/condition.class.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
9494
throw new ImportFailureException('UUID or ID is mandatory');
9595
}
9696

97+
// restore key and FK
9798
$input['items_id'] = $containerId;
9899

99100
$item = new self();
@@ -163,6 +164,7 @@ public function export($remove_uuid = false) {
163164

164165
$condition = $this->fields;
165166

167+
// remove key and FK
166168
unset($condition['items_id']);
167169

168170
// remove ID or UUID
@@ -174,13 +176,6 @@ public function export($remove_uuid = false) {
174176
$question = new PluginFormcreatorQuestion();
175177
$question->getFromDB($condition['plugin_formcreator_questions_id']);
176178
$condition['plugin_formcreator_questions_id'] = $question->fields['uuid'];
177-
$containerType = $input['itemtype'];
178-
if (!class_exists($containerType) || !is_subclass_of($containerType, PluginFormcreatorConditionnableInterface::class)) {
179-
return false;
180-
}
181-
$container = new $containerType();
182-
$container->getFromDB($condition['items_id']);
183-
$condition['items_id'] = $container->fields['uuid'];
184179
}
185180
unset($condition[$idToRemove]);
186181

@@ -239,7 +234,7 @@ public function showConditionsForItem($form, PluginFormcreatorConditionnableInte
239234
echo '<tr">';
240235
echo '<td colspan="4">';
241236
Dropdown::showFromArray(
242-
'show_rule',
237+
'show_rule',
243238
$this->getEnumShowRule(),
244239
[
245240
'value' => $item->fields['show_rule'],

inc/question.class.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
934934
throw new ImportFailureException('UUID or ID is mandatory');
935935
}
936936

937+
// restore key and FK
937938
$sectionFk = PluginFormcreatorSection::getForeignKeyField();
938939
$input[$sectionFk] = $containerId;
940+
939941
$input['_skip_checks'] = true;
940942

941943
$item = new self();

inc/questiondependency.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
136136
throw new ImportFailureException('UUID or ID is mandatory');
137137
}
138138

139+
// restore key and FK
139140
$questionFk = PluginFormcreatorQuestion::getForeignKeyField();
140141
$input[$questionFk] = $containerId;
141142

inc/section.class.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
die("Sorry. You can't access this file directly");
3636
}
3737

38-
class PluginFormcreatorSection extends CommonDBChild implements
38+
class PluginFormcreatorSection extends CommonDBChild implements
3939
PluginFormcreatorExportableInterface,
4040
PluginFormcreatorDuplicatableInterface,
4141
PluginFormcreatorConditionnableInterface
@@ -219,8 +219,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
219219
throw new ImportFailureException('UUID or ID is mandatory');
220220
}
221221

222+
// restore key and FK
222223
$formFk = PluginFormcreatorForm::getForeignKeyField();
223224
$input[$formFk] = $containerId;
225+
224226
$input['_skip_checks'] = true;
225227

226228
$item = new self();
@@ -366,7 +368,7 @@ public function showForm($ID, $options = []) {
366368
}
367369
echo '<form name="plugin_formcreator_form" method="post" action="'.static::getFormURL().'">';
368370
echo '<table class="tab_cadre_fixe">';
369-
371+
370372
echo '<tr>';
371373
echo '<th colspan="4">';
372374
echo $title;

0 commit comments

Comments
 (0)