$success = "Updated Service Extended Information"; } else { if ($_POST['request'] == 'add_contact_command') { $c = new Criteria(); $c->add(NagiosServiceContactMemberPeer::SERVICE, $_GET['id']); $c->add(NagiosServiceContactMemberPeer::CONTACT, $_POST['service_manage']['contact_add']['contact_id']); $membership = NagiosServiceContactMemberPeer::doSelectOne($c); if ($membership) { $error = "That contact already exists in that list!"; } else { $tempContact = NagiosContactPeer::retrieveByPk($_POST['service_manage']['contact_add']['contact_id']); if ($tempContact) { $membership = new NagiosServiceContactMember(); $membership->setService($_GET['id']); $membership->setNagiosContact($tempContact); $membership->save(); $success = "New Service Template Contact Link added."; } else { $error = "That contact is not found."; } } } else { if ($_POST['request'] == 'add_contactgroup_command') { $c = new Criteria(); $c->add(NagiosServiceContactGroupMemberPeer::SERVICE, $_GET['id']); $c->add(NagiosServiceContactGroupMemberPeer::CONTACT_GROUP, $_POST['contactgroup_id']); $membership = NagiosServiceContactGroupMemberPeer::doSelectOne($c); if ($membership) { $error = "That contact group already exists in that list!"; } else { $tempGroup = NagiosContactGroupPeer::retrieveByPk($_POST['contactgroup_id']);
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(NagiosServiceContactMemberPeer::TEMPLATE, $this->getId()); $c->add(NagiosServiceContactMemberPeer::CONTACT, $contact->getId()); $relationship = NagiosServiceContactMemberPeer::doSelectOne($c); if ($relationship) { return false; } } $relationship = new NagiosServiceContactMember(); $relationship->setNagiosServiceTemplate($this); $relationship->setNagiosContact($contact); $relationship->save(); return true; }