From d0a1ed9227a5166aa56d37ccea142cdb1e0ae082 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 5 Feb 2017 11:54:27 -0500 Subject: [PATCH] Add configuration parameter to disable email configuration from user interface --- ChangeLog | 1 + app/Helper/MailHelper.php | 18 +++++++++++------- app/Locale/bs_BA/translations.php | 1 + app/Locale/cs_CZ/translations.php | 1 + app/Locale/da_DK/translations.php | 1 + app/Locale/de_DE/translations.php | 1 + app/Locale/el_GR/translations.php | 1 + app/Locale/es_ES/translations.php | 1 + app/Locale/fi_FI/translations.php | 1 + app/Locale/fr_FR/translations.php | 1 + app/Locale/hu_HU/translations.php | 1 + app/Locale/id_ID/translations.php | 1 + app/Locale/it_IT/translations.php | 1 + app/Locale/ja_JP/translations.php | 1 + app/Locale/ko_KR/translations.php | 1 + app/Locale/my_MY/translations.php | 1 + app/Locale/nb_NO/translations.php | 1 + app/Locale/nl_NL/translations.php | 1 + app/Locale/pl_PL/translations.php | 1 + app/Locale/pt_BR/translations.php | 1 + app/Locale/pt_PT/translations.php | 1 + app/Locale/ru_RU/translations.php | 1 + app/Locale/sr_Latn_RS/translations.php | 1 + app/Locale/sv_SE/translations.php | 1 + app/Locale/th_TH/translations.php | 1 + app/Locale/tr_TR/translations.php | 1 + app/Locale/zh_CN/translations.php | 1 + app/Template/config/email.php | 12 ++++++++---- app/constants.php | 1 + config.default.php | 5 ++++- doc/en_US/config.markdown | 5 ++++- doc/tr_TR/config.markdown | 5 ++++- 32 files changed, 58 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b36d5f93..44dd12a7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ Version 1.0.39 (unreleased) Improvements: +* Add configuration parameter to disable email configuration from user interface * Add email address field for projects * Improve forget password behaviour (notify the user that an email has been sent or not) * Do not display current project in board selector diff --git a/app/Helper/MailHelper.php b/app/Helper/MailHelper.php index 3b1c9e417..b42d83abf 100644 --- a/app/Helper/MailHelper.php +++ b/app/Helper/MailHelper.php @@ -54,27 +54,31 @@ class MailHelper extends Base */ public function getMailSenderAddress() { - $email = $this->configModel->get('mail_sender_address'); + if (MAIL_CONFIGURATION) { + $email = $this->configModel->get('mail_sender_address'); - if (!empty($email)) { - return $email; + if (! empty($email)) { + return $email; + } } return MAIL_FROM; } /** - * Get mail sender address + * Get mail transport * * @access public * @return string */ public function getMailTransport() { - $transport = $this->configModel->get('mail_transport'); + if (MAIL_CONFIGURATION) { + $transport = $this->configModel->get('mail_transport'); - if (!empty($transport)) { - return $transport; + if (! empty($transport)) { + return $transport; + } } return MAIL_TRANSPORT; diff --git a/app/Locale/bs_BA/translations.php b/app/Locale/bs_BA/translations.php index 9dfe2a3ec..a168f6dfc 100644 --- a/app/Locale/bs_BA/translations.php +++ b/app/Locale/bs_BA/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/cs_CZ/translations.php b/app/Locale/cs_CZ/translations.php index 8ab5aa7fb..96b50af32 100644 --- a/app/Locale/cs_CZ/translations.php +++ b/app/Locale/cs_CZ/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index eeb02e1d5..5d61581cf 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index 9d1ff3bff..61175e33f 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/el_GR/translations.php b/app/Locale/el_GR/translations.php index a4750705a..5e99a225c 100644 --- a/app/Locale/el_GR/translations.php +++ b/app/Locale/el_GR/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index f84f1db1c..2e3f42155 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index 40fddda4f..84ddf1ce3 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index 54df0379c..8e062c450 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -1313,4 +1313,5 @@ return array( 'TRL - Turkish Lira' => 'TRL - Livre turque', 'The project email is optional and could be used by several plugins.' => 'L\'adresse email d\'un projet est optionnel et pourrait être utilisé par plusieurs extensions.', 'The email project must be unique across all projects' => 'L\'adresse email d\'un projet doit être unique pour tous les projets', + 'The email configuration has been disabled by the administrator.' => 'La configuration des emails a été désactivée par l\'administrateur.', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index 2ad209a72..0d4beb007 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/id_ID/translations.php b/app/Locale/id_ID/translations.php index 938c6bd7f..78b15e984 100644 --- a/app/Locale/id_ID/translations.php +++ b/app/Locale/id_ID/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 6d4ceaf91..93128cd2d 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index 1c69d8093..820d1b866 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/ko_KR/translations.php b/app/Locale/ko_KR/translations.php index 1bf456336..56bac0682 100644 --- a/app/Locale/ko_KR/translations.php +++ b/app/Locale/ko_KR/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/my_MY/translations.php b/app/Locale/my_MY/translations.php index 588829d20..1121a8803 100644 --- a/app/Locale/my_MY/translations.php +++ b/app/Locale/my_MY/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/nb_NO/translations.php b/app/Locale/nb_NO/translations.php index 04d7c7183..2743009cb 100644 --- a/app/Locale/nb_NO/translations.php +++ b/app/Locale/nb_NO/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index 3bc9e51d7..45a8c5bcc 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index fdca3f07b..b8c4a2c79 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index e709bb4a6..a21e7cb81 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/pt_PT/translations.php b/app/Locale/pt_PT/translations.php index b70d97d9e..46c23f150 100644 --- a/app/Locale/pt_PT/translations.php +++ b/app/Locale/pt_PT/translations.php @@ -1313,4 +1313,5 @@ return array( 'TRL - Turkish Lira' => 'TRL - Lira Turca', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index 680340b1d..9cd167161 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index 75678bca7..3ebd5f684 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index 3f901a093..278c0f3cf 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index 26497b0a6..00a290dae 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index c3947fed5..dc25f8619 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index 5f45188bf..e49386df6 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -1313,4 +1313,5 @@ return array( // 'TRL - Turkish Lira' => '', // 'The project email is optional and could be used by several plugins.' => '', // 'The email project must be unique across all projects' => '', + // 'The email configuration has been disabled by the administrator.' => '', ); diff --git a/app/Template/config/email.php b/app/Template/config/email.php index bc2c2ae5d..be729f5dc 100644 --- a/app/Template/config/email.php +++ b/app/Template/config/email.php @@ -6,11 +6,15 @@
- form->label(t('Email sender address'), 'mail_sender_address') ?> - form->text('mail_sender_address', $values, $errors, array('placeholder="'.MAIL_FROM.'"')) ?> + + form->label(t('Email sender address'), 'mail_sender_address') ?> + form->text('mail_sender_address', $values, $errors, array('placeholder="'.MAIL_FROM.'"')) ?> - form->label(t('Email transport'), 'mail_transport') ?> - form->select('mail_transport', $mail_transports, $values, $errors) ?> + form->label(t('Email transport'), 'mail_transport') ?> + form->select('mail_transport', $mail_transports, $values, $errors) ?> + +

+
hook->render('template:config:email', array('values' => $values, 'errors' => $errors)) ?> diff --git a/app/constants.php b/app/constants.php index ba14cde6e..d62bfd3ae 100644 --- a/app/constants.php +++ b/app/constants.php @@ -98,6 +98,7 @@ defined('REVERSE_PROXY_DEFAULT_DOMAIN') or define('REVERSE_PROXY_DEFAULT_DOMAIN' defined('REMEMBER_ME_AUTH') or define('REMEMBER_ME_AUTH', true); // Mail configuration +defined('MAIL_CONFIGURATION') or define('MAIL_CONFIGURATION', true); defined('MAIL_FROM') or define('MAIL_FROM', 'notifications@kanboard.local'); defined('MAIL_TRANSPORT') or define('MAIL_TRANSPORT', 'mail'); defined('MAIL_SMTP_HOSTNAME') or define('MAIL_SMTP_HOSTNAME', ''); diff --git a/config.default.php b/config.default.php index 9b55295f9..1f08fbad1 100644 --- a/config.default.php +++ b/config.default.php @@ -34,7 +34,10 @@ define('CACHE_DIR', DATA_DIR.DIRECTORY_SEPARATOR.'cache'); // Folder for uploaded files (must be writeable by the web server user) define('FILES_DIR', DATA_DIR.DIRECTORY_SEPARATOR.'files'); -// E-mail address for the "From" header (notifications) +// Enable/disable email configuration from the user interface +define('MAIL_CONFIGURATION', true); + +// E-mail address used for the "From" header (notifications) define('MAIL_FROM', 'replace-me@kanboard.local'); // Mail transport available: "smtp", "sendmail", "mail" (PHP mail function), "postmark", "mailgun", "sendgrid" diff --git a/doc/en_US/config.markdown b/doc/en_US/config.markdown index a20469899..4ccaec274 100644 --- a/doc/en_US/config.markdown +++ b/doc/en_US/config.markdown @@ -65,7 +65,10 @@ Email configuration ------------------- ```php -// E-mail address for the "From" header (notifications) +// Enable/disable email configuration from the user interface +define('MAIL_CONFIGURATION', true); + +// E-mail address used for the "From" header (notifications) define('MAIL_FROM', 'notifications@kanboard.local'); // Mail transport to use: "smtp", "sendmail" or "mail" (PHP mail function) diff --git a/doc/tr_TR/config.markdown b/doc/tr_TR/config.markdown index dc28fbdf0..f09b4adf8 100644 --- a/doc/tr_TR/config.markdown +++ b/doc/tr_TR/config.markdown @@ -65,7 +65,10 @@ E-posta yapılandırması ------------------- ```php -// E-mail address for the "From" header (notifications) +// Enable/disable email configuration from the user interface +define('MAIL_CONFIGURATION', true); + +// E-mail address used for the "From" header (notifications) define('MAIL_FROM', 'notifications@kanboard.local'); // Mail transport to use: "smtp", "sendmail" or "mail" (PHP mail function)