<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003, 2005 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program 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, or (at your option) any
// later version.
// 
// 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 program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// -----------------------------------------------------------------------

include_once "inc/header.inc.php";

$menu_section = "schedule"; //sets menu in default template



require_once($c_node['dir']['class_path'] . 'Schedule.class.php');
$schedule = new Schedule($db, null, $date, $file);
$schedule->schedule_config = $c_node['schedule'];


if (isset($_REQUEST['schedule_id'])) {
	$schedule->schedule_id = $_REQUEST['schedule_id'];
}

//check schedule types - they are either tasks or events
if (isset($_REQUEST['schedule_type_id'])) {
	//check it is valid
	foreach($c_node['schedule']['type'] as $key => $i):
		if ($i == $_REQUEST['schedule_type_id']) {
		    $output_schedule['schedule_type_id'] = $_REQUEST['schedule_type_id'];
			break;
		}
	endforeach;
}

if (!isset($output_schedule['schedule_type_id'])) {
	$output_schedule['schedule_type_id'] = $c_node['schedule']['type']['event'];
}

$schedule->schedule_type_id = $output_schedule['schedule_type_id'];


//append language setup
require_once($languageArrayPath . 'arr_schedule.lang.php');


//a schedule item can sit under a group
// if so we swap out menus and include group info
if (!empty($_REQUEST['group_id'])) { // page under group section
    //setup group
	$group_id = $_REQUEST['group_id'];
	include "inc/header_group.inc.php";
	require_once($languagePath . 'g_common.lang.php');
	
	//apply group to schedule
	$schedule->group_id = $group_id;
	$schedule->file = $file;
}
else {
	$schedule->user_id = $me['user_id'];
	require_once($languageArrayPath . 'arr_user.lang.php');
}

require_once($languageArrayPath . 'arr_language_name.lang.php');

?>
