Location: PHPKode > projects > ConPortal > conportal/redirects/shifts.php
<?php
/*
 *  ConPortal - Pomona College ITS scheduling appplication
 *  Copyright (C) 2005-2006  Pomona College
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of version 2 of the GNU General Public License
 *  as published by the Free Software Foundation.
 *
 *  This program 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 this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
require_once('../standard.php');
check_auth();

$message = "";
// Get message if one exists
if (isset($_POST['email_message']))
	$message = $_POST['email_message'];

// Look through all $_POST variables and take the appropriate action for each
foreach ($_POST as $key => $value)
{
	$arr = explode('_', $key);
	$shiftPid = intval($arr[0]);
	$timestamp = intval($arr[1]);
	$action = intval($value);
	if ($shiftPid != 0 and $timestamp != 0 and $action != 0)
	{
		// Check for a corresponding "user" posted variable
		$user = $_SESSION['pid'];
		if (isset($_POST["{$shiftPid}_user"]) and checkPerm($_SESSION, "shifts"))
			$user = $_POST["{$shiftPid}_user"];
		
		//var_dump($message);
		// Decide which action to take
		switch ($action)
		{
			case ACTION_PERM_TAKE:
				perm_take_shift($shiftPid, $timestamp, $user, $message);
				break;
			case ACTION_PERM_DROP:
				perm_drop_shift($shiftPid, $timestamp, $user, $message);
				break;
			case ACTION_TEMP_TAKE:
				temp_take_shift($shiftPid, $timestamp, $user, $message);
				break;
			case ACTION_TEMP_DROP:
				temp_drop_shift($shiftPid, $timestamp, $user, $message);
				break;
			default:
				$_SESSION['error'] = true;
				$_SESSION['errorArray'][] = "Unknown shift action: $action";
		}
	}
}

header("Location: " . BASE_URL . "show_shifts.php");

?>
Return current item: ConPortal