Skip to content

Commit

Permalink
refactor(formanswer): optimize target visibility computation
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed May 7, 2020
1 parent 71cddf3 commit 9a511cd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,17 +936,18 @@ public function generateTarget() {

$CFG_GLPI['plugin_formcreator_disable_hook_create_ticket'] = '1';

// get all fields to compute visibility of targets
$this->questionFields = $form->getFields();
$answers_values = $this->getAnswers($this->getID());
foreach ($this->questionFields as $id => $field) {
$this->questionFields[$id]->deserializeValue($answers_values['formcreator_field_' . $id]);
}

// Generate targets
$generatedTargets = new PluginFormcreatorComposite(new PluginFormcreatorItem_TargetTicket(), new Ticket_Ticket());
foreach ($all_targets as $targetType => $targets) {
foreach ($targets as $targetObject) {
// Check the condition of the target
$this->questionFields = $form->getFields();
$answers_values = $this->getAnswers($this->getID());
foreach ($this->questionFields as $id => $field) {
$this->questionFields[$id]->deserializeValue($answers_values['formcreator_field_' . $id]);
}

if (!PluginFormcreatorFields::isVisible($targetObject, $this->questionFields)) {
// The target shall not be generated
continue;
Expand Down

0 comments on commit 9a511cd

Please sign in to comment.