plugins/calendar

Thomas Brüderli bruederli at kolabsys.com
Fri Aug 3 15:21:50 CEST 2012


 plugins/calendar/drivers/kolab/kolab_calendar.php |   10 ++---
 plugins/calendar/drivers/kolab/kolab_driver.php   |   42 +++++++++++-----------
 2 files changed, 26 insertions(+), 26 deletions(-)

New commits:
commit 7cd68bb9d94ef764de1d2364d47b7d555025ad63
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Fri Aug 3 15:20:41 2012 +0200

    Improve error handling in Kolab driver: we don't deal with PEAR errors anymore (#914)

diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index 813b391..33af8cd 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -278,11 +278,11 @@ class kolab_calendar
     $object = $this->_from_rcube_event($event);
     $saved = $this->storage->save($object, 'event');
     
-    if (!$saved || PEAR::isError($saved)) {
+    if (!$saved) {
       raise_error(array(
         'code' => 600, 'type' => 'php',
         'file' => __FILE__, 'line' => __LINE__,
-        'message' => "Error saving event object to Kolab server:" . $saved->getMessage()),
+        'message' => "Error saving event object to Kolab server"),
         true, false);
       $saved = false;
     }
@@ -312,11 +312,11 @@ class kolab_calendar
     $object = $this->_from_rcube_event($event, $old);
     $saved = $this->storage->save($object, 'event', $event['id']);
 
-    if (!$saved || PEAR::isError($saved)) {
+    if (!$saved) {
       raise_error(array(
         'code' => 600, 'type' => 'php',
         'file' => __FILE__, 'line' => __LINE__,
-        'message' => "Error saving event object to Kolab server:" . $saved->getMessage()),
+        'message' => "Error saving event object to Kolab server"),
         true, false);
     }
     else {
@@ -337,7 +337,7 @@ class kolab_calendar
   {
     $deleted = $this->storage->delete($event['id'], $force);
 
-    if (!$deleted || PEAR::isError($deleted)) {
+    if (!$deleted) {
       raise_error(array(
         'code' => 600, 'type' => 'php',
         'file' => __FILE__, 'line' => __LINE__,
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index c4b233a..c3151e4 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -68,27 +68,18 @@ class kolab_driver extends calendar_driver
     $folders = kolab_storage::get_folders('event');
     $this->calendars = array();
 
-    if (PEAR::isError($folders)) {
-      raise_error(array(
-        'code' => 600, 'type' => 'php',
-        'file' => __FILE__, 'line' => __LINE__,
-        'message' => "Failed to list calendar folders from Kolab server:" . $folders->getMessage()),
-      true, false);
-    }
-    else {
-      // convert to UTF8 and sort
-      $names = array();
-      foreach ($folders as $folder)
-        $names[$folder->name] = rcube_charset::convert($folder->name, 'UTF7-IMAP');
-
-      asort($names, SORT_LOCALE_STRING);
-
-      foreach ($names as $utf7name => $name) {
-        $calendar = new kolab_calendar($utf7name, $this->cal);
-        $this->calendars[$calendar->id] = $calendar;
-        if (!$calendar->readonly)
-          $this->has_writeable = true;
-      }
+    // convert to UTF8 and sort
+    $names = array();
+    foreach ($folders as $folder)
+      $names[$folder->name] = rcube_charset::convert($folder->name, 'UTF7-IMAP');
+
+    asort($names, SORT_LOCALE_STRING);
+
+    foreach ($names as $utf7name => $name) {
+      $calendar = new kolab_calendar($utf7name, $this->cal);
+      $this->calendars[$calendar->id] = $calendar;
+      if (!$calendar->readonly)
+        $this->has_writeable = true;
     }
 
     return $this->calendars;
@@ -470,6 +461,15 @@ class kolab_driver extends calendar_driver
     $attachments = array();
     $old = $master = $fromcalendar->get_event($event['id']);
 
+    if (!$old || !$old['start']) {
+      raise_error(array(
+        'code' => 600, 'type' => 'php',
+        'file' => __FILE__, 'line' => __LINE__,
+        'message' => "Failed to load event object to update: id=" . $event['id']),
+        true, false);
+      return false;
+    }
+
     // delete existing attachment(s)
     if (!empty($event['deleted_attachments'])) {
       foreach ($event['deleted_attachments'] as $attachment) {





More information about the commits mailing list