Vilma: Convert PEAR::raiseError to Vilma_Exception
authorBen Klang <ben@alkaloid.net>
Sat, 2 Jan 2010 17:23:28 +0000 (12:23 -0500)
committerBen Klang <ben@alkaloid.net>
Sat, 2 Jan 2010 17:23:28 +0000 (12:23 -0500)
vilma/lib/Driver.php
vilma/lib/Exception.php [new file with mode: 0644]
vilma/lib/MailboxDriver/imap.php
vilma/lib/MailboxDriver/maildrop.php
vilma/lib/MailboxDriver/null.php

index 14b4f85..303a191 100644 (file)
@@ -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 (file)
index 0000000..800d8e3
--- /dev/null
@@ -0,0 +1 @@
+class Vilma_Exception extends Horde_Exception {}
\ No newline at end of file
index 966cfc2..9cf355c 100644 (file)
@@ -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));
         }
     }
 
index 5505106..7784d0a 100644 (file)
@@ -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',
index 32d1b0a..8fb14b3 100644 (file)
@@ -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',