summaryrefslogtreecommitdiffstats
path: root/apps/tasks/ajax/addtask.php
blob: 9d62a5fe707720cf1a264c5f357b922f6b476bbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

// Init owncloud
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks');

$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true);
$cid = reset($calendars)['id'];

$input = $_GET['text'];
$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);
$id = OC_Calendar_Object::add($cid, $vcalendar->serialize());

$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('task' => $task));