コード例 #1
0
ファイル: addtask.php プロジェクト: noci2012/owncloud
<?php

// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
OCP\JSON::callCheck();
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
$first_calendar = reset($calendars);
$cid = $first_calendar['id'];
$input = $_POST['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 = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
OCP\JSON::success(array('task' => $task));
コード例 #2
0
        $due_date_only = $_POST['date'];
        $type = null;
        if ($due != 'false') {
            try {
                $timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
                $timezone = new DateTimeZone($timezone);
                $due = new DateTime('@' . $due);
                $due->setTimezone($timezone);
                $type = Sabre_VObject_Element_DateTime::LOCALTZ;
                if ($due_date_only) {
                    $type = Sabre_VObject_Element_DateTime::DATE;
                }
            } catch (Exception $e) {
                OCP\JSON::error(array('data' => array('message' => OC_Task_App::$l10n->t('Invalid date/time'))));
                exit;
            }
        }
        $vtodo->setDateTime('DUE', $due, $type);
        break;
    case 'complete':
        $checked = $_POST['checked'];
        OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null);
        break;
    default:
        OCP\JSON::error(array('data' => array('message' => 'Unknown type')));
        exit;
}
OC_Calendar_Object::edit($id, $vcalendar->serialize());
$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$task_info = OC_Task_App::arrayForJSON($id, $vtodo, $user_timezone);
OCP\JSON::success(array('data' => $task_info));
コード例 #3
0
/**
 * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), 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;
        }
        $object = OC_VObject::parse($task['calendardata']);
        $vtodo = $object->VTODO;
        try {
            $tasks[] = OC_Task_App::arrayForJSON($task['id'], $vtodo, $user_timezone);
        } catch (Exception $e) {
            OCP\Util::writeLog('tasks', $e->getMessage(), OCP\Util::ERROR);
        }
    }
}
OCP\JSON::encodedPrint($tasks);