Don't output default encryption option if no encryption is available
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 7 Jan 2011 18:56:42 +0000 (11:56 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 7 Jan 2011 18:56:58 +0000 (11:56 -0700)
imp/lib/IMP.php

index 834cbe9..2c73629 100644 (file)
@@ -665,7 +665,8 @@ class IMP
      * @param boolean $returnList  Whether to return a hash with options
      *                             instead of the options tag.
      *
-     * @return string  The list of option tags.
+     * @return mixed  The list of option tags. This is empty if no encryption
+     *                is available.
      */
     static public function encryptList($default = null, $returnList = false)
     {
@@ -673,7 +674,7 @@ class IMP
             $default = $GLOBALS['prefs']->getValue('default_encrypt');
         }
 
-        $enc_opts = array(self::ENCRYPT_NONE => _("None"));
+        $enc_opts = array();
         $output = '';
 
         if (!empty($GLOBALS['conf']['gnupg']['path']) &&
@@ -685,6 +686,13 @@ class IMP
             $enc_opts += $GLOBALS['injector']->getInstance('IMP_Crypt_Smime')->encryptList();
         }
 
+        if (!empty($enc_opts)) {
+            $enc_opts = array_merge(
+                array(self::ENCRYPT_NONE => _("None")),
+                $enc_opts
+            );
+        }
+
         if ($returnList) {
             return $enc_opts;
         }