getTimeperiodId() != $timeperiod->getId()) { $error = "That entry either does not exist or does not belong to that timeperiod."; } else { $tempEntry->delete(); $success = "Entry deleted."; } } if($_GET['request'] == "delete" && $_GET['section'] == "exclusions") { $exclusion = NagiosTimeperiodExcludePeer::retrieveByPK($_GET['exclude_id']); if(!$exclusion) { $error = "That exclusion does not exist."; } else { if($exclusion->getNagiosTimeperiodRelatedByTimeperiodId()->getId() != $timeperiod->getId()) { $error = "That exclusion does not belong to this timeperiod."; } else { $exclusion->delete(); $success = "Exclusion deleted."; } } } } if(isset($_POST['request'])) { if($_POST['request'] == 'modify_period') { if($_POST['timeperiod_manage']['timeperiod_name'] != $timeperiod->getName() && $lilac->period_exists($_POST['timeperiod_manage']['timeperiod_name'])) { $error = "A time period with that name already exists!"; } else { // All is well for error checking, modify the timeperiod. $timeperiod->setName($_POST['timeperiod_manage']['timeperiod_name']); $timeperiod->setAlias($_POST['timeperiod_manage']['alias']); $timeperiod->save(); $success = "Time period modified."; } } else if($_POST['request'] == 'add_entry') { if(empty($_POST['entry']) || empty($_POST['value'])) { $error = "Both fields must be filled in."; } else { // We should really do some error checking here on valid values $entry = trim($_POST['entry']); /*@todo DO ERROR CHECKING HERE*/ $value = trim($_POST['value']); $values = explode(",", $value); if(count($values) == 0 && $value != '') { $error = "Entry value must be comma-delimited list of proper values."; } else { $err = false; if($value != '') { foreach($values as $val) { if(!preg_match("/\d\d:\d\d-\d\d:\d\d/", trim($val))) { $err = true; } } } if($err) { $error = "Entry value must be comma-delimited list of proper values."; } else { // Check for existing entry with that name! $c = new Criteria(); $c->add(NagiosTimeperiodEntryPeer::TIMEPERIOD_ID, $timeperiod->getId()); $c->add(NagiosTimeperiodEntryPeer::ENTRY, $entry); $foundEntry = NagiosTimeperiodEntryPeer::doSelectOne($c); if($foundEntry) { $error = "That entry already exists. Remove it then add it with the new value."; } else { // Okay, let's add. $newEntry = new NagiosTimeperiodEntry(); $newEntry->setTimeperiodId($timeperiod->getId()); $newEntry->setEntry($entry); $newEntry->setValue($value); $newEntry->save(); $success = "Entry added."; $entry = ''; $value = ''; } } } } } else if($_POST['request'] == 'exclusion_add') { // first hceck to see if the exclusion exists. $c = new Criteria(); $c->add(NagiosTimeperiodExcludePeer::TIMEPERIOD_ID, $timeperiod->getId()); $c->add(NagiosTimeperiodExcludePeer::EXCLUDED_TIMEPERIOD, $_POST['timeperiod_manage']['exclusion_add']['timeperiod_id']); $tempExclusion = NagiosTimeperiodExcludePeer::doSelectOne($c); if($tempExclusion) { $error = "That exclusion already exists."; } else { $targetTimeperiod = NagiosTimeperiodPeer::retrieveByPK($_POST['timeperiod_manage']['exclusion_add']['timeperiod_id']); if(!$targetTimeperiod) { $error = "That timeperiod is not in the system."; } else { $tempExclusion = new NagiosTimeperiodExclude(); $tempExclusion->setNagiosTimeperiodRelatedByExcludedTimeperiod($targetTimeperiod); $tempExclusion->setNagiosTimeperiodRelatedByTimeperiodId($timeperiod); $tempExclusion->save(); $success = "Exclusion added."; } } } } // Create subnav $subnav = array( 'general' => 'General', 'entries' => 'Time Entries', 'exclusions' => 'Exclusions' ); print_header("Time Period Editor"); ?> getName(), "100%"); print_subnav($subnav, $_GET['section'], "section", $_SERVER['PHP_SELF'] . "?timeperiod_id=" . $timeperiod->getId()); if($_GET['section'] == 'general') { ?>
Time Period Name:

element_desc("timeperiod_name", "nagios_timeperiods_desc"); ?>

Description:

element_desc("alias", "nagios_timeperiods_desc"); ?>

Delete  Cancel  Cancel

Time Period Entries:
add(NagiosTimeperiodEntryPeer::TIMEPERIOD_ID, $timeperiod->getId()); $timeperiodEntries = NagiosTimeperiodEntryPeer::doSelect($c); if(!count($timeperiodEntries)) { ?>
No entries defined for this timeperiod.
  Weekday / Exception Time Ranges
[ Delete ] getEntry();?> getValue();?>
Add A New Entry:
Weekday / Exception:
element_desc("timeperiod_weekday_exception", "nagios_timeperiods_desc"); ?>

Value:
element_desc("timeperiod_value", "nagios_timeperiods_desc"); ?>
getNagiosTimeperiodExcludesRelatedByTimeperiodId(); // This is our list of exclusions $timeperiods = NagiosTimePeriodPeer::doSelect(new Criteria()); ?>
getNagiosTimeperiodRelatedByExcludedTimeperiod(); if($counter % 2) { ?>
Excluded Time Periods:
 [ Delete ] getName();?>: getAlias();?>


Add New Timeperiod Exclusion: getId()));?>
element_desc("exclusion", "nagios_timeperiods_desc"); ?>