Add IMP_Exception
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 18 Dec 2009 18:49:53 +0000 (11:49 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 18 Dec 2009 20:04:42 +0000 (13:04 -0700)
imp/attachment.php
imp/config/hooks.php.dist
imp/lib/Exception.php [new file with mode: 0644]
imp/lib/Imap/Acl.php
imp/pgp.php
imp/saveimage.php
imp/smime.php

index 3dc4942..e5e8636 100644 (file)
@@ -23,7 +23,7 @@ $self_url = Horde::selfUrl(false, true, true);
 
 // Lets see if we are even able to send the user an attachment.
 if (!$conf['compose']['link_attachments']) {
-    throw new Horde_Exception(_("Linked attachments are forbidden."));
+    throw new IMP_Exception(_("Linked attachments are forbidden."));
 }
 
 // Gather required form variables.
@@ -31,13 +31,13 @@ $mail_user = Horde_Util::getFormData('u');
 $time_stamp = Horde_Util::getFormData('t');
 $file_name = Horde_Util::getFormData('f');
 if (is_null($mail_user) || is_null($time_stamp) || is_null($file_name)) {
-    throw new Horde_Exception(_("The attachment was not found."));
+    throw new IMP_Exception(_("The attachment was not found."));
 }
 
 // Initialize the VFS.
 $vfsroot = VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
 if ($vfsroot instanceof PEAR_Error) {
-    throw new Horde_Exception(sprintf(_("Could not create the VFS backend: %s"), $vfsroot->getMessage()));
+    throw new IMP_Exception(sprintf(_("Could not create the VFS backend: %s"), $vfsroot->getMessage()));
 }
 
 // Check if the file exists.
@@ -46,7 +46,7 @@ $time_stamp = basename($time_stamp);
 $file_name = escapeshellcmd(basename($file_name));
 $full_path = sprintf(IMP_Compose::VFS_LINK_ATTACH_PATH . '/%s/%d', $mail_user, $time_stamp);
 if (!$vfsroot->exists($full_path, $file_name)) {
-    throw new Horde_Exception(_("The specified attachment does not exist. It may have been deleted by the original sender."));
+    throw new IMP_Exception(_("The specified attachment does not exist. It may have been deleted by the original sender."));
 }
 
 // Check to see if we need to send a verification message.
@@ -110,7 +110,7 @@ if ($conf['compose']['link_attachments_notify']) {
 $file_data = $vfsroot->read($full_path, $file_name);
 if ($file_data instanceof PEAR_Error) {
     Horde::logMessage($file_data, __FILE__, __LINE__, PEAR_LOG_ERR);
-    throw new Horde_Exception(_("The specified file cannot be read."));
+    throw new IMP_Exception(_("The specified file cannot be read."));
 }
 $mime_type = Horde_Mime_Magic::analyzeData($file_data, isset($conf['mime']['magic_db']) ? $conf['mime']['magic_db'] : null);
 if ($mime_type === false) {
index fbf21e6..0f30312 100644 (file)
@@ -498,11 +498,11 @@ class IMP_Hooks
 //
 //        $session = ssh2_connect($host);
 //        if (!$session) {
-//            throw new Horde_Exception(_("Connection to server failed."), 'horde.error');
+//            throw new IMP_Exception(_("Connection to server failed."), 'horde.error');
 //        }
 //
 //        if (!ssh2_auth_password($session, $user, $pass)) {
-//            throw new Horde_Exception(_("Authentication failed."), 'horde.error');
+//            throw new IMP_Exception(_("Authentication failed."), 'horde.error');
 //        }
 //
 //        $stream = ssh2_exec($session, $command, false);
@@ -516,7 +516,7 @@ class IMP_Hooks
      * Retrieves public S/MIME keys of message recipients.
      *
      * The hook will be called first when searching for the keys, and further
-     * lookup techniques will only be used if the hook throws an excpetion or
+     * lookup techniques will only be used if the hook throws an exception or
      * returns an empty result.
      *
      * @param string $address  The email address of the recipient.
@@ -558,7 +558,7 @@ class IMP_Hooks
      * Retrieves public PGP keys of message recipients.
      *
      * The hook will be called first when searching for the keys, and further
-     * lookup techniques will only be used if the hook throws an excpetion or
+     * lookup techniques will only be used if the hook throws an exception or
      * returns an empty result.
      *
      * @param string $address  The email address of the recipient.
diff --git a/imp/lib/Exception.php b/imp/lib/Exception.php
new file mode 100644 (file)
index 0000000..743c8af
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Base exception class for IMP.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael Slusarz <jan@horde.org>
+ * @package IMP
+ */
+class IMP_Exception extends Horde_Exception
+{
+}
index 0459fcd..9f11d82 100644 (file)
@@ -40,6 +40,7 @@ class IMP_Imap_Acl
      * It will only create a new instance if no instance currently exists.
      *
      * @return IMP_Imap_Acl  The created concrete instance.
+     * @throws Horde_Exception
      */
     static public function singleton()
     {
@@ -52,6 +53,8 @@ class IMP_Imap_Acl
 
     /**
      * Constructor.
+     *
+     * @throws Horde_Exception
      */
     protected function __construct()
     {
index 0f54a32..9725d97 100644 (file)
@@ -265,7 +265,7 @@ case 'save_attachment_public_key':
     $contents = IMP_Contents::singleton(Horde_Util::getFormData('uid') . IMP::IDX_SEP . Horde_Util::getFormData('mailbox'));
     $mime_part = $contents->getMIMEPart(Horde_Util::getFormData('mime_id'));
     if (empty($mime_part)) {
-        throw new Horde_Exception('Cannot retrieve public key from message.');
+        throw new IMP_Exception('Cannot retrieve public key from message.');
     }
 
     /* Add the public key to the storage system. */
index 4894a74..914fdfd 100644 (file)
@@ -40,7 +40,7 @@ case 'save_image':
 
 if (!$registry->hasMethod('images/selectGalleries') ||
     !$registry->hasMethod('images/saveImage')) {
-    throw new Horde_Exception(_("Image saving is not available."));
+    throw new IMP_Exception(_("Image saving is not available."));
 }
 
 /* Build the template. */
index 46f8f65..c0eb48a 100644 (file)
@@ -187,7 +187,7 @@ case 'save_attachment_public_key':
     $contents = IMP_Contents::singleton(Horde_Util::getFormData('uid') . IMP::IDX_SEP . Horde_Util::getFormData('mailbox'));
     $mime_part = $contents->getMIMEPart(Horde_Util::getFormData('mime_id'));
     if (empty($mime_part)) {
-        throw new Horde_Exception('Cannot retrieve public key from message.');
+        throw new IMP_Exception('Cannot retrieve public key from message.');
     }
 
     /* Add the public key to the storage system. */