Allow to lock default_encrypt preference.
authorJan Schneider <jan@horde.org>
Mon, 15 Jun 2009 22:43:22 +0000 (00:43 +0200)
committerJan Schneider <jan@horde.org>
Mon, 15 Jun 2009 22:43:41 +0000 (00:43 +0200)
imp/compose.php
imp/docs/CHANGES
imp/lib/IMP.php

index 10d6ce1..d1a1589 100644 (file)
@@ -424,7 +424,7 @@ case 'send_message':
         'save_attachments' => Horde_Util::getFormData('save_attachments_select'),
         'reply_type' => Horde_Util::getFormData('reply_type'),
         'reply_index' => (empty($reply_index) ? null : $reply_index . IMP::IDX_SEP . $thismailbox),
-        'encrypt' => Horde_Util::getFormData('encrypt_options'),
+        'encrypt' => $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : Horde_Util::getFormData('encrypt_options'),
         'priority' => Horde_Util::getFormData('x_priority'),
         'readreceipt' => Horde_Util::getFormData('request_read_receipt')
     );
@@ -730,8 +730,10 @@ if ($pgp_passphrase_dialog || $pgp_symmetric_passphrase_dialog) {
 
 /* If PGP encryption is set by default, and we have a recipient list on first
  * load, make sure we have public keys for all recipients. */
-$encrypt_options = Horde_Util::getFormData('encrypt_options');
-if ($prefs->getValue('use_pgp')) {
+$encrypt_options = $prefs->isLocked('default_encrypt')
+      ? $prefs->getValue('default_encrypt')
+      : Horde_Util::getFormData('encrypt_options');
+if ($prefs->getValue('use_pgp') && !$prefs->isLocked('default_encrypt')) {
     $default_encrypt = $prefs->getValue('default_encrypt');
     if (!$token &&
         in_array($default_encrypt, array(IMP::PGP_ENCRYPT, IMP::PGP_SIGNENC))) {
@@ -1158,9 +1160,13 @@ if ($redirect) {
 
     $t->set('use_encrypt', ($prefs->getValue('use_pgp') || $prefs->getValue('use_smime')));
     if ($t->get('use_encrypt')) {
-        $t->set('encrypt_label', Horde::label('encrypt_options', _("Encr_yption Options")));
-        $t->set('encrypt_options', IMP::encryptList($encrypt_options));
-        $t->set('help-encrypt', Horde_Help::link('imp', 'compose-options-encrypt'));
+        if ($prefs->isLocked('default_encrypt')) {
+            $t->set('use_encrypt', false);
+        } else {
+            $t->set('encrypt_label', Horde::label('encrypt_options', _("Encr_yption Options")));
+            $t->set('encrypt_options', IMP::encryptList($encrypt_options));
+            $t->set('help-encrypt', Horde_Help::link('imp', 'compose-options-encrypt'));
+        }
         $t->set('pgp_options', ($prefs->getValue('use_pgp') && $prefs->getValue('pgp_public_key')));
         if ($t->get('pgp_options')) {
             $t->set('pgp_attach_pubkey', Horde_Util::getFormData('pgp_attach_pubkey', $prefs->getValue('pgp_attach_pubkey')));
index 9bb8565..a63b594 100644 (file)
@@ -83,7 +83,8 @@ v5.0-git
 v4.3.5-cvs
 ----------
 
-[mjr] Add example hook showing how to set the add_source preference (Bug #8285)
+[jan] Allow to lock default_encrypt preference.
+[mjr] Add example hook showing how to set the add_source preference (Bug #8285).
 [mms] Fix unqualified domain preference (Bug #8272).
 [jan] Highlight signed messages depending on the signature verification.
 [mms] Fix display_folder hook (m.gabriel@das-netzwerkteam.de, Bug #8254).
index d3fdd1d..e858cef 100644 (file)
@@ -1037,11 +1037,13 @@ class IMP
     /**
      * Return a list of valid encrypt HTML option tags.
      *
-     * @param string $default  The default encrypt option.
+     * @param string $default      The default encrypt option.
+     * @param boolean $returnList  Whether to return a hash with options
+     *                             instead of the options tag.
      *
      * @return string  The list of option tags.
      */
-    static public function encryptList($default = null)
+    static public function encryptList($default = null, $returnList = false)
     {
         if (is_null($default)) {
             $default = $GLOBALS['prefs']->getValue('default_encrypt');
@@ -1068,6 +1070,10 @@ class IMP
             );
         }
 
+        if ($returnList) {
+            return $enc_opts;
+        }
+
         foreach ($enc_opts as $key => $val) {
              $output .= '<option value="' . $key . '"' . (($default == $key) ? ' selected="selected"' : '') . '>' . $val . '</option>' . "\n";
         }