コード例 #1
0
ファイル: app.php プロジェクト: CDN-Sparks/owncloud
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
/**
 * This class manages our tasks
 */
OC_Task_App::$l10n = new OC_L10N('tasks');
class OC_Task_App
{
    public static $l10n;
    public static function getPriorityOptions()
    {
        return array('' => self::$l10n->t('Unspecified'), '1' => self::$l10n->t('1=highest'), '2' => '2', '3' => '3', '4' => '4', '5' => self::$l10n->t('5=medium'), '6' => '6', '7' => '7', '8' => '8', '9' => self::$l10n->t('9=lowest'));
    }
    public static function arrayForJSON($id, $vtodo, $user_timezone)
    {
        $task = array('id' => $id);
        $task['summary'] = strtr($vtodo->getAsString('SUMMARY'), array('\\,' => ',', '\\;' => ';'));
        $task['description'] = strtr($vtodo->getAsString('DESCRIPTION'), array('\\,' => ',', '\\;' => ';'));
        $task['location'] = strtr($vtodo->getAsString('LOCATION'), array('\\,' => ',', '\\;' => ';'));
        $task['categories'] = $vtodo->getAsArray('CATEGORIES');
        $due = $vtodo->DUE;
コード例 #2
0
ファイル: addtaskform.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);
$category_options = OC_Calendar_App::getCategoryOptions();
$percent_options = range(0, 100, 10);
$priority_options = OC_Task_App::getPriorityOptions();
$tmpl = new OCP\Template('tasks', 'part.addtaskform');
$tmpl->assign('calendars', $calendars);
$tmpl->assign('category_options', $category_options);
$tmpl->assign('percent_options', $percent_options);
$tmpl->assign('priority_options', $priority_options);
$tmpl->assign('details', new OC_VObject('VTODO'));
$tmpl->assign('categories', '');
$page = $tmpl->fetchPage();
OCP\JSON::success(array('data' => array('page' => $page)));
コード例 #3
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));
コード例 #4
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));
コード例 #5
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);