public function deploy()
 {
     foreach ($this->destinations as $destination) {
         // set new swap_id
         $swap_id = NConf_HTML::set_swap_id('swap_deploy');
         // reset informations
         NConf_HTML::set_info('', 'reset');
         // add informations if status is FALSE
         // if there are host informations, add them
         if (!empty($destination["host"])) {
             NConf_HTML::set_info(NConf_HTML::table_row_check('Host:', '', $destination["host"]), 'add');
         }
         // call the command and get its status back
         // also catch direct output (of errors etc.) which are not intercepted in the submodule
         ob_start();
         $status = $this->command($destination);
         if (ob_get_contents()) {
             NConf_DEBUG::set(ob_get_contents(), 'ERROR', $this->name);
             NConf_HTML::set_info(NConf_HTML::table_row_check('Error/Info:', 'ERROR', 'Please have a look at the NConf error message at the bottom of the page'), 'add');
         }
         ob_end_clean();
         // Table output
         echo NConf_HTML::table_row_check(NConf_HTML::swap_opener($swap_id, $destination["title"], TRUE), $status);
         $content = NConf_HTML::table_begin('class="table_content ui-widget-content"', array(102, 50, ''));
         $content .= NConf_HTML::get_info();
         $content .= NConf_HTML::table_end();
         // create row with detailed feedback
         echo NConf_HTML::table_row_text($content, '', 'colspan=3', TRUE);
         // add status to history log
         NConf_Deployment::history($destination["title"], $status);
     }
 }
 public function run_deployment()
 {
     if (!ALLOW_DEPLOYMENT) {
         echo NConf_HTML::limit_space(NConf_HTML::show_error('ERROR', 'Deployment functionality is currently disabled.'));
     } elseif (ALLOW_DEPLOYMENT && (!ALLOW_DIRECT_DEPLOYMENT && empty($_POST["status"]))) {
         echo NConf_HTML::limit_space(NConf_HTML::show_error('ERROR', 'Please first run the "Generate Nagios config".'));
     } elseif (ALLOW_DEPLOYMENT && ALLOW_DIRECT_DEPLOYMENT || ALLOW_DEPLOYMENT && (!ALLOW_DIRECT_DEPLOYMENT && (!empty($_POST["status"]) && $_POST["status"] == "OK"))) {
         echo NConf_HTML::table_begin('class="table_checks"', array(170, 50, ''));
         // DEPLOY
         // First do the local module
         $local_module = $this->modules["local"];
         if ($local_module->configured()) {
             NConf_DEBUG::set('', 'DEBUG', 'Deploying ' . $local_module->name);
             echo NConf_HTML::table_row_text(NConf_HTML::title($local_module->name, '', 'class="content_header"'));
             NConf_DEBUG::set($local_module->destinations, 'DEBUG', $local_module->name);
             $local_module->deploy();
             echo NConf_HTML::table_row_text(NConf_HTML::line(), '', 'colspan=3');
         }
         // Then do all other modules if they are configured
         foreach ($this->modules as $module) {
             // Dont do the "local" module
             // Check also if module is configured
             if ($module->name == "local" or !$module->configured()) {
                 continue;
             }
             NConf_DEBUG::set('', 'DEBUG', 'Deploying ' . $module->name);
             echo NConf_HTML::table_row_text(NConf_HTML::title($module->name, '', 'class="content_header"'));
             NConf_DEBUG::set($module->destinations, 'DEBUG', $module->name);
             // run the deploy
             $module->deploy();
             echo NConf_HTML::table_row_text(NConf_HTML::line(), '', 'colspan=3');
         }
         echo NConf_HTML::table_end();
     } else {
         echo NConf_HTML::text('Deployment is enabled, but your configuration seems to have errors.', TRUE, 'div', 'class="attention"');
     }
 }