2011-09-12 19:28:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Init owncloud
|
|
|
|
require_once('../../../lib/base.php');
|
2011-10-06 19:21:38 +00:00
|
|
|
OC_JSON::checkLoggedIn();
|
|
|
|
OC_JSON::checkAppEnabled('tasks');
|
2011-09-12 19:28:28 +00:00
|
|
|
|
|
|
|
$cid = $_POST['id'];
|
2012-03-08 21:26:54 +00:00
|
|
|
$calendar = OC_Calendar_App::getCalendar( $cid );
|
2011-09-12 19:28:28 +00:00
|
|
|
|
2012-02-22 19:11:38 +00:00
|
|
|
$errors = OC_Task_App::validateRequest($_POST);
|
2011-09-13 20:44:15 +00:00
|
|
|
if (!empty($errors)) {
|
2011-10-06 19:21:38 +00:00
|
|
|
OC_JSON::error(array('data' => array( 'errors' => $errors )));
|
2011-09-13 20:44:15 +00:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2012-02-22 19:11:38 +00:00
|
|
|
$vcalendar = OC_Task_App::createVCalendarFromRequest($_POST);
|
2011-09-12 19:28:28 +00:00
|
|
|
$id = OC_Calendar_Object::add($cid, $vcalendar->serialize());
|
|
|
|
|
2012-02-22 19:11:38 +00:00
|
|
|
$priority_options = OC_Task_App::getPriorityOptions();
|
2011-09-12 19:28:28 +00:00
|
|
|
$tmpl = new OC_Template('tasks','part.details');
|
2011-09-13 20:44:15 +00:00
|
|
|
$tmpl->assign('priority_options', $priority_options);
|
|
|
|
$tmpl->assign('details',$vcalendar->VTODO);
|
2011-09-12 19:28:28 +00:00
|
|
|
$tmpl->assign('id',$id);
|
|
|
|
$page = $tmpl->fetchPage();
|
|
|
|
|
2012-03-08 21:26:54 +00:00
|
|
|
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
|
|
|
|
$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
|
|
|
|
|
|
|
|
OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task )));
|