public static function getByHostTemplateAndDescription($hostTemplateName, $description) { // First get host template $template = NagiosHostTemplatePeer::getByName($hostTemplateName); if (!$template) { return false; } $c = new Criteria(); $c->add(NagiosServicePeer::HOST_TEMPLATE, $template->getId()); $c->add(NagiosServicePeer::DESCRIPTION, $description); $c->setIgnoreCase(true); $service = NagiosServicePeer::doSelectOne($c); if (!$service) { return false; } return $service; }
/** * Get the associated NagiosService object * * @param PropelPDO Optional Connection object. * @return NagiosService The associated NagiosService object. * @throws PropelException */ public function getNagiosService(PropelPDO $con = null) { if ($this->aNagiosService === null && $this->source_service !== null) { $c = new Criteria(NagiosServicePeer::DATABASE_NAME); $c->add(NagiosServicePeer::ID, $this->source_service); $this->aNagiosService = NagiosServicePeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aNagiosService->addNagiosServiceTemplateInheritances($this); */ } return $this->aNagiosService; }
} } } if ($_POST['request'] == 'service_template_modify_general') { if ($modifiedData['service_description'] != $service->getDescription()) { // Now check to see if we belong to a host or template, and if that service already exists for that name. $c = new Criteria(); $c->add(NagiosServicePeer::DESCRIPTION, $modifiedData['service_description']); if ($service->getHost()) { $c->add(NagiosServicePeer::HOST, $service->getHost()); } else { if ($service->getHostTemplate()) { $c->add(NagiosServicePeer::HOST_TEMPLATE, $service->getHostTemplate()); } } $tempService = NagiosServicePeer::doSelectOne($c); if ($tempService) { $error = "A service with that name already exists!"; } else { $service->setDescription($modifiedData['service_description']); $service->setDisplayName($modifiedData['display_name']); $service->save(); unset($_GET['edit']); $success = "Service modified."; } } else { // Field Error Checking if (count($modifiedData)) { foreach ($modifiedData as $tempVariable) { $tempVariable = trim($tempVariable); }