Solved issues in ModuleTemplates class

This commit is contained in:
Jose Gonzalez 2020-04-06 11:58:42 +02:00
parent a6ce19db66
commit a93812d1a8

View File

@ -337,8 +337,10 @@ class ModuleTemplates extends HTML
$success = false;
} else {
db_process_sql_delete('tnetwork_profile_pen', ['id_np' => $this->id_np]);
if (empty($this->pen)) {
$success = true;
} else {
$pensList = explode(',', $this->pen);
if (count($pensList) > 0) {
// Set again the new PENs associated.
foreach ($pensList as $currentPen) {
$dbResult_pen = db_process_sql_insert(
@ -355,8 +357,6 @@ class ModuleTemplates extends HTML
$success = true;
}
} else {
$success = true;
}
}
@ -379,6 +379,9 @@ class ModuleTemplates extends HTML
if ($dbResult_tnp != false) {
// Set the new id_np.
$this->id_np = $dbResult_tnp;
if (empty($this->pen)) {
$success = true;
} else {
$pensList = explode(',', $this->pen);
// Insert all of new PENs associated with this id_np.
foreach ($pensList as $currentPen) {
@ -397,6 +400,7 @@ class ModuleTemplates extends HTML
$success = true;
}
}
}
if ($success === true) {
$msg = __('Template %s successfully created', $this->name);
@ -527,8 +531,7 @@ class ModuleTemplates extends HTML
// 2 arrays. 1 with the groups, 1 with the groups by parent
$groups = [];
$groups_compound = [];
// Default group filter.
$groups_compound[0] = 'Group - All';
foreach ($result as $row) {
$groups[$row['id_sg']] = $row['name'];
}
@ -612,7 +615,7 @@ class ModuleTemplates extends HTML
'script' => 'filterGroupComponents(event);',
'class' => 'float-right',
'fields' => $groups_compound,
'nothing' => $groups_compound[$this->ncGroup],
'nothing' => 'Group - All',
'return' => true,
],
];