diff --git a/lib/installer.php b/lib/installer.php index b0175b07c4..5959153bca 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -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); @@ -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; @@ -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 @@ -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(