Source for file editmodes.php
Documentation is available at editmodes.php
* This file displays the UARS Day modes editing interface.
* This file is part of HRDIODB.
* HRDIODB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* HRDIODB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with HRDIODB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/** Configuration file */
require_once("conf.php");
/** Debugging functions */
require_once("debugging.php");
require_once("session_class.php");
require_once("uars_day_class.php");
/** HRDI database class */
require_once("hrdi_db_class.php");
require_once("mode_class.php");
require_once("user_class.php");
require_once("common_class.php");
// Create class instances
$user = new user($hdb, $session);
// Make sure we're authenticated
if (!$user->authenticated()) {
$session->set_var("page", $_SERVER['REQUEST_URI']);
// Redirect to login page
$page_title = "Editing Day Modes";
require_once("header.php");
// Make sure we're an admin user
if (!$user->is_admin()) {
error("You need to be an admin to edit mode data");
require_once("footer.php");
// Get the UARS day from GET or POST data
$uars_day = isset ($_POST['UARS_Day']) ? $_POST['UARS_Day'] : @$_GET['uars_day'];
error("UARS day is not valid");
require_once("footer.php");
// Figure out the action, if any
$action = isset ($_POST['action']) ? $_POST['action'] : @$_GET['action'];
require_once("footer.php");
// Figure out the mode id, if any
$id = isset ($_POST['id']) ? $_POST['id'] : @$_GET['id'];
error("Mode ID is not valid");
require_once("footer.php");
// Check to see if we're performing an action
if (isset ($_POST['add'])) {
// Unset things we don't want
if ($mode->add($_POST)) {
} else if (isset ($_POST['update'])) {
// Unset things we don't want
// Update an existing mode
$mode = new mode($hdb, $_POST['ID']);
if ($mode->update($_POST)) {
} else if (isset ($_POST['delete_yes'])) {
// Unset things we don't want
unset ($_POST['delete_yes']);
// Delete an existing mode
$mode = new mode($hdb, $_POST['ID']);
if ($mode->delete($_POST)) {
} else if (isset ($_POST['delete_no'])) {
// Create a UARS day class instance
// Display the mode table
<td class="label" colspan="7">Modes for UARS Day <?php print $day->day ?></td>
<td class="label_nb" align="right"><a href="day.php?uars_day= <?php print $day->day?>">View Day</a></td>
<?php foreach ($day->modes as $m) { ?>
<td> <?php print $m['Process_ID']?></td>
<td> <?php print $m['Azimuth1']?></td>
<td> <?php print $m['Azimuth2']?></td>
<td> <?php print $m['Azimuth3']?></td>
<td> <?php print $m['Azimuth4']?></td>
<td> <?php print $m['Description']?></td>
<td> <?php print ($m['Planned'] ? "Yes" : "No")?></td>
<a href=" <?php print "{ $_SERVER['PHP_SELF']}?uars_day={$day->day}&action=edit&id={$m['ID']}"?>"><img src="images/edit.png" border="0" alt="Edit" title="Edit Mode" align="center"></a>
<a href=" <?php print "{ $_SERVER['PHP_SELF']}?uars_day={$day->day}&action=delete&id={$m['ID']}"?>"><img src="images/delete.png" border="0" alt="Delete" title="Delete Mode" align="center"></a>
<a href=" <?php print "{ $_SERVER['PHP_SELF']}?uars_day={$day->day}&action=add"?>"><img src="images/add.png" border="0" alt="Add" title="Add mode" align="middle" align="center"> Add a mode</a>
// Create a mode object for a new or an existing mode
} else if (($action == 'edit') || ($action == 'delete')) {
$mode = new mode($hdb, $id);
// If we're performing an action, we need to show the action table
if (($action == 'add') || ($action == 'edit') || ($action == 'delete')) {
<form method="post" action=" <?php print "{ $_SERVER['PHP_SELF']}?uars_day={$day->day}"?>">
<input type="hidden" name="UARS_Day" value=" <?php print $uars_day?>">
<input type="hidden" name="action" value=" <?php print $action?>">
<input type="hidden" name="id" value=" <?php print $id?>">
// Add and edit actions can use the same table
if (($action == 'add') || ($action == 'edit')) {
<td>Pid / Description</td>
<select name="Process_ID">
foreach ($mode->pids as $pid) {
$pids[$pid['Pid']] = "{ $pid['Pid']} - {$pid['Description']}";
<td><input type="text" size="4" maxlength="4" name="Azimuth1"
value=" <?php print common::get_value('Azimuth1', $_POST, $mode->data)?>"></td>
<td><input type="text" size="4" maxlength="4" name="Azimuth2"
value=" <?php print common::get_value('Azimuth2', $_POST, $mode->data)?>"></td>
<td><input type="text" size="4" maxlength="4" name="Azimuth3"
value=" <?php print common::get_value('Azimuth3', $_POST, $mode->data)?>"></td>
<td><input type="text" size="4" maxlength="4" name="Azimuth4"
value=" <?php print common::get_value('Azimuth4', $_POST, $mode->data)?>"></td>
<input id="Planned_yes" type="radio" name="Planned" value="1"
if (!isset ($mode->data['Planned']) || common::get_value('Planned', $_POST, $mode->data)) {
> <label for="Planned_yes">Yes</label>
<input id="Planned_no" type="radio" name="Planned" value="0"
if (isset ($mode->data['Planned']) && !common::get_value('Planned', $_POST, $mode->data)) {
> <label for="Planned_no">No</label>
<td class="label" colspan="6" align="right">
<?php if ($action == 'add') { ?>
<input type="submit" name="add" value="Add Mode">
<input type="hidden" name="ID" value=" <?php print $mode->data['ID']?>">
<input type="submit" name="update" value="Update Mode">
// Delete action requires a different table
} else if ($action == 'delete') {
<input type="hidden" name="ID" value=" <?php print $mode->data['ID']?>">
<td>Pid / Description</td>
<td> <?php print $mode->data['Process_ID']?> - <?php print $mode->data['Description']?></td>
<td> <?php print $mode->data['Azimuth1']?></td>
<td> <?php print $mode->data['Azimuth2']?></td>
<td> <?php print $mode->data['Azimuth3']?></td>
<td> <?php print $mode->data['Azimuth4']?></td>
<td> <?php print ($mode->data['Planned'] ? "Yes" : "No")?></td>
<td class="label" colspan="6" align="center">
Are you sure you want to delete this mode?
<input type="submit" name="delete_yes" value="Yes">
<input type="submit" name="delete_no" value="No">
// Let's end what we started
if (($action == 'add') || ($action == 'edit') || ($action == 'delete')) {
// Include the page footer
require_once("footer.php");
|