mirror of
https://github.com/nextcloud/server.git
synced 2026-04-29 18:11:41 -04:00
Start using OC_JSON in tasks app
This commit is contained in:
parent
16ee08385e
commit
c30aa4ddeb
7 changed files with 29 additions and 56 deletions
|
|
@ -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 )));
|
||||
|
|
|
|||
|
|
@ -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 )));
|
||||
|
|
|
|||
|
|
@ -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 )));
|
||||
|
|
|
|||
|
|
@ -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 )));
|
||||
|
|
|
|||
|
|
@ -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 )));
|
||||
|
|
|
|||
|
|
@ -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 )));
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
Loading…
Reference in a new issue