getName(); $sublink = "?host_template_id=" . $hostTemplate->getId(); $cancelLink = "host_template.php?id=" . $hostTemplate->getId() . "§ion=services"; } } else if(isset($_GET['host_id'])) { $host = NagiosHostPeer::retrieveByPK($_GET['host_id']); if(!$host) { header("Location: welcome.php"); die(); } else { $title = " for Host " . $host->getName(); $sublink = "?host_id=" . $host->getId(); $cancelLink = "hosts.php?id=" . $host->getId() . "§ion=services"; } } else if(isset($_GET['hostgroup_id'])) { $hostgroup = NagiosHostgroupPeer::retrieveByPK($_GET['hostgroup_id']); if(!$hostgroup) { header("Location: welcome.php"); die(); } else { $title = " for Hostgroup " . $hostgroup->getName(); $sublink = "?hostgroup_id=" . $hostgroup->getId(); $cancelLink = "hostgroups.php?id=" . $hostgroup->getId() . "§ion=services"; } } else { header("Location: welcome.php"); die(); } if(isset($_POST['request'])) { if($_POST['request'] == 'add_service') { if(isset($hostTemplate)) { // Template logic $c = new Criteria(); $c->add(NagiosServicePeer::DESCRIPTION, $_POST['service_description']); $c->add(NagiosServicePeer::HOST_TEMPLATE, $hostTemplate->getId()); $c->setIgnoreCase(true); $service = NagiosServicePeer::doSelectOne($c); if($service) { $error = "A service with that description already exists for that host template."; } else { // Let's add. $service = new NagiosService(); $service->setDescription($_POST['service_description']); $service->setDisplayName($_POST['display_name']); $service->setHostTemplate($hostTemplate->getId()); $service->save(); header("Location: service.php?id=" . $service->getId()); die(); } } else if(isset($host)) { // Host logic $c = new Criteria(); $c->add(NagiosServicePeer::DESCRIPTION, $_POST['service_description']); $c->add(NagiosServicePeer::HOST, $host->getId()); $c->setIgnoreCase(true); $service = NagiosServicePeer::doSelectOne($c); if($service) { $error = "A service with that description already exists for that host."; } else { // Let's add. $service = new NagiosService(); $service->setDescription($_POST['service_description']); $service->setDisplayName($_POST['display_name']); $service->setHost($host->getId()); $service->save(); header("Location: service.php?id=" . $service->getId()); die(); } } else if(isset($hostgroup)) { // Host logic $c = new Criteria(); $c->add(NagiosServicePeer::DESCRIPTION, $_POST['service_description']); $c->add(NagiosServicePeer::HOSTGROUP, $hostgroup->getId()); $c->setIgnoreCase(true); $service = NagiosServicePeer::doSelectOne($c); if($service) { $error = "A service with that description already exists for that hostgroup."; } else { // Let's add. $service = new NagiosService(); $service->setDescription($_POST['service_description']); $service->setDisplayName($_POST['display_name']); $service->setHostgroup($hostgroup->getId()); $service->save(); header("Location: service.php?id=" . $service->getId()); die(); } } } } print_header("Service Editor"); // Get list of service templates $lilac->get_service_template_list($tempList); $template_list[] = array("service_template_id" => '', "template_name" => "None"); foreach($tempList as $tempTemplate) $template_list[] = array('service_template_id' => $tempTemplate->getId(), 'template_name' => $tempTemplate->getName()); print_window_header("Add Service " . $title, "100%"); ?>
Service Description:

element_desc("service_description", "nagios_services_desc"); ?>

Display Name: (Optional)

element_desc("display_name", "nagios_services_desc"); ?>

 [ Cancel ]