PEAR_Error -> Exceptions
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 9 Jan 2011 19:28:09 +0000 (14:28 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 9 Jan 2011 19:28:09 +0000 (14:28 -0500)
Didn't touch the Kolab drivers, I couldn't tell for sure if the
underlying libraries were throwing exceptions yet

turba/addressbooks/delete.php
turba/addressbooks/edit.php
turba/edit.php
turba/lib/Form/EditContactGroup.php

index b97b482..d5a89aa 100644 (file)
@@ -43,11 +43,11 @@ $form = new Turba_Form_DeleteAddressBook($vars, $addressbook);
 
 // Execute if the form is valid (must pass with POST variables only).
 if ($form->validate(new Horde_Variables($_POST))) {
-    $result = $form->execute();
-    if ($result instanceof PEAR_Error) {
-        $notification->push($result, 'horde.error');
-    } elseif ($result) {
+    try {
+        $result = $form->execute();
         $notification->push(sprintf(_("The addressbook \"%s\" has been deleted."), $addressbook->get('name')), 'horde.success');
+    } catch (Turba_Exception $e) {
+        $notification->push($result, 'horde.error');
     }
 
     Horde::url('addressbooks/', true)->redirect();
index 515a186..16d711b 100644 (file)
@@ -37,15 +37,15 @@ $form = new Turba_Form_EditAddressBook($vars, $addressbook);
 // Execute if the form is valid.
 if ($form->validate($vars)) {
     $original_name = $addressbook->get('name');
-    $result = $form->execute();
-    if ($result instanceof PEAR_Error) {
-        $notification->push($result, 'horde.error');
-    } else {
+    try {
+        $result = $form->execute();
         if ($addressbook->get('name') != $original_name) {
             $notification->push(sprintf(_("The addressbook \"%s\" has been renamed to \"%s\"."), $original_name, $addressbook->get('name')), 'horde.success');
         } else {
             $notification->push(sprintf(_("The addressbook \"%s\" has been saved."), $original_name), 'horde.success');
         }
+    } catch (Turba_Exception $e) {
+        $notification->push($result, 'horde.error');
     }
 
     Horde::url('addressbooks/', true)->redirect();
index 9e646a4..de49e45 100644 (file)
@@ -74,16 +74,18 @@ if ($groupedit) {
 }
 
 /* Execute() checks validation first. */
-$edited = $form->execute();
-if (!($edited instanceof PEAR_Error)) {
-    $url = Horde_Util::getFormData('url');
-    if (empty($url)) {
-        $url = $contact->url('Contact', true);
-    } else {
-        $url = new Horde_Url($url, true);
-    }
-    $url->unique()->redirect();
+try {
+    $edited = $form->execute();
+} catch (Turba_Exception $e) {
 }
+$url = Horde_Util::getFormData('url');
+if (empty($url)) {
+    $url = $contact->url('Contact', true);
+} else {
+    $url = new Horde_Url($url, true);
+}
+$url->unique()->redirect();
+
 
 $title = sprintf(_("Edit \"%s\""), $contact->getValue('name'));
 require $registry->get('templates', 'horde') . '/common-header.inc';
index 997b33d..dcb99ac 100644 (file)
@@ -47,9 +47,6 @@ class Turba_Form_EditContactGroup extends Turba_Form_EditContact
     function execute()
     {
         $result = parent::execute();
-        if ($result instanceof PEAR_Error) {
-            return $result;
-        }
 
         $this->getInfo($this->_vars, $info);