} else { $host->setTwoDCoords(null); } if (isset($modifiedData['three_d_coords'])) { $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 {
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; }