$membership->setNagiosContactGroup($tempGroup); $membership->save(); $success = "New Host Contact Group Link added."; } } } else { if ($_POST['request'] == 'parent_add') { // Wants to add a parent $c = new Criteria(); $c->add(NagiosHostPeer::NAME, $_POST['parenthost']); $c->setIgnoreCase(true); $parentHost = NagiosHostPeer::doSelectOne($c); if (!$parentHost) { $error = "The host named " . $_POST['parenthost'] . " was not found."; } else { $tempParent = new NagiosHostParent(); $tempParent->setChildHost($host->getId()); $tempParent->setParentHost($parentHost->getId()); $tempParent->save(); $success = "Parent added"; } } } } } } if (isset($_GET['id'])) { // Load template. $host = NagiosHostPeer::retrieveByPK($_GET['id']); if (!$host) { header("Location: hosts.php");
$tempHost->setAddress($device->getAddress()); $tempHost->setName($device->getName()); $tempHost->setAlias($device->getDescription()); $tempHost->save(); // Now assign a template, if wanted $template = $device->getNagiosHostTemplate(); if (!empty($template)) { $inheritance = new NagiosHostTemplateInheritance(); $inheritance->setNagiosHost($tempHost); $inheritance->setNagiosHostTemplateRelatedByTargetTemplate($template); $inheritance->save(); } // Now parent $parent = $device->getNagiosHost(); if (!empty($parent)) { $parentRelationship = new NagiosHostParent(); $parentRelationship->setNagiosHostRelatedByChildHost($tempHost); $parentRelationship->setNagiosHostRelatedByParentHost($parent); $parentRelationship->save(); } $totalSuccess++; $device->delete(); } $success = $totalSuccess . " Device(s) Imported."; } } } } } print_header("AutoDiscovery"); if (isset($autodiscoveryJob)) {
function addParentByName($name) { $parentId = $this->getParentHost(); $c = new Criteria(); $c->add(NagiosHostPeer::NAME, $name); $c->setIgnoreCase(true); $host = NagiosHostPeer::doSelectOne($c); if (!$host) { return false; } if (empty($parentId)) { $this->setParentHost($host->getId()); return true; } // Okay, let's first see if there's a parent relationship around $id = $this->getId(); if (!empty($id)) { $c = new Criteria(); $c->add(NagiosHostParentPeer::CHILD_HOST_TEMPLATE, $this->getId()); $c->add(NagiosHostParentPeer::PARENT_HOST, $host->getId()); $relationship = NagiosHostParentPeer::doSelectOne($c); if ($relationship) { return false; } } // Okay, relationship doesn't exist, let's add it! $relationship = new NagiosHostParent(); $relationship->setNagiosHostTemplate($this); $relationship->setNagiosHostRelatedByParentHost($host); $relationship->save(); return true; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param NagiosHostParent $value A NagiosHostParent object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(NagiosHostParent $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }