From: Michael J. Rubinsky Date: Sun, 9 Jan 2011 19:28:09 +0000 (-0500) Subject: PEAR_Error -> Exceptions X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1adb14cd78c9c6f9fb70e9950df84faee630264e;p=horde.git PEAR_Error -> Exceptions Didn't touch the Kolab drivers, I couldn't tell for sure if the underlying libraries were throwing exceptions yet --- diff --git a/turba/addressbooks/delete.php b/turba/addressbooks/delete.php index b97b48206..d5a89aa11 100644 --- a/turba/addressbooks/delete.php +++ b/turba/addressbooks/delete.php @@ -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(); diff --git a/turba/addressbooks/edit.php b/turba/addressbooks/edit.php index 515a18670..16d711bfc 100644 --- a/turba/addressbooks/edit.php +++ b/turba/addressbooks/edit.php @@ -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(); diff --git a/turba/edit.php b/turba/edit.php index 9e646a46c..de49e45b4 100644 --- a/turba/edit.php +++ b/turba/edit.php @@ -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'; diff --git a/turba/lib/Form/EditContactGroup.php b/turba/lib/Form/EditContactGroup.php index 997b33d76..dcb99ac09 100644 --- a/turba/lib/Form/EditContactGroup.php +++ b/turba/lib/Form/EditContactGroup.php @@ -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);