Tasks: Update to new public API

This commit is contained in:
Bart Visscher 2012-05-04 17:19:25 +02:00
parent 1e47156226
commit 439467746a
10 changed files with 50 additions and 50 deletions

View File

@ -2,10 +2,10 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks'); OCP\JSON::checkAppEnabled('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true); $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
$cid = reset($calendars)['id']; $cid = reset($calendars)['id'];
$input = $_GET['text']; $input = $_GET['text'];
@ -21,7 +21,7 @@ $request['description'] = null;
$vcalendar = OC_Task_App::createVCalendarFromRequest($request); $vcalendar = OC_Task_App::createVCalendarFromRequest($request);
$id = OC_Calendar_Object::add($cid, $vcalendar->serialize()); $id = OC_Calendar_Object::add($cid, $vcalendar->serialize());
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $user_timezone = OC_Preferences::getValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone); $task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
OC_JSON::success(array('task' => $task)); OCP\JSON::success(array('task' => $task));

View File

@ -2,10 +2,10 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks'); OCP\JSON::checkAppEnabled('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true); $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
$category_options = OC_Calendar_App::getCategoryOptions(); $category_options = OC_Calendar_App::getCategoryOptions();
$percent_options = range(0, 100, 10); $percent_options = range(0, 100, 10);
$priority_options = OC_Task_App::getPriorityOptions(); $priority_options = OC_Task_App::getPriorityOptions();
@ -18,4 +18,4 @@ $tmpl->assign('details', new OC_VObject('VTODO'));
$tmpl->assign('categories', ''); $tmpl->assign('categories', '');
$page = $tmpl->fetchPage(); $page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page ))); OCP\JSON::success(array('data' => array( 'page' => $page )));

View File

@ -22,11 +22,11 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks'); OCP\JSON::checkAppEnabled('tasks');
$id = $_GET['id']; $id = $_GET['id'];
$task = OC_Calendar_App::getEventObject( $id ); $task = OC_Calendar_App::getEventObject( $id );
OC_Calendar_Object::delete($id); OC_Calendar_Object::delete($id);
OC_JSON::success(array('data' => array( 'id' => $id ))); OCP\JSON::success(array('data' => array( 'id' => $id )));

View File

@ -2,8 +2,8 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks'); OCP\JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks'); $l10n = new OC_L10N('tasks');
@ -12,7 +12,7 @@ $vcalendar = OC_Calendar_App::getVCalendar($id);
$errors = OC_Task_App::validateRequest($_POST); $errors = OC_Task_App::validateRequest($_POST);
if (!empty($errors)) { if (!empty($errors)) {
OC_JSON::error(array('data' => array( 'errors' => $errors ))); OCP\JSON::error(array('data' => array( 'errors' => $errors )));
exit(); exit();
} }
@ -26,7 +26,7 @@ $tmpl->assign('details', $vcalendar->VTODO);
$tmpl->assign('id', $id); $tmpl->assign('id', $id);
$page = $tmpl->fetchPage(); $page = $tmpl->fetchPage();
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $user_timezone = OC_Preferences::getValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone); $task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task ))); OCP\JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task )));

View File

@ -2,8 +2,8 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks'); OCP\JSON::checkAppEnabled('tasks');
$id = $_GET['id']; $id = $_GET['id'];
$details = OC_Calendar_App::getVCalendar($id)->VTODO; $details = OC_Calendar_App::getVCalendar($id)->VTODO;
@ -22,4 +22,4 @@ $tmpl->assign('details',$details);
$tmpl->assign('categories', $categories); $tmpl->assign('categories', $categories);
$page = $tmpl->fetchPage(); $page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page ))); OCP\JSON::success(array('data' => array( 'page' => $page )));

View File

@ -2,8 +2,8 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks'); OCP\JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks'); $l10n = new OC_L10N('tasks');
@ -11,7 +11,7 @@ $id = $_GET['id'];
$task = OC_Calendar_Object::find($id); $task = OC_Calendar_Object::find($id);
$details = OC_VObject::parse($task['calendardata']); $details = OC_VObject::parse($task['calendardata']);
if (!$details){ if (!$details){
OC_JSON::error(); OCP\JSON::error();
exit; exit;
} }
@ -22,4 +22,4 @@ $tmpl->assign('details',$details->VTODO);
$tmpl->assign('id',$id); $tmpl->assign('id',$id);
$page = $tmpl->fetchPage(); $page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page ))); OCP\JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));

View File

@ -8,11 +8,11 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks'); OCP\JSON::checkAppEnabled('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true); $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $user_timezone = OC_Preferences::getValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$tasks = array(); $tasks = array();
foreach( $calendars as $calendar ){ foreach( $calendars as $calendar ){
@ -34,4 +34,4 @@ foreach( $calendars as $calendar ){
} }
} }
OC_JSON::encodedPrint($tasks); OCP\JSON::encodedPrint($tasks);

View File

