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; }
} 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']); $membership = NagiosHostContactgroupPeer::doSelectOne($c); if ($membership) { $error = "That contact group already exists in that list!"; } else { $tempGroup = NagiosContactGroupPeer::retrieveByPk($_POST['host_manage']['contactgroup_add']['contactgroup_id']); if ($tempGroup) { $membership = new NagiosHostContactgroup(); $membership->setHost($_GET['id']); $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.";
/** * 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 NagiosHostContactgroup $value A NagiosHostContactgroup object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(NagiosHostContactgroup $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }