summaryrefslogtreecommitdiffstats
path: root/apps/calendar/ajax/moveevent.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-12-18 22:58:20 +0100
committerBart Visscher <bartv@thisnet.nl>2011-12-18 23:10:42 +0100
commit4eb36b0ecf40266ceb2abf0f5bc17dad4bde6951 (patch)
tree1c9a177a152e8c6e4155e7766f7ea5cfd991cf97 /apps/calendar/ajax/moveevent.php
parent3d1accab701730fbd2b0cb89cb8c727301f5d756 (diff)
downloadnextcloud-server-4eb36b0ecf40266ceb2abf0f5bc17dad4bde6951.tar.gz
nextcloud-server-4eb36b0ecf40266ceb2abf0f5bc17dad4bde6951.zip
Calendar: refactor common ajax functions to OC_Calendar_App
Diffstat (limited to 'apps/calendar/ajax/moveevent.php')
-rw-r--r--apps/calendar/ajax/moveevent.php26
1 files changed, 8 insertions, 18 deletions
diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php
index 51fafdfeb97..f2256d4eee6 100644
--- a/apps/calendar/ajax/moveevent.php
+++ b/apps/calendar/ajax/moveevent.php
@@ -5,31 +5,20 @@
* later.
* See the COPYING-README file.
*/
-error_reporting(E_ALL);
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
-$data = OC_Calendar_Object::find($_POST["id"]);
-$calendarid = $data["calendarid"];
-$cal = $calendarid;
+
$id = $_POST['id'];
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
-if(OC_User::getUser() != $calendar['userid']){
- OC_JSON::error();
- exit;
-}
+
+$vcalendar = OC_Calendar_App::getVCalendar($id);
+$vevent = $vcalendar->VEVENT;
+
$allday = $_POST['allDay'];
$delta = new DateInterval('P0D');
$delta->d = $_POST['dayDelta'];
$delta->i = $_POST['minuteDelta'];
-$vcalendar = OC_VObject::parse($data['calendardata']);
-$vevent = $vcalendar->VEVENT;
-
-$last_modified = $vevent->__get('LAST-MODIFIED');
-if($last_modified && $_POST['lastmodified'] != $last_modified->getDateTime()->format('U')){
- OC_JSON::error();
- exit;
-}
+OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
@@ -50,4 +39,5 @@ $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
-OC_JSON::success(array('lastmodified'=>(int)$now->format('U')));
+$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
+OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U')));