Exemplo n.º 1
0
         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 {
     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
Exemplo n.º 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(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;
 }