From: Jan Schneider Date: Mon, 15 Jun 2009 22:43:22 +0000 (+0200) Subject: Allow to lock default_encrypt preference. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a69203fa5eba30213cbad48fbf1f9e74fa93b508;p=horde.git Allow to lock default_encrypt preference. --- diff --git a/imp/compose.php b/imp/compose.php index 10d6ce1f5..d1a158990 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -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'))); diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 9bb8565fc..a63b594bb 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -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). diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index d3fdd1d8e..e858cef5e 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -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 .= '' . "\n"; }