public function getByName($name) { $c = new Criteria(); $c->add(NagiosContactPeer::NAME, $name); $c->setIgnoreCase(true); $contact = NagiosContactPeer::doSelectOne($c); if (!$contact) { return false; } return $contact; }
public function addMemberByName($name) { $c = new Criteria(); $c->add(NagiosContactPeer::NAME, $name); $contact = NagiosContactPeer::doSelectOne($c); if (!empty($contact)) { $membership = new NagiosContactGroupMember(); $membership->setNagiosContactGroup($this); $membership->setNagiosContact($contact); $membership->save(); return true; } return false; }
public function valid() { $values = $this->getSegment()->getValues(); $job = $this->getEngine()->getJob(); // Check contact existence if (isset($values['members'])) { foreach ($values['members'] as $contactValues) { $c = new Criteria(); $c->add(NagiosContactPeer::NAME, $contactValues['value']); $contact = NagiosContactPeer::doSelectOne($c); if (empty($contact)) { $job->addNotice("The contact specified by " . $contactValues['value'] . " was not found. Setting this contact group as queued."); return false; } $contact->clearAllReferences(true); } } return true; }
function addContactByName($name) { $c = new Criteria(); $c->add(NagiosContactPeer::NAME, $name); $c->setIgnoreCase(true); $contact = NagiosContactPeer::doSelectOne($c); if (!$contact) { return false; } // Okay, contact is valid, check for relationship $id = $this->getId(); if (!empty($id)) { $c = new Criteria(); $c->add(NagiosHostContactMemberPeer::TEMPLATE, $this->getId()); $c->add(NagiosHostContactMemberPeer::CONTACT, $contact->getId()); $relationship = NagiosHostContactMemberPeer::doSelectOne($c); if ($relationship) { return false; } } $relationship = new NagiosHostContactMember(); $relationship->setNagiosHostTemplate($this); $relationship->setNagiosContact($contact); $relationship->save(); return true; }
/** * Get the associated NagiosContact object * * @param PropelPDO Optional Connection object. * @return NagiosContact The associated NagiosContact object. * @throws PropelException */ public function getNagiosContact(PropelPDO $con = null) { if ($this->aNagiosContact === null && $this->contact !== null) { $c = new Criteria(NagiosContactPeer::DATABASE_NAME); $c->add(NagiosContactPeer::ID, $this->contact); $this->aNagiosContact = NagiosContactPeer::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->aNagiosContact->addNagiosEscalationContacts($this); */ } return $this->aNagiosContact; }
public function valid() { $values = $this->getSegment()->getValues(); $job = $this->getEngine()->getJob(); if (isset($values['use'])) { // We need to use a template $job->addNotice("This Host uses a template: " . $values['use'][0]['value']); $template = NagiosHostTemplatePeer::getByName($values['use'][0]['value']); if (empty($template)) { if (!isset($values['name'][0]['value'])) { $job->addNotice("That template is not found yet. Setting this host (" . $values['host_name'][0]['value'] . ") as queued."); } else { $job->addNotice("That template is not found yet. Setting this host template (" . $values['name'][0]['value'] . ") as queued."); } return false; } } // Check time period existence if (isset($values['check_period'])) { $c = new Criteria(); $c->add(NagiosTimeperiodPeer::NAME, $values['check_period'][0]['value']); $timePeriod = NagiosTimeperiodPeer::doSelectOne($c); if (empty($timePeriod)) { $job->addNotice("The time period specified by " . $values['check_period'][0]['value'] . " was not found."); return false; } $timePeriod->clearAllReferences(true); } if (isset($values['notification_period'])) { $c = new Criteria(); $c->add(NagiosTimeperiodPeer::NAME, $values['notification_period'][0]['value']); $timePeriod = NagiosTimeperiodPeer::doSelectOne($c); if (empty($timePeriod)) { $job->addNotice("The time period specified by " . $values['notification_period'][0]['value'] . " was not found."); return false; } $timePeriod->clearAllReferences(true); } // Check command existence if (isset($values['check_command'])) { $params = explode("!", $values['check_command'][0]['value']); $c = new Criteria(); $c->add(NagiosCommandPeer::NAME, $params[0]); $command = NagiosCommandPeer::doSelectOne($c); if (empty($command)) { $job->addNotice("The command specified by " . $params[0] . " was not found."); return false; } $command->clearAllReferences(true); } if (isset($values['event_handler'])) { $c = new Criteria(); $c->add(NagiosCommandPeer::NAME, $values['event_handler'][0]['value']); $command = NagiosCommandPeer::doSelectOne($c); if (empty($command)) { $job->addNotice("The command specified by " . $values['event_handler'][0]['value'] . " was not found."); return false; } $command->clearAllReferences(true); } // Check contact groups if (isset($values['contact_groups'])) { foreach ($values['contact_groups'] as $contactGroupValues) { $c = new Criteria(); $c->add(NagiosContactGroupPeer::NAME, $contactGroupValues['value']); $contactgroup = NagiosContactGroupPeer::doSelectOne($c); if (empty($contactgroup)) { $job->addNotice("The contact group specified by " . $contactGroupValues['value'] . " was not found."); return false; } $contactgroup->clearAllReferences(); } } if (isset($values['contacts'])) { foreach ($values['contacts'] as $contactValues) { $c = new Criteria(); $c->add(NagiosContactPeer::NAME, $contactValues['value']); $contactgroup = NagiosContactPeer::doSelectOne($c); if (empty($contactgroup)) { $job->addNotice("The contact specified by " . $contactValues['value'] . " was not found."); return false; } $contactgroup->clearAllReferences(); } } // Check host groups if (isset($values['hostgroups'])) { foreach ($values['hostgroups'] as $hostGroupValues) { $c = new Criteria(); $c->add(NagiosHostgroupPeer::NAME, $hostGroupValues['value']); $hostgroup = NagiosHostgroupPeer::doSelectOne($c); if (empty($hostgroup)) { $job->addNotice("The host group specified by " . $hostGroupValues['value'] . " was not found."); return false; } $hostgroup->clearAllReferences(); } } // Check parents if (isset($values['parents'])) { foreach ($values['parents'] as $parentValues) { $c = new Criteria(); $c->add(NagiosHostPeer::NAME, $parentValues['value']); $host = NagiosHostPeer::doSelectOne($c); if (empty($host)) { $job->addNotice("The host specified by " . $parentValues['value'] . " was not found."); return false; } $host->clearAllReferences(); } } return true; }
public function valid() { $values = $this->getSegment()->getValues(); $job = $this->getEngine()->getJob(); if (isset($values['use'])) { // We need to use a template $job->addNotice("This Service Escalation uses a template: " . $values['use'][0]['value']); $template = NagiosServiceEscalationImporter::getTemplateByName($values['use'][0]['value']); if (empty($template)) { $job->addNotice("That template is not found yet. Setting this service escalation as queued."); return false; } } // Check time period existence if (isset($values['escalation_period'])) { $c = new Criteria(); $c->add(NagiosTimeperiodPeer::NAME, $values['escalation_period'][0]['value']); $timePeriod = NagiosTimeperiodPeer::doSelectOne($c); if (empty($timePeriod)) { $job->addNotice("The time period specified by " . $values['escalation_period'][0]['value'] . " was not found. Setting this service escalation as queued."); return false; } $timePeriod->clearAllReferences(true); } // Check contact groups if (isset($values['contact_groups'])) { foreach ($values['contact_groups'] as $contactGroupValues) { $c = new Criteria(); $c->add(NagiosContactGroupPeer::NAME, $contactGroupValues['value']); $contactgroup = NagiosContactGroupPeer::doSelectOne($c); if (empty($contactgroup)) { $job->addNotice("The contact group specified by " . $contactGroupValues['value'] . " was not found. Setting this service escalation as queued."); return false; } $contactgroup->clearAllReferences(true); } } // Check contacts if (isset($values['contacts'])) { foreach ($values['contacts'] as $contactValues) { $c = new Criteria(); $c->add(NagiosContactPeer::NAME, $contactValues['value']); $contact = NagiosContactPeer::doSelectOne($c); if (empty($contact)) { $job->addNotice("The contact specified by " . $contactValues['value'] . " was not found. Setting this service escalation as queued."); return false; } $contact->clearAllReferences(true); } } if (isset($values['host_name'])) { foreach ($values['host_name'] as $hostValues) { $service = NagiosServicePeer::getByHostAndDescription($hostValues['value'], $values['service_description'][0]['value']); if (empty($service)) { $job->addNotice("The service specified by " . $hostValues['value'] . ":" . $values['service_description'][0]['value'] . " was not found. Setting this host escalation as queued."); return false; } $service->clearAllReferences(true); } } // Check for hostgroup_name if (isset($values['hostgroup_name'])) { foreach ($values['hostgroup_name'] as $hostgroupValues) { $service = NagiosServicePeer::getByHostgroupAndDescription($hostgroupValues['value'], $values['service_description'][0]['value']); if (empty($service)) { $job->addNotice("The service specified by hostgroup " . $hostgroupValues['value'] . ":" . $values['service_description'][0]['value'] . " was not found. Setting this host escalation as queued."); return false; } $service->clearAllReferences(true); } } return true; }