Example #1
0
     $template = NagiosHostTemplatePeer::retrieveByPK($_POST['hostmanage']['template_add']['template_id']);
     if (!$template) {
         $error = "That host template is not found.";
     } else {
         // We need to get the count of templates already inherited
         $templateList = $host->getNagiosHostTemplateInheritances();
         foreach ($templateList as $tempTemplate) {
             if ($tempTemplate->getId() == $_POST['hostmanage']['template_add']['template_id']) {
                 $error = "That template already exists in the inheritance chain.";
             }
         }
         if (empty($error)) {
             $newInheritance = new NagiosHostTemplateInheritance();
             $newInheritance->setNagiosHost($host);
             $newInheritance->setNagiosHostTemplateRelatedByTargetTemplate($template);
             $newInheritance->setOrder(count($templateList));
             try {
                 $newInheritance->save();
                 $success = "Template added to inheritance chain.";
             } catch (Exception $e) {
                 $error = $e->getMessage();
             }
         }
     }
 } else {
     if ($_POST['request'] == 'host_template_modify_checks') {
         if (count($modifiedData)) {
             foreach ($modifiedData as $tempVariable) {
                 $tempVariable = trim($tempVariable);
             }
         }