Skip to content

Commit

Permalink
fix(condition): incomplete export
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Feb 5, 2020
1 parent ca2450c commit d4ffca2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
11 changes: 3 additions & 8 deletions inc/condition.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
throw new ImportFailureException('UUID or ID is mandatory');
}

// restore key and FK
$input['items_id'] = $containerId;

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

$condition = $this->fields;

// remove key and FK
unset($condition['items_id']);

// remove ID or UUID
Expand All @@ -174,13 +176,6 @@ public function export($remove_uuid = false) {
$question = new PluginFormcreatorQuestion();
$question->getFromDB($condition['plugin_formcreator_questions_id']);
$condition['plugin_formcreator_questions_id'] = $question->fields['uuid'];
$containerType = $input['itemtype'];
if (!class_exists($containerType) || !is_subclass_of($containerType, PluginFormcreatorConditionnableInterface::class)) {
return false;
}
$container = new $containerType();
$container->getFromDB($condition['items_id']);
$condition['items_id'] = $container->fields['uuid'];
}
unset($condition[$idToRemove]);

Expand Down Expand Up @@ -239,7 +234,7 @@ public function showConditionsForItem($form, PluginFormcreatorConditionnableInte
echo '<tr">';
echo '<td colspan="4">';
Dropdown::showFromArray(
'show_rule',
'show_rule',
$this->getEnumShowRule(),
[
'value' => $item->fields['show_rule'],
Expand Down
2 changes: 2 additions & 0 deletions inc/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,10 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
throw new ImportFailureException('UUID or ID is mandatory');
}

// restore key and FK
$sectionFk = PluginFormcreatorSection::getForeignKeyField();
$input[$sectionFk] = $containerId;

$input['_skip_checks'] = true;

$item = new self();
Expand Down
1 change: 1 addition & 0 deletions inc/questiondependency.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static function import(PluginFormcreatorLinker $linker, $input = [], $con
throw new ImportFailureException('UUID or ID is mandatory');
}

// restore key and FK
$questionFk = PluginFormcreatorQuestion::getForeignKeyField();
$input[$questionFk] = $containerId;

Expand Down
6 changes: 4 additions & 2 deletions inc/section.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
die("Sorry. You can't access this file directly");
}

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

// restore key and FK
$formFk = PluginFormcreatorForm::getForeignKeyField();
$input[$formFk] = $containerId;

$input['_skip_checks'] = true;

$item = new self();
Expand Down Expand Up @@ -366,7 +368,7 @@ public function showForm($ID, $options = []) {
}
echo '<form name="plugin_formcreator_form" method="post" action="'.static::getFormURL().'">';
echo '<table class="tab_cadre_fixe">';

echo '<tr>';
echo '<th colspan="4">';
echo $title;
Expand Down

0 comments on commit d4ffca2

Please sign in to comment.