nextcloud/apps/calendar/ajax/neweventform.php

50 lines
1.6 KiB
PHP
Raw Normal View History

2011-08-11 13:22:07 +04:00
<?php
2011-09-24 00:59:24 +04:00
/**
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
require_once('../../../lib/base.php');
2011-09-15 01:29:35 +04:00
$l10n = new OC_L10N('calendar');
2011-09-15 01:29:35 +04:00
2011-08-11 13:22:07 +04:00
if(!OC_USER::isLoggedIn()) {
2011-09-15 01:29:35 +04:00
die('<script type="text/javascript">document.location = oc_webroot;</script>');
2011-08-11 13:22:07 +04:00
}
OC_JSON::checkAppEnabled('calendar');
2011-09-15 01:29:35 +04:00
2011-10-25 21:57:20 +04:00
if (!isset($_POST['start'])){
OC_JSON::error();
die;
2011-09-15 01:29:35 +04:00
}
2011-10-25 21:57:20 +04:00
$start = $_POST['start'];
$end = $_POST['end'];
$allday = $_POST['allday'];
2011-09-15 01:29:35 +04:00
2011-10-25 21:57:20 +04:00
if (!$end){
$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', '60');
$end = $start + ($duration * 60);
}
$start = new DateTime('@'.$start);
$end = new DateTime('@'.$end);
$timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
2011-10-25 21:57:20 +04:00
$start->setTimezone(new DateTimeZone($timezone));
$end->setTimezone(new DateTimeZone($timezone));
2011-10-02 00:53:18 +04:00
2011-10-25 21:57:20 +04:00
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
2011-09-15 01:29:35 +04:00
$tmpl = new OC_Template('calendar', 'part.newevent');
2011-09-23 00:22:52 +04:00
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
2011-10-25 21:57:20 +04:00
$tmpl->assign('startdate', $start->format('d-m-Y'));
$tmpl->assign('starttime', $start->format('H:i'));
$tmpl->assign('enddate', $end->format('d-m-Y'));
$tmpl->assign('endtime', $end->format('H:i'));
2011-09-15 01:29:35 +04:00
$tmpl->assign('allday', $allday);
$tmpl->printpage();
?>