Example #1
0
 public function getByName($name)
 {
     $c = new Criteria();
     $c->add(NagiosContactGroupPeer::NAME, $name);
     $c->setIgnoreCase(true);
     $contactgroup = NagiosContactGroupPeer::doSelectOne($c);
     if (!$contactgroup) {
         return false;
     }
     return $contactgroup;
 }
Example #2
0
 public function joinNagiosContactGroupByName($name)
 {
     $c = new Criteria();
     $c->add(NagiosContactGroupPeer::NAME, $name);
     $group = NagiosContactGroupPeer::doSelectOne($c);
     if (!empty($group)) {
         $membership = new NagiosContactGroupMember();
         $membership->setNagiosContact($this);
         $membership->setNagiosContactGroup($group);
         $membership->save();
         return true;
     }
     return false;
 }
Example #3
0
 function addContactGroupByName($name)
 {
     $c = new Criteria();
     $c->add(NagiosContactGroupPeer::NAME, $name);
     $c->setIgnoreCase(true);
     $contactgroup = NagiosContactGroupPeer::doSelectOne($c);
     if (!$contactgroup) {
         return false;
     }
     // Okay, contactgroup is valid, check for relationship
     $id = $this->getId();
     if (!empty($id)) {
         $c = new Criteria();
         $c->add(NagiosHostContactgroupPeer::HOST_TEMPLATE, $this->getId());
         $c->add(NagiosHostContactgroupPeer::CONTACTGROUP, $contactgroup->getId());
         $relationship = NagiosHostContactgroupPeer::doSelectOne($c);
         if ($relationship) {
             return false;
         }
     }
     $relationship = new NagiosHostContactgroup();
     $relationship->setNagiosHostTemplate($this);
     $relationship->setNagiosContactGroup($contactgroup);
     $relationship->save();
     return true;
 }
Example #4
0
 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;
 }
 /**
  * Get the associated NagiosContactGroup object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     NagiosContactGroup The associated NagiosContactGroup object.
  * @throws     PropelException
  */
 public function getNagiosContactGroup(PropelPDO $con = null)
 {
     if ($this->aNagiosContactGroup === null && $this->contactgroup !== null) {
         $c = new Criteria(NagiosContactGroupPeer::DATABASE_NAME);
         $c->add(NagiosContactGroupPeer::ID, $this->contactgroup);
         $this->aNagiosContactGroup = NagiosContactGroupPeer::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->aNagiosContactGroup->addNagiosHostContactgroups($this);
         		 */
     }
     return $this->aNagiosContactGroup;
 }
 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;
 }
Example #7
0
 public function valid()
 {
     $values = $this->getSegment()->getValues();
     $job = $this->getEngine()->getJob();
     if (isset($values['use'])) {
         // We need to use a template
         $job->addNotice("This Contact uses a template: " . $values['use'][0]['value']);
         $template = NagiosContactImporter::getTemplateByName($values['use'][0]['value']);
         if (empty($template)) {
             $job->addNotice("That template is not found yet. Setting this contact as queued.");
             return false;
         }
     }
     // Check time period existence
     if (isset($values['host_notification_period'])) {
         $c = new Criteria();
         $c->add(NagiosTimeperiodPeer::NAME, $values['host_notification_period'][0]['value']);
         $timePeriod = NagiosTimeperiodPeer::doSelectOne($c);
         if (empty($timePeriod)) {
             $job->addNotice("The time period specified by " . $values['host_notification_period'][0]['value'] . " was not found.  Setting this contact as queued.");
             return false;
         }
         $timePeriod->clearAllReferences(true);
     }
     if (isset($values['service_notification_period'])) {
         $c = new Criteria();
         $c->add(NagiosTimeperiodPeer::NAME, $values['service_notification_period'][0]['value']);
         $timePeriod = NagiosTimeperiodPeer::doSelectOne($c);
         if (empty($timePeriod)) {
             $job->addNotice("The time period specified by " . $values['service_notification_period'][0]['value'] . " was not found.  Setting this contact as queued.");
             return false;
         }
         $timePeriod->clearAllReferences(true);
     }
     // Check command existence
     if (isset($values['service_notification_commands'])) {
         foreach ($values['service_notification_commands'] as $commandValues) {
             $c = new Criteria();
             $c->add(NagiosCommandPeer::NAME, $commandValues['value']);
             $command = NagiosCommandPeer::doSelectOne($c);
             if (empty($command)) {
                 $job->addNotice("The command specified by " . $commandValues['value'] . " was not found.  Setting this contact as queued.");
                 return false;
             }
             $command->clearAllReferences(true);
         }
     }
     if (isset($values['host_notification_commands'])) {
         foreach ($values['host_notification_commands'] as $commandValues) {
             $c = new Criteria();
             $c->add(NagiosCommandPeer::NAME, $commandValues['value']);
             $command = NagiosCommandPeer::doSelectOne($c);
             if (empty($command)) {
                 $job->addNotice("The command specified by " . $commandValues['value'] . " was not found.  Setting this contact as queued.");
                 return false;
             }
             $command->clearAllReferences(true);
         }
     }
     // Check contact groups
     if (isset($values['contactgroups'])) {
         foreach ($values['contactgroups'] 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 contact as queued.");
                 return false;
             }
             $contactgroup->clearAllReferences(true);
         }
     }
     return true;
 }