Beispiel #1
0
         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']);
             if ($tempGroup) {
                 $membership = new NagiosServiceContactGroupMember();
                 $membership->setService($_GET['id']);
                 $membership->setNagiosContactGroup($tempGroup);
                 $membership->save();
                 $success = "New Service Contact Group Link added.";
             }
         }
     } else {
         if ($_POST['request'] == 'add_servicegroup_command') {
             $c = new Criteria();
Beispiel #2
0
 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(NagiosServiceContactGroupMemberPeer::TEMPLATE, $this->getId());
         $c->add(NagiosServiceContactGroupMemberPeer::CONTACT_GROUP, $contactgroup->getId());
         $relationship = NagiosServiceContactGroupMemberPeer::doSelectOne($c);
         if ($relationship) {
             return false;
         }
     }
     $relationship = new NagiosServiceContactGroupMember();
     $relationship->setNagiosServiceTemplate($this);
     $relationship->setNagiosContactGroup($contactgroup);
     $relationship->save();
     return true;
 }