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."); }
} } 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.";