<?php
/*=====================================================================*\
|| ###################################################################
|| # Kalens [#]version[#]
|| # Copyright ©2002-[#]year[#] Iris Studios, Inc.
|| #
|| # 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; version [#]gpl[#] of the License.
|| #
|| # 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 Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/
define('SVN', '$Id$');
$cachetemplates = array(
'change_displays',
'calendar_manage_bit',
'select_option'
);
require_once('./global.php');
require_once('./includes/api_calendar.php');
require_once('./includes/functions_lists.php');
APIError(array(APIErrorHandler, 'UserErrorBox'));
// ###################################################################
if ($_POST['do'] == 'kill')
{
$calendar = new CalendarAPI($kalens);
$calendar->set('calendarid', $kalens->in['calendarid']);
$calendar->set_condition();
$calendar->delete();
}
// ###################################################################
if ($_REQUEST['do'] == 'delete')
{
$kalens->input_clean('calendarid', TYPE_UINT);
$message->confirm(_('Are you sure you want to delete the calendar and all of its events?'), 'calendar.php', 'kill', _('Delete'), 'calendar.php?do=edit&calendarid=' . $kalens->in['calendarid'], array('calendarid' => $kalens->in['calendarid']));
}
// ###################################################################
if ($_REQUEST['do'] == 'insert')
{
$calendar = new CalendarAPI($kalens);
$calendar->set('userid', $kalens->userinfo['userid']);
$calendar->set('name', $kalens->in['name']);
$calendar->set('description', $kalens->in['description']);
if (!$message->hasErrors())
{
$calendar->insert();
}
else
{
echo $message->errorBox();
}
}
// ###################################################################
if ($_REQUEST['do'] == 'add')
{
eval('$template->flush("' . $template->fetch('calendar_add') . '");');
}
// ###################################################################
if ($_POST['do'] == 'update')
{
$calendar = new CalendarAPI($kalens);
$calendar->set('calendarid', $kalens->in['calendarid']);
$calendar->set_condition();
$calendar->fetch();
$calendar->set('name', $kalens->in['name']);
$calendar->set('description', $kalens->in['description']);
if (!$message->hasErrors())
{
$calendar->update();
}
else
{
echo $message->errorBox();
}
}
// ###################################################################
if ($_REQUEST['do'] == 'edit')
{
if ($calendar == null)
{
APIError(array(APIErrorHandler, 'UserError'));
$calendar = new CalendarAPI($kalens);
$calendar->set('calendarid', $kalens->in['calendarid']);
$calendar->set_condition();
$calendar->fetch();
$calendar->values = $calendar->objdata;
}
eval('$template->flush("' . $template->fetch('calendar_edit') . '");');
}
// ###################################################################
if ($_REQUEST['do'] == 'modify')
{
$calendarsFetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "calendar ORDER BY name ASC");
while ($calendar = $db->fetch_array($calendarsFetch))
{
eval('$calendars .= "' . $template->fetch('calendar_manage_bit') . '";');
}
$month = $kalens->input_clean('month', TYPE_UINT);
$year = $kalens->input_clean('year', TYPE_UINT);
eval('$template->flush("' . $template->fetch('change_displays') . '");');
}
// ###################################################################
if ($_REQUEST['do'] == 'changemonth')
{
$select['months'] = ConstructMonthList(date('m'));
$select['years'] = ConstructYearList(date('Y'));
eval('$template->flush("' . $template->fetch('change_month') . '");');
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>