Example #1
0
if (isset($_POST['request'])) {
    if ($_POST['request'] == 'add_servicegroup') {
        // Check for pre-existing contact with same name
        if ($lilac->servicegroup_exists($_POST['servicegroup_name'])) {
            $error = "A service group with that name already exists!";
        } else {
            // Field Error Checking
            if ($_POST['servicegroup_name'] == '' || $_POST['alias'] == '') {
                $error = "Fields shown are required and cannot be left blank.";
            } else {
                // All is well for error checking, add the servicegroup into the db.
                $serviceGroup = new NagiosServiceGroup();
                $serviceGroup->setName($_POST['servicegroup_name']);
                $serviceGroup->setAlias($_POST['alias']);
                $serviceGroup->save();
                header("Location: servicegroups.php?id=" . $serviceGroup->getId());
                die;
            }
        }
    } else {
        if ($_POST['request'] == 'modify_servicegroup') {
            if ($_POST['servicegroup_name'] != $serviceGroup->getName() && $lilac->servicegroup_exists($_POST['servicegroup_name'])) {
                $error = "A service group with that name already exists!";
            } else {
                // Error check!
                // Field Error Checking
                if ($_POST['servicegroup_name'] == '' || $_POST['alias'] == '') {
                    $addError = 1;
                    $error = "Fields shown are required and cannot be left blank.";
                } else {
                    // All is well for error checking, modify the group.
 /**
  * Declares an association between this object and a NagiosServiceGroup object.
  *
  * @param      NagiosServiceGroup $v
  * @return     NagiosServiceGroupMember The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setNagiosServiceGroup(NagiosServiceGroup $v = null)
 {
     if ($v === null) {
         $this->setServiceGroup(NULL);
     } else {
         $this->setServiceGroup($v->getId());
     }
     $this->aNagiosServiceGroup = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the NagiosServiceGroup object, it will not be re-added.
     if ($v !== null) {
         $v->addNagiosServiceGroupMember($this);
     }
     return $this;
 }
 /**
  * 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      NagiosServiceGroup $value A NagiosServiceGroup object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(NagiosServiceGroup $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }