2012-04-15 17:39:49 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Init owncloud
|
2012-05-04 19:19:25 +04:00
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::checkAppEnabled('tasks');
|
2012-07-17 13:52:11 +04:00
|
|
|
OCP\JSON::callCheck();
|
2012-04-15 17:39:49 +04:00
|
|
|
|
|
|
|
$id = $_POST['id'];
|
2012-04-17 19:32:21 +04:00
|
|
|
$property = $_POST['type'];
|
2012-04-15 17:39:49 +04:00
|
|
|
$vcalendar = OC_Calendar_App::getVCalendar( $id );
|
|
|
|
|
|
|
|
$vtodo = $vcalendar->VTODO;
|
2012-04-17 19:32:21 +04:00
|
|
|
switch($property) {
|
|
|
|
case 'summary':
|
|
|
|
$summary = $_POST['summary'];
|
|
|
|
$vtodo->setString('SUMMARY', $summary);
|
|
|
|
break;
|
2012-04-21 01:37:42 +04:00
|
|
|
case 'description':
|
|
|
|
$description = $_POST['description'];
|
|
|
|
$vtodo->setString('DESCRIPTION', $description);
|
|
|
|
break;
|
2012-04-27 22:26:12 +04:00
|
|
|
case 'location':
|
|
|
|
$location = $_POST['location'];
|
|
|
|
$vtodo->setString('LOCATION', $location);
|
|
|
|
break;
|
2012-04-23 20:03:19 +04:00
|
|
|
case 'categories':
|
|
|
|
$categories = $_POST['categories'];
|
|
|
|
$vtodo->setString('CATEGORIES', $categories);
|
|
|
|
break;
|
2012-04-20 20:16:39 +04:00
|
|
|
case 'due':
|
|
|
|
$due = $_POST['due'];
|
2012-04-21 00:56:59 +04:00
|
|
|
$due_date_only = $_POST['date'];
|
|
|
|
$type = null;
|
2012-04-20 20:16:39 +04:00
|
|
|
if ($due != 'false') {
|
|
|
|
try {
|
2012-07-21 02:45:13 +04:00
|
|
|
$timezone = OC_Calendar_App::getTimezone();
|
2012-04-20 20:16:39 +04:00
|
|
|
$timezone = new DateTimeZone($timezone);
|
|
|
|
$due = new DateTime('@'.$due);
|
|
|
|
$due->setTimezone($timezone);
|
2012-04-21 00:56:59 +04:00
|
|
|
$type = Sabre_VObject_Element_DateTime::LOCALTZ;
|
|
|
|
if ($due_date_only) {
|
|
|
|
$type = Sabre_VObject_Element_DateTime::DATE;
|
|
|
|
}
|
2012-04-20 20:16:39 +04:00
|
|
|
} catch (Exception $e) {
|
2012-05-04 19:19:25 +04:00
|
|
|
OCP\JSON::error(array('data'=>array('message'=>OC_Task_App::$l10n->t('Invalid date/time'))));
|
2012-04-20 20:16:39 +04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
2012-04-21 00:56:59 +04:00
|
|
|
$vtodo->setDateTime('DUE', $due, $type);
|
2012-04-20 20:16:39 +04:00
|
|
|
break;
|
2012-04-17 19:32:21 +04:00
|
|
|
case 'complete':
|
|
|
|
$checked = $_POST['checked'];
|
|
|
|
OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null);
|
|
|
|
break;
|
|
|
|
default:
|
2012-05-04 19:19:25 +04:00
|
|
|
OCP\JSON::error(array('data'=>array('message'=>'Unknown type')));
|
2012-04-17 19:32:21 +04:00
|
|
|
exit();
|
|
|
|
}
|
2012-04-15 17:39:49 +04:00
|
|
|
OC_Calendar_Object::edit($id, $vcalendar->serialize());
|
|
|
|
|
2012-07-21 02:45:13 +04:00
|
|
|
$user_timezone = OC_Calendar_App::getTimezone();
|
2012-04-15 17:39:49 +04:00
|
|
|
$task_info = OC_Task_App::arrayForJSON($id, $vtodo, $user_timezone);
|
2012-05-04 19:19:25 +04:00
|
|
|
OCP\JSON::success(array('data' => $task_info));
|