/** * @NoAdminRequired */ public function getTasks() { $calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true); $user_timezone = \OC_Calendar_App::getTimezone(); $tasks = array(); foreach ($calendars as $calendar) { $calendar_tasks = \OC_Calendar_Object::all($calendar['id']); foreach ($calendar_tasks as $task) { if ($task['objecttype'] != 'VTODO') { continue; } if (is_null($task['summary'])) { continue; } $vtodo = Helper::parseVTODO($task['calendardata']); try { $task_data = Helper::arrayForJSON($task['id'], $vtodo, $user_timezone); $task_data['calendarid'] = $calendar['id']; $task_data['calendarcolor'] = $calendar['calendarcolor']; $tasks[] = $task_data; } catch (\Exception $e) { \OCP\Util::writeLog('tasks', $e->getMessage(), \OCP\Util::ERROR); } } } $result = array('data' => array('tasks' => $tasks)); $response = new JSONResponse(); $response->setData($result); return $response; }
public function getTask($taskID) { $object = \OC_Calendar_App::getEventObject($taskID); $user_timezone = \OC_Calendar_App::getTimezone(); $task = array(); if ($object['objecttype'] == 'VTODO' && !is_null($object['summary'])) { $vtodo = Helper::parseVTODO($object['calendardata']); try { $task_data = Helper::arrayForJSON($object['id'], $vtodo, $user_timezone, $object['calendarid']); $task[] = $task_data; } catch (\Exception $e) { \OCP\Util::writeLog('tasks', $e->getMessage(), \OCP\Util::ERROR); } } $result = array('data' => array('tasks' => $task)); $response = new JSONResponse(); $response->setData($result); return $response; }
/** * get task by id * * @param string $taskID * @return array * @throws \Exception */ public function get($taskID) { $object = \OC_Calendar_App::getEventObject($taskID); $user_timezone = \OC_Calendar_App::getTimezone(); $task = array(); if ($object['objecttype'] == 'VTODO' && !is_null($object['summary'])) { if ($vtodo = Helper::parseVTODO($object)) { $task_data = Helper::arrayForJSON($object['id'], $vtodo, $user_timezone, $object['calendarid']); $task[] = $task_data; } } return array('tasks' => $task); }