From 93b8b7ab6d13286add59d726e765f2a7bfacf915 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 21 Jul 2017 12:34:22 +0200 Subject: [PATCH] W.I.P. SMIME: - Warn user if the SMIME private key is not configured - Do not show smime actions in compose dialog if private key is not configured --- mail/inc/class.mail_compose.inc.php | 38 +++++++++++++++++------------ mail/inc/class.mail_ui.inc.php | 6 +++++ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 7c6617ed07..604e0b1015 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -212,23 +212,29 @@ class mail_compose 'onExecute' => 'javaScript:app.mail.compose_saveDraft2fm', 'hint' => 'Save the drafted message as eml file into VFS' ), - 'smime_sign' => array ( - 'caption' => 'SMIME Sign', - 'icon' => 'smimeSignature', - 'group' => ++$group, - 'onExecute' => 'javaScript:app.mail.compose_setToggle', - 'checkbox' => true, - 'hint' => 'Sign your message with smime certificate' - ), - 'smime_encrypt' => array ( - 'caption' => 'SMIME Encryption', - 'icon' => 'smimeEncryption', - 'group' => ++$group, - 'onExecute' => 'javaScript:app.mail.compose_setToggle', - 'checkbox' => true, - 'hint' => 'Encrypt your message with smime certificate' - ) + ); + $credentials = Mail\Credentials::read($this->mail_bo->profileID, Mail\Credentials::SMIME, $GLOBALS['egw_info']['user']['account_id']); + if ($credentials['acc_smime_password']) + { + $actions = array_merge($actions, array( + 'smime_sign' => array ( + 'caption' => 'SMIME Sign', + 'icon' => 'smimeSignature', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.mail.compose_setToggle', + 'checkbox' => true, + 'hint' => 'Sign your message with smime certificate' + ), + 'smime_encrypt' => array ( + 'caption' => 'SMIME Encryption', + 'icon' => 'smimeEncryption', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.mail.compose_setToggle', + 'checkbox' => true, + 'hint' => 'Encrypt your message with smime certificate' + ))); + } foreach (self::$priorities as $key => $priority) { $actions['prty']['children'][$key] = array( diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 1a5840809b..e4d01f8c17 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -3087,6 +3087,12 @@ $filter['before']= date("d-M-Y", $cutoffdate2); } catch(Mail\Smime\PassphraseMissing $e) { + $credentials = Mail\Credentials::read($this->mail_bo->profileID, Mail\Credentials::SMIME, $GLOBALS['egw_info']['user']['account_id']); + if (empty($credentials['acc_smime_password'])) + { + self::callWizard($e->getMessage().' '.lang('Please configure your S/MIME private key in Encryption tab.')); + } + // do NOT include any default CSS $smimeHtml = $this->get_email_header(). '
'.lang("This message is smime encrypted and password protected.").'
'.