@ -8,8 +8,8 @@
// Init owncloud // Init owncloud
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OCP\JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks'); OCP\JSON::checkAppEnabled('tasks');
$id = $_POST['id']; $id = $_POST['id'];
$property = $_POST['type']; $property = $_POST['type'];
@ -39,7 +39,7 @@ switch($property) {
$type = null; $type = null;
if ($due != 'false') { if ($due != 'false') {
try { try {
$timezone = OC_Preferences::getValue(OC_User::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $timezone = OC_Preferences::getValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$timezone = new DateTimeZone($timezone); $timezone = new DateTimeZone($timezone);
$due = new DateTime('@'.$due); $due = new DateTime('@'.$due);
$due->setTimezone($timezone); $due->setTimezone($timezone);
@ -48,7 +48,7 @@ switch($property) {
$type = Sabre_VObject_Element_DateTime::DATE; $type = Sabre_VObject_Element_DateTime::DATE;
} }
} catch (Exception $e) { } catch (Exception $e) {
OC_JSON::error(array('data'=>array('message'=>OC_Task_App::$l10n->t('Invalid date/time')))); OCP\JSON::error(array('data'=>array('message'=>OC_Task_App::$l10n->t('Invalid date/time'))));
exit(); exit();
} }
} }
@ -59,11 +59,11 @@ switch($property) {
OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null); OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null);
break; break;
default: default:
OC_JSON::error(array('data'=>array('message'=>'Unknown type'))); OCP\JSON::error(array('data'=>array('message'=>'Unknown type')));
exit(); exit();
} }
OC_Calendar_Object::edit($id, $vcalendar->serialize()); OC_Calendar_Object::edit($id, $vcalendar->serialize());
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $user_timezone = OC_Preferences::getValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$task_info = OC_Task_App::arrayForJSON($id, $vtodo, $user_timezone); $task_info = OC_Task_App::arrayForJSON($id, $vtodo, $user_timezone);
OC_JSON::success(array('data' => $task_info)); OCP\JSON::success(array('data' => $task_info));

View File

@ -9,22 +9,22 @@
*************************************************/ *************************************************/
require_once ('../../lib/base.php'); require_once ('../../lib/base.php');
OC_Util::checkLoggedIn(); OCP\User::checkLoggedIn();
OC_Util::checkAppEnabled('tasks'); OCP\App::checkAppEnabled('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true); $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
if( count($calendars) == 0 ) { if( count($calendars) == 0 ) {
header('Location: ' . OC_Helper::linkTo('calendar', 'index.php')); header('Location: ' . OC_Helper::linkTo('calendar', 'index.php'));
exit; exit;
} }
OC_Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker'); OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker');
OC_Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker'); OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
OC_UTIL::addScript('tasks', 'tasks'); OCP\Util::addScript('tasks', 'tasks');
OC_UTIL::addStyle('tasks', 'style'); OCP\Util::addStyle('tasks', 'style');
OC_Util::addScript('contacts','jquery.multi-autocomplete'); OCP\Util::addScript('contacts','jquery.multi-autocomplete');
OC_Util::addScript('','oc-vcategories'); OCP\Util::addScript('','oc-vcategories');
OC_APP::setActiveNavigationEntry('tasks_index'); OCP\App::setActiveNavigationEntry('tasks_index');
$categories = OC_Calendar_App::getCategoryOptions(); $categories = OC_Calendar_App::getCategoryOptions();
$l10n = new OC_L10N('tasks'); $l10n = new OC_L10N('tasks');

View File

@ -82,7 +82,7 @@ class OC_Task_App {
} }
try { try {
$timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London"); $timezone = OC_Preferences::getValue(OCP\User::getUser(), "calendar", "timezone", "Europe/London");
$timezone = new DateTimeZone($timezone); $timezone = new DateTimeZone($timezone);
new DateTime($request['due'], $timezone); new DateTime($request['due'], $timezone);
} catch (Exception $e) { } catch (Exception $e) {
@ -94,7 +94,7 @@ class OC_Task_App {
} }
if ($request['percent_complete'] == 100 && !empty($request['completed'])){ if ($request['percent_complete'] == 100 && !empty($request['completed'])){
try { try {
$timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London"); $timezone = OC_Preferences::getValue(OCP\User::getUser(), "calendar", "timezone", "Europe/London");
$timezone = new DateTimeZone($timezone); $timezone = new DateTimeZone($timezone);
new DateTime($request['completed'], $timezone); new DateTime($request['completed'], $timezone);
} catch (Exception $e) { } catch (Exception $e) {
@ -147,7 +147,7 @@ class OC_Task_App {
$vtodo->setString('PRIORITY', $priority); $vtodo->setString('PRIORITY', $priority);
if ($due) { if ($due) {
$timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $timezone = OC_Preferences::getValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$timezone = new DateTimeZone($timezone); $timezone = new DateTimeZone($timezone);
$due = new DateTime($due, $timezone); $due = new DateTime($due, $timezone);
$vtodo->setDateTime('DUE', $due); $vtodo->setDateTime('DUE', $due);
@ -176,7 +176,7 @@ class OC_Task_App {
$completed = null; $completed = null;
} }
if ($completed) { if ($completed) {
$timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $timezone = OC_Preferences::getValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$timezone = new DateTimeZone($timezone); $timezone = new DateTimeZone($timezone);
$completed = new DateTime($completed, $timezone); $completed = new DateTime($completed, $timezone);
$vtodo->setDateTime('COMPLETED', $completed); $vtodo->setDateTime('COMPLETED', $completed);