/** * Gets an array of NagiosService objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this NagiosTimeperiod has previously been saved, it will retrieve * related NagiosServicesRelatedByNotificationPeriod from storage. If this NagiosTimeperiod is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array NagiosService[] * @throws PropelException */ public function getNagiosServicesRelatedByNotificationPeriod($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(NagiosTimeperiodPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collNagiosServicesRelatedByNotificationPeriod === null) { if ($this->isNew()) { $this->collNagiosServicesRelatedByNotificationPeriod = array(); } else { $criteria->add(NagiosServicePeer::NOTIFICATION_PERIOD, $this->id); NagiosServicePeer::addSelectColumns($criteria); $this->collNagiosServicesRelatedByNotificationPeriod = NagiosServicePeer::doSelect($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 the collection. $criteria->add(NagiosServicePeer::NOTIFICATION_PERIOD, $this->id); NagiosServicePeer::addSelectColumns($criteria); if (!isset($this->lastNagiosServiceRelatedByNotificationPeriodCriteria) || !$this->lastNagiosServiceRelatedByNotificationPeriodCriteria->equals($criteria)) { $this->collNagiosServicesRelatedByNotificationPeriod = NagiosServicePeer::doSelect($criteria, $con); } } } $this->lastNagiosServiceRelatedByNotificationPeriodCriteria = $criteria; return $this->collNagiosServicesRelatedByNotificationPeriod; }
/** * 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(NagiosServicePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(NagiosServicePeer::DATABASE_NAME); $criteria->add(NagiosServicePeer::ID, $pks, Criteria::IN); $objs = NagiosServicePeer::doSelect($criteria, $con); } return $objs; }
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++; } } }
/** * Gets an array of NagiosService objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this NagiosCommand has previously been saved, it will retrieve * related NagiosServicesRelatedByEventHandler from storage. If this NagiosCommand is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array NagiosService[] * @throws PropelException */ public function getNagiosServicesRelatedByEventHandler($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(NagiosCommandPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collNagiosServicesRelatedByEventHandler === null) { if ($this->isNew()) { $this->collNagiosServicesRelatedByEventHandler = array(); } else { $criteria->add(NagiosServicePeer::EVENT_HANDLER, $this->id); NagiosServicePeer::addSelectColumns($criteria); $this->collNagiosServicesRelatedByEventHandler = NagiosServicePeer::doSelect($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 the collection. $criteria->add(NagiosServicePeer::EVENT_HANDLER, $this->id); NagiosServicePeer::addSelectColumns($criteria); if (!isset($this->lastNagiosServiceRelatedByEventHandlerCriteria) || !$this->lastNagiosServiceRelatedByEventHandlerCriteria->equals($criteria)) { $this->collNagiosServicesRelatedByEventHandler = NagiosServicePeer::doSelect($criteria, $con); } } } $this->lastNagiosServiceRelatedByEventHandlerCriteria = $criteria; return $this->collNagiosServicesRelatedByEventHandler; }
</table> <br /> <br /> [ <a href="add_dependency.php?hostgroup_id=<?php echo $_GET['id']; ?> ">Create A New Dependency For This Hostgroup</a> ] </td> </tr> </table> <?php } else { if ($_GET['section'] == 'services') { $c = new Criteria(); $c->add(NagiosServicePeer::HOSTGROUP, $_GET['id']); $hostgroupServiceList = NagiosServicePeer::doSelect($c); $numOfServices = count($hostgroupServiceList); ?> <table width="100%" border="0"> <tr> <td width="100" align="center" valign="top"> <img src="<?php echo $path_config['image_root']; ?> services.gif" /> </td> <td valign="top"> <table width="100%" align="center" cellspacing="0" cellpadding="2" border="0"> <tr class="altTop"> <td colspan="2">Services Explicitly Linked to This Hostgroup:</td> </tr>