From 7ce958ecd987745e545fc40fdc090c6430053b5d Mon Sep 17 00:00:00 2001 From: Kyle Francis <franck6@rpi.edu> Date: Fri, 01 Apr 2016 12:32:57 -0400 Subject: [PATCH] Added attach pubkey checkbox in compose UI, added preferences setting for attach pubkey by default --- plugins/enigma/enigma.php | 20 ++++++++++++++++++++ plugins/enigma/lib/enigma_ui.php | 5 +++++ plugins/enigma/localization/en_US.inc | 2 ++ plugins/enigma/config.inc.php.dist | 3 +++ 4 files changed, 30 insertions(+), 0 deletions(-) diff --git a/plugins/enigma/config.inc.php.dist b/plugins/enigma/config.inc.php.dist index 17e3265..57dfcad 100644 --- a/plugins/enigma/config.inc.php.dist +++ b/plugins/enigma/config.inc.php.dist @@ -28,6 +28,9 @@ // Enable encrypting all messages by default $config['enigma_encrypt_all'] = false; +// Enable signing all messages by default +$config['enigma_attach_pubkey'] = false; + // Default for how long to store private key passwords (in minutes). // When set to 0 passwords will be stored for the whole session. $config['enigma_password_time'] = 5; diff --git a/plugins/enigma/enigma.php b/plugins/enigma/enigma.php index 8e8ded2..c9471ac 100644 --- a/plugins/enigma/enigma.php +++ b/plugins/enigma/enigma.php @@ -339,6 +339,25 @@ ); } + if (!isset($no_override['enigma_attach_pubkey'])) { + if (!$p['current']) { + $p['blocks']['main']['content'] = true; + return $p; + } + + $field_id = 'rcmfd_enigma_attach_pubkey'; + $input = new html_checkbox(array( + 'name' => '_enigma_attach_pubkey', + 'id' => $field_id, + 'value' => 1, + )); + + $p['blocks']['main']['options']['enigma_encrypt_all'] = array( + 'title' => html::label($field_id, $this->gettext('attachpubkeydefault')), + 'content' => $input->show($this->rc->config->get('enigma_attach_pubkey') ? 1 : 0), + ); + } + if (!isset($no_override['enigma_password_time'])) { if (!$p['current']) { $p['blocks']['main']['content'] = true; @@ -380,6 +399,7 @@ 'enigma_encryption' => (bool) rcube_utils::get_input_value('_enigma_encryption', rcube_utils::INPUT_POST), 'enigma_sign_all' => (bool) rcube_utils::get_input_value('_enigma_sign_all', rcube_utils::INPUT_POST), 'enigma_encrypt_all' => (bool) rcube_utils::get_input_value('_enigma_encrypt_all', rcube_utils::INPUT_POST), + 'enigma_attach_pubkey' => (bool) rcube_utils::get_input_value('_enigma_attach_pubkey', rcube_utils::INPUT_POST), 'enigma_password_time' => intval(rcube_utils::get_input_value('_enigma_password_time', rcube_utils::INPUT_POST)), ); } diff --git a/plugins/enigma/lib/enigma_ui.php b/plugins/enigma/lib/enigma_ui.php index f0963dc..3ccacd4 100644 --- a/plugins/enigma/lib/enigma_ui.php +++ b/plugins/enigma/lib/enigma_ui.php @@ -730,6 +730,11 @@ $menu->add(null, $chbox->show($this->rc->config->get('enigma_encrypt_all') ? 1 : 0, array('name' => '_enigma_encrypt', 'id' => 'enigmaencryptopt'))); + $menu->add(null, html::label(array('for' => 'enigmaattachpubkeyopt'), + rcube::Q($this->enigma->gettext('attachpubkeymsg')))); + $menu->add(null, $chbox->show($this->rc->config->get('enigma_attach_pubkey') ? 1 : 0, + array('name' => '_enigma_attachpubkey', 'id' => 'enigmaattachpubkeyopt'))); + $menu = html::div(array('id' => 'enigmamenu', 'class' => 'popupmenu'), $menu->show()); // Options menu contents diff --git a/plugins/enigma/localization/en_US.inc b/plugins/enigma/localization/en_US.inc index 0e4d2b4..5224ca5 100644 --- a/plugins/enigma/localization/en_US.inc +++ b/plugins/enigma/localization/en_US.inc @@ -53,6 +53,7 @@ $labels['supportdecryption'] = 'Enable message decryption'; $labels['signdefault'] = 'Sign all messages by default'; $labels['encryptdefault'] = 'Encrypt all messages by default'; +$labels['attachpubkeydefault'] = 'Attach my public PGP key by default'; $labels['passwordtime'] = 'Keep private key passwords for'; $labels['nminutes'] = '$m minute(s)'; $labels['wholesession'] = 'the whole session'; @@ -82,6 +83,7 @@ $labels['enterkeypasstitle'] = 'Enter key passphrase'; $labels['enterkeypass'] = 'A passphrase is needed to unlock the secret key ($keyid) for user: $user.'; $labels['arialabelkeyexportoptions'] = 'Keys export options'; +$labels['attachpubkeymsg'] = 'Attach my public key'; $messages = array(); $messages['sigvalid'] = 'Verified signature from $sender.'; -- Gitblit v1.9.1