Skip to content

Commit

Permalink
QA: #5583 - Rework default process a little
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Nov 24, 2023
1 parent e605700 commit 28c70c9
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions lib/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3172,7 +3172,9 @@ private function install() {
Installer::disableInvalidPlugins();
}

log_install_always('', __('Finished %s Process for v%s', $which, CACTI_VERSION_FULL));
$this->setDefaultTemplate();

log_install_always('', __('Finished %s Process for v%s', $which, CACTI_VERSION));

set_config_option('install_error', $failure);

Expand All @@ -3199,6 +3201,27 @@ private function install() {
}
}

private function setDefaultTemplate() {
if (read_config_option('default_template', true) == '') {
$default_set = false;

foreach($this->defaultAutomation as $item) {
$host_template_id = db_fetch_cell_prepared('SELECT id
FROM host_template
WHERE hash = ?',
array($item['hash']));

if (!empty($host_template_id)) {
log_install_always('', __('Setting the Default Device Template to \'%s\'', $item['name']));

set_config_option('default_template', $host_template_id);

break;
}
}
}
}

private function installTemplate() {
global $config;

Expand Down Expand Up @@ -3243,11 +3266,6 @@ private function installTemplate() {
// Repair automation rules if broken
repair_automation();

$default_set = false;
if (read_config_option('default_template') != '') {
$default_set = true;
}

foreach($this->defaultAutomation as $item) {
$host_template_id = db_fetch_cell_prepared('SELECT id
FROM host_template
Expand All @@ -3256,13 +3274,6 @@ private function installTemplate() {
);

if (!empty($host_template_id)) {
if (!$default_set) {
log_install_always('', __('Setting the Default Device Template to \'%s\'', $item['name']));

set_config_option('default_template', $host_template_id);
$default_set = true;
}

log_install_always('', __('Mapping Automation Template for Device Template \'%s\'', $item['name']));

$exists = db_fetch_cell_prepared(
Expand Down

0 comments on commit 28c70c9

Please sign in to comment.