nextcloud/apps/tasks/ajax/edittask.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2011-09-12 23:28:28 +04:00
<?php
// Init owncloud
require_once('../../../lib/base.php');
2011-10-06 23:21:38 +04:00
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks');
2011-09-12 23:28:28 +04:00
$l10n = new OC_L10N('tasks');
$id = $_POST['id'];
$task = OC_Calendar_Object::find( $id );
if( $task === false ){
2011-10-06 23:21:38 +04:00
OC_JSON::error(array('data' => array( 'message' => $l10n->t('Can not find Task!'))));
2011-09-12 23:28:28 +04:00
exit();
}
$calendar = OC_Calendar_Calendar::findCalendar( $task['calendarid'] );
if( $calendar === false || $calendar['userid'] != OC_USER::getUser()){
2011-10-06 23:21:38 +04:00
OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your task!'))));
2011-09-12 23:28:28 +04:00
exit();
}
$errors = OC_Task_App::validateRequest($_POST);
2011-09-14 00:44:15 +04:00
if (!empty($errors)) {
2011-10-06 23:21:38 +04:00
OC_JSON::error(array('data' => array( 'errors' => $errors )));
2011-09-14 00:44:15 +04:00
exit();
}
2011-12-10 00:41:21 +04:00
$vcalendar = OC_VObject::parse($task['calendardata']);
OC_Task_App::updateVCalendarFromRequest($_POST, $vcalendar);
2011-09-12 23:28:28 +04:00
OC_Calendar_Object::edit($id, $vcalendar->serialize());
$priority_options = OC_Task_App::getPriorityOptions();
2011-09-12 23:28:28 +04:00
$tmpl = new OC_Template('tasks','part.details');
2011-09-14 00:44:15 +04:00
$tmpl->assign('priority_options', $priority_options);
$tmpl->assign('details', $vcalendar->VTODO);
$tmpl->assign('id', $id);
2011-09-12 23:28:28 +04:00
$page = $tmpl->fetchPage();
2011-10-06 23:21:38 +04:00
OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));