Example #1
0
 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;
 }
Example #2
0
 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;
 }
Example #4
0
         $host->setThreeDCoords($modifiedData['three_d_coords']);
     } else {
         $host->setThreeDCoords(null);
     }
     $host->save();
     $success = "Updated Host Extended Information";
 } else {
     if ($_POST['request'] == 'add_contact_command') {
         $c = new Criteria();
         $c->add(NagiosHostContactMemberPeer::HOST, $_GET['id']);
         $c->add(NagiosHostContactMemberPeer::CONTACT, $_POST['host_manage']['contact_add']['contact_id']);
         $membership = NagiosHostContactMemberPeer::doSelectOne($c);
         if ($membership) {
             $error = "That contact already exists in that list!";
         } else {
             $tempContact = NagiosContactPeer::retrieveByPk($_POST['host_manage']['contact_add']['contact_id']);
             if ($tempContact) {
                 $membership = new NagiosHostContactMember();
                 $membership->setHost($_GET['id']);
                 $membership->setNagiosContact($tempContact);
                 $membership->save();
                 $success = "New Host Contact Link added.";
             } else {
                 $error = "That contact is not found.";
             }
         }
     } else {
         if ($_POST['request'] == 'add_contactgroup_command') {
             $c = new Criteria();
             $c->add(NagiosHostContactgroupPeer::HOST, $_GET['id']);
             $c->add(NagiosHostContactgroupPeer::CONTACTGROUP, $_POST['host_manage']['contactgroup_add']['contactgroup_id']);
 /**
  * Selects a collection of NagiosContactNotificationCommand objects pre-filled with all related objects except NagiosCommand.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of NagiosContactNotificationCommand objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptNagiosCommand(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     NagiosContactNotificationCommandPeer::addSelectColumns($c);
     $startcol2 = NagiosContactNotificationCommandPeer::NUM_COLUMNS - NagiosContactNotificationCommandPeer::NUM_LAZY_LOAD_COLUMNS;
     NagiosContactPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (NagiosContactPeer::NUM_COLUMNS - NagiosContactPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(NagiosContactNotificationCommandPeer::CONTACT_ID), array(NagiosContactPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = NagiosContactNotificationCommandPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = NagiosContactNotificationCommandPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = NagiosContactNotificationCommandPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             NagiosContactNotificationCommandPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined NagiosContact rows
         $key2 = NagiosContactPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = NagiosContactPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = NagiosContactPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 NagiosContactPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (NagiosContactNotificationCommand) to the collection in $obj2 (NagiosContact)
             $obj2->addNagiosContactNotificationCommand($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Example #6
0
 public function export()
 {
     // Grab our export job
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("NagiosContactExporter attempting to export contact configuration.");
     $fp = $this->getOutputFile();
     fputs($fp, "# Written by NagiosContactExporter from " . LILAC_NAME . " " . LILAC_VERSION . " on " . date("F j, Y, g:i a") . "\n\n");
     $contacts = NagiosContactPeer::doSelect(new Criteria());
     foreach ($contacts as $contact) {
         fputs($fp, "define contact {\n");
         $finalArray = array();
         $values = $contact->toArray(BasePeer::TYPE_FIELDNAME);
         foreach ($values as $key => $value) {
             if ($key == 'id' || $key == 'host_notification_on_down' || $key == 'host_notification_on_unreachable' || $key == 'host_notification_on_recovery' || $key == 'host_notification_on_flapping' || $key == 'host_notification_on_scheduled_downtime' || $key == 'service_notification_on_warning' || $key == 'service_notification_on_unknown' || $key == 'service_notification_on_critical' || $key == 'service_notification_on_recovery' || $key == 'service_notification_on_flapping') {
                 continue;
             }
             if ($key == 'name') {
                 $key = 'contact_name';
             }
             if ($value === null) {
                 continue;
             }
             if ($value === false) {
                 $value = '0';
             }
             if ($key == "host_notification_period" || $key == "service_notification_period") {
                 $timeperiod = NagiosTimeperiodPeer::retrieveByPK($value);
                 if (!$timeperiod) {
                     $job->addError("Unable to find timeperiod with id: " . $value . " for " . $key);
                     return false;
                 }
                 $value = $timeperiod->getName();
             }
             $finalArray[$key] = $value;
         }
         foreach ($finalArray as $key => $val) {
             fputs($fp, "\t" . $key . "\t" . $val . "\n");
         }
         // Notification On changes
         if (!$contact->getHostNotificationOnDown() && !$contact->getHostNotificationOnUnreachable() && !$contact->getHostNotificationOnRecovery() && !$contact->getHostNotificationOnFlapping()) {
             // Do nothing
         } else {
             fputs($fp, "\thost_notification_options\t");
             if ($contact->getHostNotificationOnDown()) {
                 fputs($fp, "d");
                 if ($contact->getHostNotificationOnUnreachable() || $contact->getHostNotificationOnRecovery() || $contact->getHostNotificationOnFlapping() || $contact->getHostNotificationOnScheduledDowntime()) {
                     fputs($fp, ",");
                 }
             }
             if ($contact->getHostNotificationOnUnreachable()) {
                 fputs($fp, "u");
                 if ($contact->getHostNotificationOnRecovery() || $contact->getHostNotificationOnFlapping() || $contact->getHostNotificationOnScheduledDowntime()) {
                     fputs($fp, ",");
                 }
             }
             if ($contact->getHostNotificationOnRecovery()) {
                 fputs($fp, "r");
                 if ($contact->getHostNotificationOnFlapping() || $contact->getHostNotificationOnScheduledDowntime()) {
                     fputs($fp, ",");
                 }
             }
             if ($contact->getHostNotificationOnFlapping()) {
                 fputs($fp, "f");
                 if ($contact->getHostNotificationOnScheduledDowntime()) {
                     fputs($fp, ",");
                 }
             }
             if ($contact->getHostNotificationOnScheduledDowntime()) {
                 fputs($fp, "s");
             }
             fputs($fp, "\n");
         }
         if (!$contact->getServiceNotificationOnWarning() && !$contact->getServiceNotificationOnUnknown() && !$contact->getServiceNotificationOnCritical() && !$contact->getServiceNotificationOnRecovery()) {
             // Do nothing
         } else {
             fputs($fp, "\tservice_notification_options\t");
             if ($contact->getServiceNotificationOnWarning()) {
                 fputs($fp, "w");
                 if ($contact->getServiceNotificationOnUnknown() || $contact->getServiceNotificationOnCritical() || $contact->getServiceNotificationOnRecovery()) {
                     fputs($fp, ",");
                 }
             }
             if ($contact->getServiceNotificationOnUnknown()) {
                 fputs($fp, "u");
                 if ($contact->getServiceNotificationOnCritical() || $contact->getServiceNotificationOnRecovery()) {
                     fputs($fp, ",");
                 }
             }
             if ($contact->getServiceNotificationOnCritical()) {
                 fputs($fp, "c");
                 if ($contact->getServiceNotificationOnRecovery() || $contact->getServiceNotificationOnFlapping()) {
                     fputs($fp, ",");
                 }
             }
             if ($contact->getServiceNotificationOnRecovery()) {
                 fputs($fp, "r");
                 if ($contact->getServiceNotificationOnFlapping()) {
                     fputs($fp, ",");
                 }
             }
             if ($contact->getServiceNotificationOnFlapping()) {
                 fputs($fp, "f");
             }
             fputs($fp, "\n");
         }
         // Get notification commands
         $c = new Criteria();
         $c->add(NagiosContactNotificationCommandPeer::TYPE, "host");
         $hostNotificationCommands = $contact->getNagiosContactNotificationCommands($c);
         $c = new Criteria();
         $c->add(NagiosContactNotificationCommandPeer::TYPE, "service");
         $serviceNotificationCommands = $contact->getNagiosContactNotificationCommands($c);
         if (count($hostNotificationCommands)) {
             fputs($fp, "\thost_notification_commands\t");
             $first = true;
             foreach ($hostNotificationCommands as $command) {
                 if (!$first) {
                     fputs($fp, ",");
                 } else {
                     $first = false;
                 }
                 fputs($fp, $command->getNagiosCommand()->getName());
             }
             fputs($fp, "\n");
         }
         if (count($serviceNotificationCommands)) {
             fputs($fp, "\tservice_notification_commands\t");
             $first = true;
             foreach ($serviceNotificationCommands as $command) {
                 if (!$first) {
                     fputs($fp, ",");
                 } else {
                     $first = false;
                 }
                 fputs($fp, $command->getNagiosCommand()->getName());
             }
             fputs($fp, "\n");
         }
         // Get Addresses
         $c = new Criteria();
         $c->addAscendingOrderByColumn(NagiosContactAddressPeer::ID);
         $addresses = $contact->getNagiosContactAddresss($c);
         if (count($addresses)) {
             $counter = 1;
             foreach ($addresses as $address) {
                 fputs($fp, "\taddress" . $counter++ . "\t" . $address->getAddress() . "\n");
             }
         }
         fputs($fp, "}\n");
         fputs($fp, "\n");
     }
     $job->addNotice("NagiosContactExporter complete.");
     return true;
 }
Example #7
0
                $membership->setNagiosEscalation($escalation);
                $membership->setContactgroup($_POST['escalation_manage']['contactgroup_add']['contactgroup_id']);
                $membership->save();
                $success = "New Escalation Contact Group Link added.";
                unset($_POST['escalation_manage']);
            }
        } else {
            if ($_POST['request'] == 'add_contact_command') {
                $c = new Criteria();
                $c->add(NagiosEscalationContactPeer::ESCALATION, $_GET['id']);
                $c->add(NagiosEscalationContactPeer::CONTACT, $_POST['escalation_manage']['contact_add']['contact_id']);
                $membership = NagiosEscalationContactPeer::doSelectOne($c);
                if ($membership) {
                    $error = "That contact already exists in that list!";
                } else {
                    $tempContact = NagiosContactPeer::retrieveByPk($_POST['escalation_manage']['contact_add']['contact_id']);
                    if ($tempContact) {
                        $membership = new NagiosEscalationContact();
                        $membership->setEscalation($_GET['id']);
                        $membership->setNagiosContact($tempContact);
                        $membership->save();
                        $success = "New Escalation Contact Link added.";
                    } else {
                        $error = "That contact is not found.";
                    }
                }
            }
        }
    }
}
if (isset($_GET['id'])) {
Example #8
0
 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;
 }
Example #10
0
 public function import()
 {
     $job = $this->getJob();
     $job->addNotice("FruityImportEngine beginning import...");
     $config = $this->getConfig();
     $job->addNotice("Removing existing Nagios objects.");
     NagiosTimeperiodPeer::doDeleteAll();
     NagiosCommandPeer::doDeleteAll();
     NagiosContactPeer::doDeleteAll();
     NagiosContactGroupPeer::doDeleteAll();
     NagiosHostTemplatePeer::doDeleteAll();
     NagiosHostPeer::doDeleteAll();
     NagiosHostgroupPeer::doDeleteAll();
     NagiosServiceGroupPeer::doDeleteAll();
     NagiosServiceTemplatePeer::doDeleteAll();
     NagiosServicePeer::doDeleteAll();
     NagiosDependencyPeer::doDeleteAll();
     NagiosDependencyTargetPeer::doDeleteAll();
     NagiosEscalationPeer::doDeleteAll();
     NagiosBrokerModulePeer::doDeleteAll();
     NagiosMainConfigurationPeer::doDeleteAll();
     NagiosCgiConfigurationPeer::doDeleteAll();
     $importer = new FruityResourceImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityCgiImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityCommandImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityTimeperiodImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityContactImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityServiceGroupImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityServiceTemplateImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityHostTemplateImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityHostGroupImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityHostImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityServiceImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityDependencyImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityEscalationImporter($this, $this->dbConn);
     $importer->import();
     $importer = new FruityMainImporter($this, $this->dbConn);
     $importer->import();
     $job->addNotice("FruityImportEngine completed job.");
     return true;
 }
Example #11
0
 public function init()
 {
     $job = $this->getJob();
     $job->addNotice("NagiosImportEngine Starting...");
     $config = $this->getConfig();
     // Attempt to try and open each config file
     $job->addNotice("Attempting to open " . $config->GetVar('config_file'));
     if (!file_exists($config->getVar('config_file')) || !@fopen($config->getVar('config_file'), "r")) {
         $job->addError("Failed to open " . $config->getVar('config_file'));
         return false;
     }
     $job->addNotice("Attempting to open " . $config->GetVar('cgi_file'));
     if (!file_exists($config->getVar('cgi_file')) || !@fopen($config->getVar('cgi_file'), "r")) {
         $job->addError("Failed to open " . $config->getVar('cgi_file'));
         return false;
     }
     $job->addNotice("Attempting to open " . $config->GetVar('resources_file'));
     if (!file_exists($config->getVar('resources_file')) || !@fopen($config->getVar('resources_file'), "r")) {
         $job->addError("Failed to open " . $config->getVar('resources_file'));
         return false;
     }
     $job->addNotice("Config passed sanity check for Nagios import.  Finished initializing.");
     if ($config->getVar('delete_existing')) {
         $job->addNotice("Removing existing Nagios objects.");
         NagiosTimeperiodPeer::doDeleteAll();
         NagiosCommandPeer::doDeleteAll();
         NagiosContactPeer::doDeleteAll();
         NagiosContactGroupPeer::doDeleteAll();
         NagiosHostTemplatePeer::doDeleteAll();
         NagiosHostPeer::doDeleteAll();
         NagiosHostgroupPeer::doDeleteAll();
         NagiosServiceGroupPeer::doDeleteAll();
         NagiosServiceTemplatePeer::doDeleteAll();
         NagiosServicePeer::doDeleteAll();
         NagiosDependencyPeer::doDeleteAll();
         NagiosDependencyTargetPeer::doDeleteAll();
         NagiosEscalationPeer::doDeleteAll();
     }
     return true;
 }
Example #12
0
 /**
  * Returns the number of related NagiosContact objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related NagiosContact objects.
  * @throws     PropelException
  */
 public function countNagiosContactsRelatedByServiceNotificationPeriod(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(NagiosTimeperiodPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collNagiosContactsRelatedByServiceNotificationPeriod === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(NagiosContactPeer::SERVICE_NOTIFICATION_PERIOD, $this->id);
             $count = NagiosContactPeer::doCount($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(NagiosContactPeer::SERVICE_NOTIFICATION_PERIOD, $this->id);
             if (!isset($this->lastNagiosContactRelatedByServiceNotificationPeriodCriteria) || !$this->lastNagiosContactRelatedByServiceNotificationPeriodCriteria->equals($criteria)) {
                 $count = NagiosContactPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collNagiosContactsRelatedByServiceNotificationPeriod);
             }
         } else {
             $count = count($this->collNagiosContactsRelatedByServiceNotificationPeriod);
         }
     }
     return $count;
 }
Example #13
0
                    }
                } else {
                    if ($_POST['request'] == 'contact_address_add') {
                        // All is well for error checking, modify the contact.
                        $lilac->add_contact_address($_GET['contact_id'], $tempData);
                        // Remove session data
                        unset($tempData);
                        $success = "Contact Address added.";
                    }
                }
            }
        }
    }
}
if (isset($_GET['contact_id'])) {
    $tempContactInfo = NagiosContactPeer::retrieveByPK($_GET['contact_id']);
    if (!$tempContactInfo) {
        header("Location: welcome.php");
    }
}
$lilac->get_contact_list($contact_list);
$numOfContacts = count($contact_list);
$lilac->return_period_list($tempList);
$period_list = array();
foreach ($tempList as $tempPeriod) {
    $period_list[] = array("timeperiod_id" => $tempPeriod->getId(), "timeperiod_name" => $tempPeriod->getName());
}
print_header("Contact Editor");
if (isset($_GET['contact_id'])) {
    // Build subnav
    $subnav = array('general' => 'General', 'notification' => 'Notification Commands', 'groups' => 'Group Membership', 'addresses' => 'Addresses');
 private function __addContacts($escalation)
 {
     $job = $this->getEngine()->getJob();
     $config = $this->getEngine()->getConfig();
     $segment = $this->getSegment();
     $values = $segment->getValues();
     $fileName = $segment->getFilename();
     // Check if we need to bring in values from a template
     if (isset($values['use'])) {
         // We sure are using a template!
         // Okay, hokey multi-inheritance support for the importer
         $tempValues = $this->getTemplateValues($values['use'][0]['value']);
         // Okay, go through each
         foreach ($tempValues as $key => $val) {
             if (!isset($values[$key])) {
                 $values[$key] = $val;
             }
         }
     }
     if (isset($values['contacts'])) {
         $contactNames = explode(",", $values['contacts'][0]['value']);
         foreach ($contactNames as $contact_name) {
             $contact = NagiosContactPeer::getByName($contact_name);
             if (!$contact) {
                 return false;
             }
             $relationship = new NagiosEscalationContact();
             $relationship->setNagiosContact($contact);
             $relationship->setNagiosEscalation($escalation);
             $relationship->save();
             $contact->clearAllReferences(true);
             $relationship->clearAllReferences(true);
         }
     }
     if (isset($values['contact_groups'])) {
         $contactGroupNames = explode(",", $values['contact_groups'][0]['value']);
         foreach ($contactGroupNames as $contactgroup_name) {
             $contactgroup = NagiosContactGroupPeer::getByName($contactgroup_name);
             if (!$contactgroup) {
                 return false;
             }
             $relationship = new NagiosEscalationContactGroup();
             $relationship->setNagiosContactGroup($contactgroup);
             $relationship->setNagiosEscalation($escalation);
             $relationship->save();
             $contactgroup->clearAllReferences(true);
             $relationship->clearAllReferences(true);
         }
     }
     return true;
 }
Example #15
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(NagiosContactPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(NagiosContactPeer::DATABASE_NAME);
         $criteria->add(NagiosContactPeer::ID, $pks, Criteria::IN);
         $objs = NagiosContactPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #16
0
 public function import()
 {
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("FruityContactImporter beginning to import Contact Configuration.");
     // Contacts
     foreach ($this->dbConn->query("SELECT * FROM nagios_contacts", PDO::FETCH_ASSOC) as $contact) {
         // Check for existing
         if (NagiosContactPeer::getByName($contact['contact_name'])) {
             $job->addNotice("Fruity Contact Importer: Contact " . $contact['contact_name'] . " already exists.  Aborting it's import.");
             continue;
         }
         $newContact = new NagiosContact();
         foreach ($contact as $key => $val) {
             unset($name);
             if ($key == "contact_id") {
                 continue;
             }
             if ($key == "contact_name") {
                 $key = "name";
             }
             if ($key == "host_notification_options_down") {
                 $key = "host_notification_on_down";
             }
             if ($key == "host_notification_options_unreachable") {
                 $key = "host_notification_on_unreachable";
             }
             if ($key == "host_notification_options_recovery") {
                 $key = "host_notification_on_recovery";
             }
             if ($key == "host_notification_options_flapping") {
                 $key = "host_notification_on_flapping";
             }
             if ($key == "service_notification_options_warning") {
                 $key = "service_notification_on_warning";
             }
             if ($key == "service_notification_options_unknown") {
                 $key = "service_notification_on_unknown";
             }
             if ($key == "service_notification_options_critical") {
                 $key = "service_notification_on_critical";
             }
             if ($key == "service_notification_options_recovery") {
                 $key = "service_notification_on_recovery";
             }
             if ($key == "service_notification_options_flapping") {
                 $key = "service_notification_on_flapping";
             }
             if ($key == "host_notification_period") {
                 $name = $this->getTimeperiodNameById($val, $this->dbConn);
                 if ($name) {
                     $newContact->setHostNotificationPeriodByName($name);
                 }
                 continue;
             }
             if ($key == "service_notification_period") {
                 $name = $this->getTimeperiodNameById($val, $this->dbConn);
                 if ($name) {
                     $newContact->setServiceNotificationPeriodByName($name);
                 }
                 continue;
             }
             try {
                 $name = NagiosContactPeer::translateFieldName($key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME);
             } catch (Exception $e) {
                 $job->addNotice("Fruity Contact Importer: Was unable to store unsupported value: " . $key);
             }
             if (!empty($name)) {
                 $method = "set" . $name;
                 $newContact->{$method}($val);
             }
         }
         $newContact->save();
     }
     // Contact Addresses
     foreach ($this->dbConn->query("SELECT * FROM nagios_contact_addresses", PDO::FETCH_ASSOC) as $address) {
         // Check for required contact
         $name = $this->getContactNameById($address['contact_id'], $this->dbConn);
         if (!$name) {
             $job->addNotice("Fruity Contact Address Importer: Could not find contact with id: " . $address['contact_id']);
             continue;
         }
         $contact = NagiosContactPeer::getByName($name);
         if (!$contact) {
             $job->addNotice("Fruity Contact Address Importer: Could not find contact with name: " . $name);
             continue;
         }
         $newContactAddress = new NagiosContactAddress();
         $newContactAddress->setNagiosContact($contact);
         $newContactAddress->setAddress($address['address']);
         $newContactAddress->save();
     }
     // Contact Notification Commands
     foreach ($this->dbConn->query("SELECT * FROM nagios_contacts_notification_commands", PDO::FETCH_ASSOC) as $notificationCommand) {
         // Check for required contact
         $name = $this->getContactNameById($notificationCommand['contact_id'], $this->dbConn);
         if (!$name) {
             $job->addNotice("Fruity Contact Notification Command Importer: Could not find contact with id: " . $notificationCommand['contact_id']);
             continue;
         }
         $contact = NagiosContactPeer::getByName($name);
         if (!$contact) {
             $job->addNotice("Fruity Contact Notification Command Importer: Could not find contact with name: " . $name);
             continue;
         }
         // Okay, now get the required command
         $name = $this->getCommandNameById($notificationCommand['command_id'], $this->dbConn);
         if (!$name) {
             $job->addNotice("Fruity Crontact Notification Command Importer: Could not find command with id: " . $notificationCommand['contact_id']);
             continue;
         }
         $command = NagiosCommandPeer::getByName($name);
         if (!$contact) {
             $job->addNotice("Fruity Contact Notification Command Importer: Could not find command with name: " . $name);
             continue;
         }
         $newNotificationCommand = new NagiosContactNotificationCommand();
         $newNotificationCommand->setNagiosContact($contact);
         $newNotificationCommand->setNagiosCommand($command);
         $newNotificationCommand->setType($notificationCommand['notification_type']);
         $newNotificationCommand->save();
     }
     // Contact Groups
     foreach ($this->dbConn->query("SELECT * FROM nagios_contactgroups", PDO::FETCH_ASSOC) as $contactGroup) {
         if (NagiosContactGroupPeer::getByName($contactGroup['contactgroup_name'])) {
             $job->addNotice("Fruity Contact Group Importer: Group " . $contactGroup['contactgroup_name'] . "already exists.  Aborting it's import.");
             continue;
         }
         $newContactGroup = new NagiosContactGroup();
         $newContactGroup->setName($contactGroup['contactgroup_name']);
         $newContactGroup->setAlias($contactGroup['alias']);
         $newContactGroup->save();
     }
     // Contact Group Members
     foreach ($this->dbConn->query("SELECT * FROM nagios_contactgroup_membership", PDO::FETCH_ASSOC) as $membership) {
         // Check for required contact
         $name = $this->getContactNameById($membership['contact_id'], $this->dbConn);
         if (!$name) {
             $job->addNotice("Fruity Contact Group Membership Importer: Could not find contact with id: " . $membership['contact_id']);
             continue;
         }
         $contact = NagiosContactPeer::getByName($name);
         if (!$contact) {
             $job->addNotice("Fruity Contact Group Membership Importer: Could not find contact with name: " . $name);
             continue;
         }
         // Okay, now get the required contact group
         $name = $this->getContactGroupNameById($membership['contactgroup_id'], $this->dbConn);
         if (!$name) {
             $job->addNotice("Fruity Contact Group Membership Importer: Could not find contact group with id: " . $membership['contactgroup_id']);
             continue;
         }
         $contactgroup = NagiosContactGroupPeer::getByName($name);
         if (!$contactgroup) {
             $job->addNotice("Fruity Contact Group Membership Importer: Could not find contact group with name: " . $name);
             continue;
         }
         $newMembership = new NagiosContactGroupMember();
         $newMembership->setNagiosContact($contact);
         $newMembership->setNagiosContactGroup($contactgroup);
         $newMembership->save();
     }
     $job->addNotice("FruityContactImporter finished importing Contact Configuration.");
 }
Example #17
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = NagiosContactPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setAlias($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setEmail($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setPager($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setHostNotificationsEnabled($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setServiceNotificationsEnabled($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setHostNotificationPeriod($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setServiceNotificationPeriod($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setHostNotificationOnDown($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setHostNotificationOnUnreachable($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setHostNotificationOnRecovery($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setHostNotificationOnFlapping($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setHostNotificationOnScheduledDowntime($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setServiceNotificationOnWarning($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setServiceNotificationOnUnknown($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setServiceNotificationOnCritical($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setServiceNotificationOnRecovery($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setServiceNotificationOnFlapping($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setCanSubmitCommands($arr[$keys[19]]);
     }
     if (array_key_exists($keys[20], $arr)) {
         $this->setRetainStatusInformation($arr[$keys[20]]);
     }
     if (array_key_exists($keys[21], $arr)) {
         $this->setRetainNonstatusInformation($arr[$keys[21]]);
     }
 }
Example #18
0
		<td><?php 
echo NagiosCommandPeer::doCount(new Criteria());
?>
</td>
	</tr>
	<tr class="odd">
		<td><strong>Total Nagios Time Periods:</strong></td>
		<td><?php 
echo NagiosTimeperiodPeer::doCount(new Criteria());
?>
</td>
	</tr>
	<tr>
		<td><strong>Total Nagios Contacts:</strong></td>
		<td><?php 
echo NagiosContactPeer::doCount(new Criteria());
?>
</td>
	</tr>
	<tr class="odd">
		<td><strong>Total Nagios Contact Groups:</strong></td>
		<td><?php 
echo NagiosContactGroupPeer::doCount(new Criteria());
?>
</td>
	</tr>
	<tr>
		<td><strong>Total Nagios Host Groups:</strong></td>
		<td><?php 
echo NagiosHostgroupPeer::doCount(new Criteria());
?>
Example #19
0
 /**
  * Method perform a DELETE on the database, given a NagiosTimeperiod or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or NagiosTimeperiod object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(NagiosTimeperiodPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // invalidate the cache for all objects of this type, since we have no
         // way of knowing (without running a query) what objects should be invalidated
         // from the cache based on this Criteria.
         NagiosTimeperiodPeer::clearInstancePool();
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof NagiosTimeperiod) {
         // invalidate the cache for this single object
         NagiosTimeperiodPeer::removeInstanceFromPool($values);
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it must be the primary key
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(NagiosTimeperiodPeer::ID, (array) $values, Criteria::IN);
         foreach ((array) $values as $singleval) {
             // we can invalidate the cache for this single object
             NagiosTimeperiodPeer::removeInstanceFromPool($singleval);
         }
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         $affectedRows += NagiosTimeperiodPeer::doOnDeleteCascade($criteria, $con);
         NagiosTimeperiodPeer::doOnDeleteSetNull($criteria, $con);
         // Because this db requires some delete cascade/set null emulation, we have to
         // clear the cached instance *after* the emulation has happened (since
         // instances get re-added by the select statement contained therein).
         if ($values instanceof Criteria) {
             NagiosTimeperiodPeer::clearInstancePool();
         } else {
             // it's a PK or object
             NagiosTimeperiodPeer::removeInstanceFromPool($values);
         }
         $affectedRows += BasePeer::doDelete($criteria, $con);
         // invalidate objects in NagiosTimeperiodEntryPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosTimeperiodEntryPeer::clearInstancePool();
         // invalidate objects in NagiosTimeperiodExcludePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosTimeperiodExcludePeer::clearInstancePool();
         // invalidate objects in NagiosTimeperiodExcludePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosTimeperiodExcludePeer::clearInstancePool();
         // invalidate objects in NagiosContactPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosContactPeer::clearInstancePool();
         // invalidate objects in NagiosContactPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosContactPeer::clearInstancePool();
         // invalidate objects in NagiosHostTemplatePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosHostTemplatePeer::clearInstancePool();
         // invalidate objects in NagiosHostTemplatePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosHostTemplatePeer::clearInstancePool();
         // invalidate objects in NagiosHostPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosHostPeer::clearInstancePool();
         // invalidate objects in NagiosHostPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosHostPeer::clearInstancePool();
         // invalidate objects in NagiosServiceTemplatePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosServiceTemplatePeer::clearInstancePool();
         // invalidate objects in NagiosServiceTemplatePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosServiceTemplatePeer::clearInstancePool();
         // invalidate objects in NagiosServicePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosServicePeer::clearInstancePool();
         // invalidate objects in NagiosServicePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosServicePeer::clearInstancePool();
         // invalidate objects in NagiosDependencyPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosDependencyPeer::clearInstancePool();
         // invalidate objects in NagiosEscalationPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         NagiosEscalationPeer::clearInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #20
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;
 }
Example #21
0
 private function search_text($text)
 {
     // LOTS of places to check...
     // Hosts: name, alias, addresses
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosHostPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(nagiosHostPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c3 = $c->getNewCriterion(nagiosHostPeer::ADDRESS, "%" . $text . "%", Criteria::LIKE);
     $c2->addOr($c3);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosHostPeer::NAME);
     $matchedHosts = NagiosHostPeer::doSelect($c);
     if (count($matchedHosts)) {
         foreach ($matchedHosts as $host) {
             $this->searchResults['hosts'][$host->getId()] = $host;
             $this->searchCount++;
         }
     }
     // Hostgroups: name, alias
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosHostgroupPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(nagiosHostgroupPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosHostgroupPeer::NAME);
     $matchedHostgroups = NagiosHostgroupPeer::doSelect($c);
     if (count($matchedHostgroups)) {
         foreach ($matchedHostgroups as $hostgroup) {
             $this->searchResults['hostgroups'][$hostgroup->getId()] = $hostgroup;
             $this->searchCount++;
         }
     }
     // Host Templates: name, description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosHostTemplatePeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosHostTemplatePeer::DESCRIPTION, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosHostTemplatePeer::NAME);
     $matchedTemplates = NagiosHostTemplatePeer::doSelect($c);
     if (count($matchedTemplates)) {
         foreach ($matchedTemplates as $template) {
             $this->searchResults['host_templates'][$template->getId()] = $template;
             $this->searchCount++;
         }
     }
     // Services: description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosServicePeer::DESCRIPTION, "%" . $text . "%", Criteria::LIKE);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosServicePeer::DESCRIPTION);
     $matchedServices = NagiosServicePeer::doSelect($c);
     if (count($matchedServices)) {
         foreach ($matchedServices as $service) {
             $this->searchResults['services'][$service->getId()] = $service;
             $this->searchCount++;
         }
     }
     // Servicegroups: name, alias
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosServiceGroupPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosServiceGroupPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosServiceGroupPeer::NAME);
     $matchedServicegroups = NagiosServiceGroupPeer::doSelect($c);
     if (count($matchedServicegroups)) {
         foreach ($matchedServicegroups as $servicegroup) {
             $this->searchResults['servicegroups'][$servicegroup->getId()] = $servicegroup;
             $this->searchCount++;
         }
     }
     // Service Templates: name, description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosServiceTemplatePeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosServiceTemplatePeer::DESCRIPTION, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosServiceTemplatePeer::NAME);
     $matchedTemplates = NagiosServiceTemplatePeer::doSelect($c);
     if (count($matchedTemplates)) {
         foreach ($matchedTemplates as $template) {
             $this->searchResults['service_templates'][$template->getId()] = $template;
             $this->searchCount++;
         }
     }
     // Service Templates: name, description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosContactPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosContactPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c3 = $c->getNewCriterion(NagiosContactPeer::EMAIL, "%" . $text . "%", Criteria::LIKE);
     $c2->addOr($c3);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosContactPeer::NAME);
     $matchedContacts = NagiosContactPeer::doSelect($c);
     if (count($matchedContacts)) {
         foreach ($matchedContacts as $contact) {
             $this->searchResults['contacts'][$contact->getId()] = $contact;
             $this->searchCount++;
         }
     }
     // ContactGroups: name, alias
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosContactGroupPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosContactGroupPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosContactGroupPeer::NAME);
     $matchedContactgroups = NagiosContactGroupPeer::doSelect($c);
     if (count($matchedContactgroups)) {
         foreach ($matchedContactgroups as $contactgroup) {
             $this->searchResults['contactgroups'][$contactgroup->getId()] = $contactgroup;
             $this->searchCount++;
         }
     }
     // Timeperiod: name, alias
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosTimeperiodPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosTimeperiodPeer::ALIAS, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosTimeperiodPeer::NAME);
     $matchedPeriods = NagiosTimeperiodPeer::doSelect($c);
     if (count($matchedPeriods)) {
         foreach ($matchedPeriods as $period) {
             $this->searchResults['timeperiods'][$period->getId()] = $period;
             $this->searchCount++;
         }
     }
     // Command: name, description
     $c = new Criteria();
     $c1 = $c->getNewCriterion(NagiosCommandPeer::NAME, "%" . $text . "%", Criteria::LIKE);
     $c2 = $c->getNewCriterion(NagiosCommandPeer::DESCRIPTION, "%" . $text . "%", Criteria::LIKE);
     $c1->addOr($c2);
     $c->add($c1);
     $c->setIgnoreCase(true);
     $c->addAscendingOrderByColumn(NagiosCommandPeer::NAME);
     $matchedCommands = NagiosCommandPeer::doSelect($c);
     if (count($matchedCommands)) {
         foreach ($matchedCommands as $command) {
             $this->searchResults['commands'][$command->getId()] = $command;
             $this->searchCount++;
         }
     }
 }