/**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aNagiosService !== null) {
             if ($this->aNagiosService->isModified() || $this->aNagiosService->isNew()) {
                 $affectedRows += $this->aNagiosService->save($con);
             }
             $this->setNagiosService($this->aNagiosService);
         }
         if ($this->aNagiosServiceTemplate !== null) {
             if ($this->aNagiosServiceTemplate->isModified() || $this->aNagiosServiceTemplate->isNew()) {
                 $affectedRows += $this->aNagiosServiceTemplate->save($con);
             }
             $this->setNagiosServiceTemplate($this->aNagiosServiceTemplate);
         }
         if ($this->aNagiosServiceGroup !== null) {
             if ($this->aNagiosServiceGroup->isModified() || $this->aNagiosServiceGroup->isNew()) {
                 $affectedRows += $this->aNagiosServiceGroup->save($con);
             }
             $this->setNagiosServiceGroup($this->aNagiosServiceGroup);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = NagiosServiceGroupMemberPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = NagiosServiceGroupMemberPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += NagiosServiceGroupMemberPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 public function import()
 {
     $engine = $this->getEngine();
     $job = $engine->getJob();
     $job->addNotice("FruityServiceGroupImporter beginning to import Service Group Configuration.");
     // service groups
     foreach ($this->dbConn->query("SELECT * FROM nagios_servicegroups", PDO::FETCH_ASSOC) as $serviceGroup) {
         if (NagiosContactGroupPeer::getByName($serviceGroup['servicegroup_name'])) {
             $job->addNotice("Fruity Service Group Importer: Group " . $serviceGroup['servicegroup_name'] . " already exists.  Aborting it's import.");
             continue;
         }
         $newServiceGroup = new NagiosServiceGroup();
         $newServiceGroup->setName($serviceGroup['servicegroup_name']);
         $newServiceGroup->setAlias($serviceGroup['alias']);
         $newServiceGroup->save();
     }
     $job->addNotice("FruityServiceGroupImporter finished importing Service Group Configuration.");
 }
Example #3
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 {