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.");
 }
 public function import()
 {
     $job = $this->getEngine()->getJob();
     $config = $this->getEngine()->getConfig();
     $segment = $this->getSegment();
     $values = $segment->getValues();
     $fileName = $segment->getFilename();
     $servicegroup = new NagiosServiceGroup();
     if (isset($values['members'])) {
         $members = explode(",", $values['members'][0]['value']);
         for ($counter = 0; $counter < count($members); $counter += 2) {
             // Get Service
             $service = NagiosServicePeer::getByHostAndDescription($members[$counter], $members[$counter + 1]);
             $servicegroup->addService($service);
             $service->clearAllReferences(true);
         }
     }
     foreach ($values as $key => $entries) {
         foreach ($entries as $entry) {
             // Skips
             $value = $entry['value'];
             $lineNum = $entry['line'];
             if ($key == 'members') {
                 // Already did it above
                 continue;
             }
             // Okay, let's check that the method DOES exist
             if (!method_exists($servicegroup, $this->fieldMethods[$key])) {
                 $job->addError("Method " . $this->fieldMethods[$key] . " does not exist for variable: " . $key . " on line " . $lineNum . " in file " . $fileName);
                 if (!$config->getVar('continue_error')) {
                     return false;
                 }
             } else {
                 call_user_method($this->fieldMethods[$key], $servicegroup, $value);
             }
         }
     }
     $servicegroup->save();
     $servicegroup->clearAllReferences(true);
     $job->addNotice("NagiosServiceGroupImporter finished importing service group: " . $servicegroup->getName());
     return true;
 }
 /**
  * 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;
 }
Example #4
0
        unset($serviceGroup);
        unset($_GET['id']);
    }
}
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'] == '') {
 /**
  * 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;
     }
 }