2011-09-12 19:28:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Init owncloud
|
2012-05-04 15:19:25 +00:00
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::checkAppEnabled('tasks');
|
2011-09-12 19:28:28 +00:00
|
|
|
|
2012-05-04 15:19:25 +00:00
|
|
|
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
|
2012-05-05 16:47:26 +00:00
|
|
|
$first_calendar = reset($calendars);
|
|
|
|
$cid = $first_calendar['id'];
|
2011-09-12 19:28:28 +00:00
|
|
|
|
2012-06-09 12:32:51 +00:00
|
|
|
$input = $_POST['text'];
|
2012-04-23 20:13:35 +00:00
|
|
|
$request = array();
|
|
|
|
$request['summary'] = $input;
|
|
|
|
$request["categories"] = null;
|
|
|
|
$request['priority'] = null;
|
|
|
|
$request['percent_complete'] = null;
|
|
|
|
$request['completed'] = null;
|
|
|
|
$request['location'] = null;
|
|
|
|
$request['due'] = null;
|
|
|
|
$request['description'] = null;
|
|
|
|
$vcalendar = OC_Task_App::createVCalendarFromRequest($request);
|
2011-09-12 19:28:28 +00:00
|
|
|
$id = OC_Calendar_Object::add($cid, $vcalendar->serialize());
|
|
|
|
|
2012-05-04 18:20:37 +00:00
|
|
|
$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
|
2012-03-08 21:26:54 +00:00
|
|
|
$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
|
|
|
|
|
2012-05-04 15:19:25 +00:00
|
|
|
OCP\JSON::success(array('task' => $task));
|