Skip to content

Commit

Permalink
refactor(targetchange): code factorization
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 6, 2019
1 parent b895252 commit 75338b7
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions inc/targetchange.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,20 @@ public static function import($targetitems_id = 0, $target_data = []) {
// convert question uuid into id
$targetTicket = new PluginFormcreatorTargetTicket();
$targetTicket->getFromDB($targetitems_id);
$found_section = $DB->request([
'SELECT' => ['id'],
'FROM' => PluginFormcreatorSection::getTable(),
'WHERE' => [
'plugin_formcreator_forms_id' => $targetTicket->getForm()->getID()
],
'ORDER' => 'order ASC'
]);
$section = new PluginFormcreatorSection();
$foundSections = $section->getSectionsFromForm($targetTicket->getForm()->getID());
$tab_section = [];
foreach ($found_section as $section_item) {
$tab_section[] = $section_item['id'];
foreach ($foundSections as $section) {
$tab_section[] = $section->getID();
}

if (!empty($tab_section)) {
$sectionFk = PluginFormcreatorSection::getForeignKeyField();
$rows = $DB->request([
'SELECT' => ['id', 'uuid'],
'FROM' => PluginFormcreatorQuestion::getTable(),
'WHERE' => [
'plugin_formcreator_sections_id' => $tab_section
$sectionFk => $tab_section
],
'ORDER' => 'order ASC'
]);
Expand Down

0 comments on commit 75338b7

Please sign in to comment.