summaryrefslogtreecommitdiffstats
path: root/apps/tasks
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-10-06 21:21:38 +0200
committerBart Visscher <bartv@thisnet.nl>2011-10-06 21:21:38 +0200
commitc30aa4ddebaefe93ec82f4f73d615a7ba1025e61 (patch)
tree1c5d1cd14533f193fa562ad450ce770f4cf816dd /apps/tasks
parent16ee08385e2ff52c13fe25c1b4b6344e7cbdb813 (diff)
downloadnextcloud-server-c30aa4ddebaefe93ec82f4f73d615a7ba1025e61.tar.gz
nextcloud-server-c30aa4ddebaefe93ec82f4f73d615a7ba1025e61.zip
Start using OC_JSON in tasks app
Diffstat (limited to 'apps/tasks')
-rw-r--r--apps/tasks/ajax/addtask.php14
-rw-r--r--apps/tasks/ajax/addtaskform.php10
-rw-r--r--apps/tasks/ajax/delete.php15
-rw-r--r--apps/tasks/ajax/edittask.php16
-rw-r--r--apps/tasks/ajax/edittaskform.php14
-rw-r--r--apps/tasks/ajax/getdetails.php10
-rw-r--r--apps/tasks/index.php6
7 files changed, 29 insertions, 56 deletions
diff --git a/apps/tasks/ajax/addtask.php b/apps/tasks/ajax/addtask.php
index 81905666ff3..d2bd46f56a6 100644
--- a/apps/tasks/ajax/addtask.php
+++ b/apps/tasks/ajax/addtask.php
@@ -2,25 +2,21 @@
// Init owncloud
require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks');
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
- exit();
-}
-
$cid = $_POST['id'];
$calendar = OC_Calendar_Calendar::findCalendar( $cid );
if( $calendar === false || $calendar['userid'] != OC_USER::getUser()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your calendar!'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your calendar!'))));
exit();
}
$errors = OC_Task_VTodo::validateRequest($_POST, $l10n);
if (!empty($errors)) {
- echo json_encode( array( 'status' => 'error', 'data' => array( 'errors' => $errors )));
+ OC_JSON::error(array('data' => array( 'errors' => $errors )));
exit();
}
@@ -34,4 +30,4 @@ $tmpl->assign('details',$vcalendar->VTODO);
$tmpl->assign('id',$id);
$page = $tmpl->fetchPage();
-echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page )));
+OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
diff --git a/apps/tasks/ajax/addtaskform.php b/apps/tasks/ajax/addtaskform.php
index 297c590060d..222ccbd79a3 100644
--- a/apps/tasks/ajax/addtaskform.php
+++ b/apps/tasks/ajax/addtaskform.php
@@ -2,18 +2,14 @@
// Init owncloud
require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks');
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
- exit();
-}
-
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true);
$tmpl = new OC_Template('tasks','part.addtaskform');
$tmpl->assign('calendars',$calendars);
$page = $tmpl->fetchPage();
-echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
+OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/tasks/ajax/delete.php b/apps/tasks/ajax/delete.php
index 1d96a058d79..03c8a7e92e4 100644
--- a/apps/tasks/ajax/delete.php
+++ b/apps/tasks/ajax/delete.php
@@ -22,28 +22,23 @@
// Init owncloud
require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks');
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
- exit();
-}
-
-
$id = $_GET['id'];
$task = OC_Calendar_Object::find( $id );
if( $task === false ){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Task!'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('Can not find Task!'))));
exit();
}
$calendar = OC_Calendar_Calendar::findCalendar( $task['calendarid'] );
if( $calendar === false || $calendar['userid'] != OC_USER::getUser()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your task!'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your task!'))));
exit();
}
OC_Calendar_Object::delete($id);
-echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id )));
+OC_JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/tasks/ajax/edittask.php b/apps/tasks/ajax/edittask.php
index 9f836f1f8a8..e9603d92da9 100644
--- a/apps/tasks/ajax/edittask.php
+++ b/apps/tasks/ajax/edittask.php
@@ -2,31 +2,27 @@
// Init owncloud
require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks');
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
- exit();
-}
-
$id = $_POST['id'];
$task = OC_Calendar_Object::find( $id );
if( $task === false ){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Task!'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('Can not find Task!'))));
exit();
}
$calendar = OC_Calendar_Calendar::findCalendar( $task['calendarid'] );
if( $calendar === false || $calendar['userid'] != OC_USER::getUser()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your task!'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your task!'))));
exit();
}
$errors = OC_Task_VTodo::validateRequest($_POST, $l10n);
if (!empty($errors)) {
- echo json_encode( array( 'status' => 'error', 'data' => array( 'errors' => $errors )));
+ OC_JSON::error(array('data' => array( 'errors' => $errors )));
exit();
}
@@ -41,4 +37,4 @@ $tmpl->assign('details', $vcalendar->VTODO);
$tmpl->assign('id', $id);
$page = $tmpl->fetchPage();
-echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page )));
+OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
diff --git a/apps/tasks/ajax/edittaskform.php b/apps/tasks/ajax/edittaskform.php
index dc8bb60e64d..b309413683c 100644
--- a/apps/tasks/ajax/edittaskform.php
+++ b/apps/tasks/ajax/edittaskform.php
@@ -2,25 +2,21 @@
// Init owncloud
require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks');
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
- exit();
-}
-
$id = $_GET['id'];
$task = OC_Calendar_Object::find( $id );
if( $task === false ){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Task!'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('Can not find Task!'))));
exit();
}
$calendar = OC_Calendar_Calendar::findCalendar( $task['calendarid'] );
if( $calendar === false || $calendar['userid'] != OC_USER::getUser()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your task!'))));
+ OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your task!'))));
exit();
}
@@ -44,4 +40,4 @@ $tmpl->assign('details',$details);
$tmpl->assign('categories', $categories);
$page = $tmpl->fetchPage();
-echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
+OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/tasks/ajax/getdetails.php b/apps/tasks/ajax/getdetails.php
index f111a399b36..08bf6c9ecf6 100644
--- a/apps/tasks/ajax/getdetails.php
+++ b/apps/tasks/ajax/getdetails.php
@@ -2,15 +2,11 @@
// Init owncloud
require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('tasks');
$l10n = new OC_L10N('tasks');
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('You need to log in!'))));
- exit();
-}
-
$id = $_GET['id'];
$task = OC_Calendar_Object::find($id);
$details = Sabre_VObject_Reader::read($task['calendardata'])->VTODO;
@@ -22,4 +18,4 @@ $tmpl->assign('details',$details);
$tmpl->assign('id',$id);
$page = $tmpl->fetchPage();
-echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id, 'page' => $page )));
+OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
diff --git a/apps/tasks/index.php b/apps/tasks/index.php
index 696ab11dd68..a653326338b 100644
--- a/apps/tasks/index.php
+++ b/apps/tasks/index.php
@@ -9,10 +9,8 @@
*************************************************/
require_once ('../../lib/base.php');
-if(!OC_USER::isLoggedIn()) {
- header('Location: ' . OC_HELPER::linkTo('', 'index.php'));
- exit;
-}
+OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true);
if( count($calendars) == 0){