Skip to content

Commit cb4dceb

Browse files
committed
fix(condition): fail to import conditions
1 parent 55bf8b4 commit cb4dceb

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

inc/abstracttarget.class.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,18 @@ public function prepareInputForAdd($input) {
139139
return false;
140140
}
141141

142+
if (!$this->skipChecks) {
143+
if (!$this->checkConditionSettings($input)) {
144+
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
145+
}
146+
}
147+
142148
// generate a unique id
143149
if (!isset($input['uuid'])
144150
|| empty($input['uuid'])) {
145151
$input['uuid'] = plugin_formcreator_getUuid();
146152
}
147153

148-
if (!$this->checkConditionSettings($input)) {
149-
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
150-
}
151-
152154
return $input;
153155
}
154156

@@ -160,6 +162,10 @@ public function prepareInputForUpdate($input) {
160162
Session::addMessageAfterRedirect(__('The name cannot be empty!', 'formcreator'), false, ERROR);
161163
return [];
162164
}
165+
166+
if (!$this->checkConditionSettings($input)) {
167+
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
168+
}
163169
}
164170

165171
// generate a uniq id
@@ -168,10 +174,6 @@ public function prepareInputForUpdate($input) {
168174
$input['uuid'] = plugin_formcreator_getUuid();
169175
}
170176

171-
if (!$this->checkConditionSettings($input)) {
172-
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
173-
}
174-
175177
return $input;
176178
}
177179

inc/exportabletrait.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ public function exportChildrenObjects(array $subItems, array $export, bool $remo
8282
* @param array $input
8383
* @return void
8484
*/
85-
public function importChildrenObjects(PluginFormcreatorExportableInterface $item, PluginFormcreatorLinker $linker, array $subItems, array $input) : void {
86-
$itemId = $item->getID();
85+
public function importChildrenObjects(PluginFormcreatorExportableInterface $parent, PluginFormcreatorLinker $linker, array $subItems, array $input) : void {
86+
/** @var CommonDBTM $parent */
87+
$itemId = $parent->getID();
8788
foreach ($subItems as $key => $itemtypes) {
8889
if (!is_array($itemtypes)) {
8990
if (!isset($input[$key])) {
@@ -111,7 +112,7 @@ public function importChildrenObjects(PluginFormcreatorExportableInterface $item
111112
}
112113
// Delete all other restrictions
113114
$subItem = new $itemtype();
114-
$subItem->deleteObsoleteItems($item, $importedItems);
115+
$subItem->deleteObsoleteItems($parent, $importedItems);
115116
}
116117
}
117118
}

inc/question.class.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ private function checkBeforeSave($input) : array {
399399
public function prepareInputForAdd($input) {
400400
if (!$this->skipChecks) {
401401
$input = $this->checkBeforeSave($input);
402+
403+
if (!$this->checkConditionSettings($input)) {
404+
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
405+
}
402406
}
403407
if (count($input) === 0) {
404408
return [];
@@ -456,10 +460,6 @@ public function prepareInputForAdd($input) {
456460
$input['uuid'] = plugin_formcreator_getUuid();
457461
}
458462

459-
if (!$this->checkConditionSettings($input)) {
460-
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
461-
}
462-
463463
return $input;
464464
}
465465

@@ -478,7 +478,12 @@ public function prepareInputForUpdate($input) {
478478
if (!isset($input['plugin_formcreator_sections_id'])) {
479479
$input['plugin_formcreator_sections_id'] = $this->fields['plugin_formcreator_sections_id'];
480480
}
481+
481482
$input = $this->checkBeforeSave($input);
483+
484+
if (!$this->checkConditionSettings($input)) {
485+
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
486+
}
482487
}
483488

484489
if (!is_array($input) || count($input) == 0) {
@@ -510,10 +515,6 @@ public function prepareInputForUpdate($input) {
510515
}
511516
}
512517

513-
if (!$this->checkConditionSettings($input)) {
514-
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
515-
}
516-
517518
return $input;
518519
}
519520

0 commit comments

Comments
 (0)