nextcloud/apps/calendar/ajax/editevent.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2011-08-12 16:29:45 +04:00
<?php
2011-09-24 00:59:24 +04:00
/**
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
2011-09-15 23:20:42 +04:00
require_once('../../../lib/base.php');
2011-08-12 16:29:45 +04:00
2011-09-15 23:20:42 +04:00
$l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
$errarr = OC_Calendar_Object::validateRequest($_POST);
if($errarr){
//show validate errors
$errarr['status'] = 'error';
2011-09-15 23:20:42 +04:00
echo json_encode($errarr);
exit;
}else{
$id = $_POST['id'];
2011-09-16 02:08:15 +04:00
$cal = $_POST['calendar'];
2011-09-15 23:20:42 +04:00
$data = OC_Calendar_Object::find($id);
if (!$data)
{
2011-09-18 19:12:31 +04:00
echo json_encode(array('status'=>'error'));
2011-09-15 23:20:42 +04:00
exit;
}
2011-09-16 02:08:15 +04:00
$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
if($calendar['userid'] != OC_User::getUser()){
2011-09-18 19:12:31 +04:00
echo json_encode(array('status'=>'error'));
2011-09-16 02:08:15 +04:00
exit;
}
2011-09-15 23:20:42 +04:00
$vcalendar = Sabre_VObject_Reader::read($data['calendardata']);
OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar);
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
2011-09-16 02:08:15 +04:00
if ($data['calendarid'] != $cal) {
OC_Calendar_Object::moveToCalendar($id, $cal);
}
echo json_encode(array('status' => 'success'));
2011-09-15 23:20:42 +04:00
}
2011-08-12 16:29:45 +04:00
?>