Esempio n. 1
0
 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;
 }
Esempio n. 2
0
         $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 {
         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) {
 /**
  * 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      NagiosHostContactMember $value A NagiosHostContactMember object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(NagiosHostContactMember $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }