summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-10-18 23:02:00 +0200
committerBart Visscher <bartv@thisnet.nl>2011-10-20 23:49:28 +0200
commit3d8a1ccb3f34eae204d3a3154c4e55d40ebc24f8 (patch)
tree181e0b3919ec186a4cf1b8be6486bbcf7bb2067d
parenta8bca282df6185ce0f1b919e84167d2210952258 (diff)
downloadnextcloud-server-3d8a1ccb3f34eae204d3a3154c4e55d40ebc24f8.tar.gz
nextcloud-server-3d8a1ccb3f34eae204d3a3154c4e55d40ebc24f8.zip
Implement resizing of events
-rw-r--r--apps/calendar/ajax/resizeevent.php43
-rw-r--r--apps/calendar/js/calendar.js11
2 files changed, 54 insertions, 0 deletions
diff --git a/apps/calendar/ajax/resizeevent.php b/apps/calendar/ajax/resizeevent.php
new file mode 100644
index 00000000000..3a2bf87afd9
--- /dev/null
+++ b/apps/calendar/ajax/resizeevent.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * 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.
+ */
+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;
+}
+
+$delta = new DateInterval('P0D');
+$delta->d = $_POST['dayDelta'];
+$delta->i = $_POST['minuteDelta'];
+
+$vcalendar = Sabre_VObject_Reader::read($data['calendardata']);
+$vevent = $vcalendar->VEVENT;
+
+$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+$end_type = $dtend->getDateType();
+$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
+unset($vevent->DURATION);
+
+$now = new DateTime();
+$last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED');
+$last_modified->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
+$vevent->__set('LAST-MODIFIED', $last_modified);
+
+$dtstamp = new Sabre_VObject_Element_DateTime('DTSTAMP');
+$dtstamp->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
+$vevent->DTSTAMP = $dtstamp;
+
+$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
+OC_JSON::success();
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index db5bf44c260..5251dbaa2b4 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -201,6 +201,16 @@ Calendar={
}
});
},
+ resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
+ $.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta},
+ function(data) {
+ if (data.status == 'success'){
+ console.log("Event resized successfully");
+ }else{
+ revertFunc();
+ }
+ });
+ },
showadvancedoptions:function(){
$("#advanced_options").css("display", "block");
$("#advanced_options_button").css("display", "none");
@@ -476,6 +486,7 @@ $(document).ready(function(){
dayClick: Calendar.UI.newEvent,
eventClick: Calendar.UI.editEvent,
eventDrop: Calendar.UI.moveEvent,
+ eventResize: Calendar.UI.resizeEvent,
eventMouseover: Calendar.UI.createEventPopup,
eventMouseout: Calendar.UI.hideEventPopup,
eventSources: eventSources