From d9fd1eda3e6ded7ca5b399b2b365ed84ef710cbf Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Sat, 2 Jan 2010 12:23:28 -0500 Subject: [PATCH] Vilma: Convert PEAR::raiseError to Vilma_Exception --- vilma/lib/Driver.php | 16 ++++++++-------- vilma/lib/Exception.php | 1 + vilma/lib/MailboxDriver/imap.php | 2 +- vilma/lib/MailboxDriver/maildrop.php | 6 +++--- vilma/lib/MailboxDriver/null.php | 6 +++--- 5 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 vilma/lib/Exception.php diff --git a/vilma/lib/Driver.php b/vilma/lib/Driver.php index 14b4f858a..303a19190 100644 --- a/vilma/lib/Driver.php +++ b/vilma/lib/Driver.php @@ -105,7 +105,7 @@ class Vilma_Driver { return $addrinfo; } } - return PEAR::raiseError(sprintf(_("No such address %s of type %s found."), $address, $type)); + throw new Vilma_Exception(sprintf(_("No such address %s of type %s found."), $address, $type)); } /** @@ -268,13 +268,13 @@ class Vilma_Driver { escapeshellarg($info['password'])); $msg = system($cmd, $ec); if ($msg === false) { - return PEAR::raiseError(_("Error running authentication update script.")); + throw new Vilma_Exception(_("Error running authentication update script.")); } if ($ec != 0) { if (empty($msg)) { $msg = _("Unknown error running authentication update script."); } - return PEAR::raiseError($msg); + throw new Vilma_Exception($msg); } } @@ -283,7 +283,7 @@ class Vilma_Driver { function deleteUser($user_id) { - return PEAR::raiseError(_("Vilma_Driver::deleteUser(): Method Not Implemented.")); + throw new Vilma_Exception(_("Vilma_Driver::deleteUser(): Method Not Implemented.")); } /** @@ -302,7 +302,7 @@ class Vilma_Driver { $ret = Horde::callHook('_vilma_hook_savedomain', array($info), 'vilma'); if (!$ret) { - return PEAR::raiseError(_("Domain added but an error was encountered while calling the configured hook. Contact your administrator for futher assistance.")); + throw new Vilma_Exception(_("Domain added but an error was encountered while calling the configured hook. Contact your administrator for futher assistance.")); } return $domain_id; @@ -318,7 +318,7 @@ class Vilma_Driver { */ function _saveDomain(&$info) { - return PEAR::raiseError(_("Not implemented.")); + throw new Vilma_Exception(_("Not implemented.")); } /** @@ -353,7 +353,7 @@ class Vilma_Driver { array($domain_record['domain_name']), 'vilma'); if (!$ret) { - return PEAR::raiseError(_("Error while calling hook to delete domain.")); + throw new Vilma_Exception(_("Error while calling hook to delete domain.")); } } @@ -367,7 +367,7 @@ class Vilma_Driver { */ function _deleteDomain($domain_id) { - return PEAR::raiseError(_("Not implemented.")); + throw new Vilma_Exception(_("Not implemented.")); } /** diff --git a/vilma/lib/Exception.php b/vilma/lib/Exception.php new file mode 100644 index 000000000..800d8e3d4 --- /dev/null +++ b/vilma/lib/Exception.php @@ -0,0 +1 @@ +class Vilma_Exception extends Horde_Exception {} \ No newline at end of file diff --git a/vilma/lib/MailboxDriver/imap.php b/vilma/lib/MailboxDriver/imap.php index 966cfc23c..9cf355cb8 100644 --- a/vilma/lib/MailboxDriver/imap.php +++ b/vilma/lib/MailboxDriver/imap.php @@ -40,7 +40,7 @@ class Vilma_MailboxDriver_imap extends Vilma_MailboxDriver { } if (!$this->_imapAdmin->mailboxExists($user . '@' . $domain)) { - return PEAR::raiseError(sprintf(_("Mailbox '%s@%s' does not exist."), $user, $domain)); + throw new Vilma_Exception(sprintf(_("Mailbox '%s@%s' does not exist."), $user, $domain)); } } diff --git a/vilma/lib/MailboxDriver/maildrop.php b/vilma/lib/MailboxDriver/maildrop.php index 55051060a..7784d0a53 100644 --- a/vilma/lib/MailboxDriver/maildrop.php +++ b/vilma/lib/MailboxDriver/maildrop.php @@ -14,7 +14,7 @@ class Vilma_MailboxDriver_maildrop extends Vilma_MailboxDriver { { if (empty($this->_params['mail_dir_base'])) { require_once 'PEAR.php'; - return PEAR::raiseError(_("No 'mail_dir_base' parameter specified to maildrop driver.")); + throw new Vilma_Exception(_("No 'mail_dir_base' parameter specified to maildrop driver.")); } $dir = $this->_params['mail_dir_base']; $usedomain = isset($this->_params['usedomain']) ? $this->_params['usedomain'] : false; @@ -40,7 +40,7 @@ class Vilma_MailboxDriver_maildrop extends Vilma_MailboxDriver { if (!$exists[$dir]) { require_once 'PEAR.php'; - return PEAR::raiseError(sprintf(_("Maildrop directory \"%s\" does not exist."), $dir)); + throw new Vilma_Exception(sprintf(_("Maildrop directory \"%s\" does not exist."), $dir)); } return true; @@ -54,7 +54,7 @@ class Vilma_MailboxDriver_maildrop extends Vilma_MailboxDriver { } if (empty($this->_params['system_user'])) { require_once 'PEAR.php'; - return PEAR::raiseError(_("No 'system_user' parameter specified to maildrop driver.")); + throw new Vilma_Exception(_("No 'system_user' parameter specified to maildrop driver.")); } $create_function = sprintf('sudo -u %s maildirmake %s', diff --git a/vilma/lib/MailboxDriver/null.php b/vilma/lib/MailboxDriver/null.php index 32d1b0a6b..8fb14b3d3 100644 --- a/vilma/lib/MailboxDriver/null.php +++ b/vilma/lib/MailboxDriver/null.php @@ -15,7 +15,7 @@ class Vilma_MailboxDriver_null extends Vilma_MailboxDriver { /* if (empty($this->_params['mail_dir_base'])) { require_once 'PEAR.php'; - return PEAR::raiseError(_("No 'mail_dir_base' parameter specified to maildrop driver.")); + throw new Vilma_Exception(_("No 'mail_dir_base' parameter specified to maildrop driver.")); } $dir = $this->_params['mail_dir_base']; $usedomain = isset($this->_params['usedomain']) ? $this->_params['usedomain'] : false; @@ -43,7 +43,7 @@ class Vilma_MailboxDriver_null extends Vilma_MailboxDriver { if (!$exists[$dir]) { require_once 'PEAR.php'; - return PEAR::raiseError(sprintf(_("Maildrop directory \"%s\" does not exist."), $dir)); + throw new Vilma_Exception(sprintf(_("Maildrop directory \"%s\" does not exist."), $dir)); } */ @@ -58,7 +58,7 @@ class Vilma_MailboxDriver_null extends Vilma_MailboxDriver { } if (empty($this->_params['system_user'])) { require_once 'PEAR.php'; - return PEAR::raiseError(_("No 'system_user' parameter specified to maildrop driver.")); + throw new Vilma_Exception(_("No 'system_user' parameter specified to maildrop driver.")); } $create_function = sprintf('sudo -u %s maildirmake %s', -- 2.11.0