Implement UpdateEvent. Dragged events are stored in the backend now.
authorJan Schneider <jan@horde.org>
Tue, 17 Mar 2009 22:31:12 +0000 (23:31 +0100)
committerJan Schneider <jan@horde.org>
Tue, 17 Mar 2009 22:38:12 +0000 (23:38 +0100)
kronolith/ajax.php
kronolith/js/src/kronolith.js

index 320ca82..b69e4d2 100644 (file)
@@ -129,6 +129,37 @@ case 'GetEvent':
     $result->event = $event;
     break;
 
+case 'UpdateEvent':
+    if (!($kronolith_driver = getDriver($cal = Util::getFormData('cal')))) {
+        break;
+    }
+    $event = $kronolith_driver->getEvent(Util::getFormData('id'));
+    if (is_a($event, 'PEAR_Error')) {
+        $notification->push($event, 'horde.error');
+        break;
+    }
+    if ($event) {
+        $notification->push(_("The requested event was not found."), 'horde.error');
+        break;
+    }
+    $attributes = Horde_Serialize::unserialize(Util::getFormData('att'), Horde_Serialize::JSON);
+    foreach ($attributes as $attribute => $value) {
+        switch ($attribute) {
+        case 'start_date':
+            $start = new Horde_Date($value);
+            $event->start->year = $start->year;
+            $event->start->month = $start->month;
+            $event->start->mday = $start->mday;
+            $event->end = $event->start->add(array('min' => $event->durMin));
+            break;
+        }
+    }
+    $result = $event->save();
+    if (is_a($result, 'PEAR_Error')) {
+        $notification->push($result, 'horde.error');
+    }
+    break;
+
 case 'SaveCalPref':
     $result = true;
     break;
index 30a9ea8..a7ba8e8 100644 (file)
@@ -402,8 +402,11 @@ KronolithCore = {
             }
             new Drop(cell, { onDrop: function(drop) {
                 var el = DragDrop.Drags.drag.element;
-                this.doAction('UpdateEvent', { cal: el.readAttribute('calendar'), id: el.readAttribute('eventid'), att: $H({ start: drop.readAttribute('date') }).toJSON() });
                 drop.insert(el);
+                this.doAction('UpdateEvent',
+                              { cal: el.readAttribute('calendar'),
+                                id: el.readAttribute('eventid'),
+                                att: $H({ start_date: drop.readAttribute('date') }).toJSON() });
             }.bind(this) });
             cell.down('.kronolithDay').setText(day.getDate());
             cell = cell.next();