From 87b9f7bae604f9e6e24642eb138c16b676ff30b2 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 12 Nov 2016 15:19:26 +0900 Subject: [PATCH] Initial implementation of Notification Settings screen --- common/lang/en.php | 3 + common/lang/ko.php | 3 + modules/admin/admin.admin.controller.php | 66 ++++++ modules/admin/admin.admin.view.php | 22 ++ modules/admin/conf/module.xml | 2 + modules/admin/lang/en.php | 1 + modules/admin/lang/ko.php | 1 + modules/admin/tpl/config_header.html | 1 + modules/admin/tpl/config_notification.html | 214 ++++++++++++++++++++ modules/admin/tpl/js/notification_config.js | 96 +++++++++ modules/advanced_mailer/lang/en.php | 3 + modules/advanced_mailer/lang/ko.php | 3 + 12 files changed, 415 insertions(+) create mode 100644 modules/admin/tpl/config_notification.html create mode 100644 modules/admin/tpl/js/notification_config.js diff --git a/common/lang/en.php b/common/lang/en.php index 65429151c..a25ad207c 100644 --- a/common/lang/en.php +++ b/common/lang/en.php @@ -110,6 +110,9 @@ $lang->comment = 'Comment'; $lang->description = 'Description'; $lang->trackback = 'Trackback'; $lang->tag = 'Tag'; +$lang->mail = 'Mail'; +$lang->email = 'E-mail'; +$lang->sms = 'SMS'; $lang->allow_comment = 'Allow Comments'; $lang->lock_comment = 'Block Comments'; $lang->allow_trackback = 'Allow Trackbacks'; diff --git a/common/lang/ko.php b/common/lang/ko.php index 720909c06..043e085a2 100644 --- a/common/lang/ko.php +++ b/common/lang/ko.php @@ -110,6 +110,9 @@ $lang->comment = '댓글'; $lang->description = '설명'; $lang->trackback = '엮인글'; $lang->tag = '태그'; +$lang->mail = '메일'; +$lang->email = '이메일'; +$lang->sms = 'SMS'; $lang->allow_comment = '댓글 허용'; $lang->lock_comment = '댓글 잠금'; $lang->allow_trackback = '엮인글 허용'; diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 2696fc87f..848e68ba4 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -555,6 +555,72 @@ class adminAdminController extends admin $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigGeneral')); } + /** + * Update notification configuration. + */ + function procAdminUpdateNotification() + { + $vars = Context::getRequestVars(); + + // Load advanced mailer module (for lang). + $oAdvancedMailerAdminView = getAdminView('advanced_mailer'); + + // Validate the mail driver. + $mail_drivers = Rhymix\Framework\Mail::getSupportedDrivers(); + $mail_driver = $vars->mail_driver; + if (!array_key_exists($mail_driver, $mail_drivers)) + { + return new Object(-1, 'msg_advanced_mailer_sending_method_is_invalid'); + } + + // Validate the mail driver settings. + $mail_driver_config = array(); + foreach ($mail_drivers[$mail_driver]['required'] as $conf_name) + { + $conf_value = $vars->{'mail_' . $mail_driver . '_' . $conf_name} ?: null; + if (!$conf_value) + { + return new Object(-1, 'msg_advanced_mailer_smtp_host_is_invalid'); + } + $mail_driver_config[$conf_name] = $conf_value; + } + + // Validate the SMS driver. + $sms_drivers = Rhymix\Framework\SMS::getSupportedDrivers(); + $sms_driver = $vars->sms_driver; + if (!array_key_exists($sms_driver, $sms_drivers)) + { + return new Object(-1, 'msg_advanced_mailer_sending_method_is_invalid'); + } + + // Validate the SMS driver settings. + $sms_driver_config = array(); + foreach ($sms_drivers[$sms_driver]['required'] as $conf_name) + { + $conf_value = $vars->{'sms_' . $sms_driver . '_' . $conf_name} ?: null; + if (!$conf_value) + { + return new Object(-1, 'msg_advanced_mailer_smtp_host_is_invalid'); + } + $sms_driver_config[$conf_name] = $conf_value; + } + foreach ($sms_drivers[$sms_driver]['optional'] as $conf_name) + { + $conf_value = $vars->{'sms_' . $sms_driver . '_' . $conf_name} ?: null; + $sms_driver_config[$conf_name] = $conf_value; + } + + // Save. + Rhymix\Framework\Config::set("mail.type", $mail_driver); + Rhymix\Framework\Config::set("mail.$mail_driver", $mail_driver_config); + Rhymix\Framework\Config::set("sms.type", $sms_driver); + Rhymix\Framework\Config::set("sms.$sms_driver", $sms_driver_config); + Rhymix\Framework\Config::save(); + + $this->setMessage('success_updated'); + $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigNotification')); + } + /** * Update security configuration. */ diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index f1535af65..1f6459f7f 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -445,6 +445,28 @@ class adminAdminView extends admin $this->setTemplateFile('config_general'); } + /** + * Display Notification Settings page + * @return void + */ + function dispAdminConfigNotification() + { + // Load advanced mailer module (for lang). + $oAdvancedMailerAdminView = getAdminView('advanced_mailer'); + + // Load mail drivers. + $mail_drivers = Rhymix\Framework\Mail::getSupportedDrivers(); + Context::set('mail_drivers', $mail_drivers); + Context::set('mail_driver', config('mail.type') ?: 'mailfunction'); + + // Load SMS drivers. + $sms_drivers = Rhymix\Framework\SMS::getSupportedDrivers(); + Context::set('sms_drivers', $sms_drivers); + Context::set('sms_driver', config('sms.type') ?: 'dummy'); + + $this->setTemplateFile('config_notification'); + } + /** * Display Security Settings page * @return void diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index b6fd159a4..7b21ba003 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -5,6 +5,7 @@ + @@ -24,6 +25,7 @@ + diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index d7bd7c2e6..57443f0c7 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -2,6 +2,7 @@ $lang->admin = 'Admin'; $lang->cmd_configure = 'Configure'; $lang->subtitle_primary = 'General Settings'; +$lang->subtitle_notification = 'Notification Settings'; $lang->subtitle_security = 'Security Settings'; $lang->subtitle_advanced = 'Advanced Settings'; $lang->subtitle_debug = 'Debug Settings'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index e1cb5490e..2e74ed5e4 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -2,6 +2,7 @@ $lang->admin = '관리자'; $lang->cmd_configure = '설정하기'; $lang->subtitle_primary = '기본 설정'; +$lang->subtitle_notification = '알림 설정'; $lang->subtitle_security = '보안 설정'; $lang->subtitle_advanced = '고급 설정'; $lang->subtitle_debug = '디버그 설정'; diff --git a/modules/admin/tpl/config_header.html b/modules/admin/tpl/config_header.html index dabe0f771..4fea11641 100644 --- a/modules/admin/tpl/config_header.html +++ b/modules/admin/tpl/config_header.html @@ -5,6 +5,7 @@
  • {$lang->subtitle_primary}
  • +
  • {$lang->subtitle_notification}
  • {$lang->subtitle_security}
  • {$lang->subtitle_advanced}
  • {$lang->subtitle_debug}
  • diff --git a/modules/admin/tpl/config_notification.html b/modules/admin/tpl/config_notification.html new file mode 100644 index 000000000..bf2e8aaae --- /dev/null +++ b/modules/admin/tpl/config_notification.html @@ -0,0 +1,214 @@ + + +
    +

    {$XE_VALIDATOR_MESSAGE}

    +
    + + + +
    + + + + +
    + +

    {$lang->email}

    + +
    + +
    + +

    + {$lang->msg_advanced_mailer_about_dummy}
    {$lang->msg_advanced_mailer_about_dummy_exceptions} +

    +
    +
    + + + + + + {@ $conf_value = escape(config("mail.$driver_name.$conf_name"))} + + +
    + +
    + + +
    +
    + + + +
    + +
    + +
    +
    + + + +
    + +
    + + + +
    +
    + + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + + + + + +
    + +
    + +

    {$lang->sms}

    + +
    + +
    + +
    +
    + + + + + {@ $conf_names = array_merge($driver_definition['required'], $driver_definition['optional'])} + + + + {@ $conf_value = escape(config("sms.$driver_name.$conf_name"))} + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + + + + + +
    + +
    +
    + +
    +
    +
    diff --git a/modules/admin/tpl/js/notification_config.js b/modules/admin/tpl/js/notification_config.js new file mode 100644 index 000000000..1dc70f7f1 --- /dev/null +++ b/modules/admin/tpl/js/notification_config.js @@ -0,0 +1,96 @@ + +(function($) { + + $(function() { + + $("#mail_driver").on("change", function() { + var selected_driver = $(this).val(); + $(this).parents("section").find("div.x_control-group.hidden-by-default, p.x_help-block").not(".show-always").each(function() { + if ($(this).hasClass("show-for-" + selected_driver)) { + $(this).show(); + } else { + $(this).hide(); + } + }); + var reply_to = $("#mail_reply_to").parents("div.x_control-group"); + if (selected_driver === "woorimail") { + reply_to.hide(); + } else { + reply_to.show(); + } + }).triggerHandler("change"); + + $("#sms_driver").on("change", function() { + var selected_driver = $(this).val(); + $(this).parents("section").find("div.x_control-group.hidden-by-default, p.x_help-block").not(".show-always").each(function() { + if ($(this).hasClass("show-for-" + selected_driver)) { + $(this).show(); + } else { + $(this).hide(); + } + }); + }).triggerHandler("change"); + + $("#mail_smtp_manual_entry").on("change", function() { + var auto_fill = $(this).val(); + if (auto_fill === 'gmail') { + $("#mail_smtp_smtp_host").val('smtp.gmail.com'); + $("#mail_smtp_smtp_port").val('465'); + $("#mail_smtp_security_ssl").prop("checked", true).parent().addClass("checked"); + $("#mail_smtp_security_tls").parent().removeClass("checked"); + $("#mail_smtp_security_none").parent().removeClass("checked"); + $("#mail_force_sender").prop("checked", true).parent().addClass("checked"); + } + if (auto_fill === 'hanmail') { + $("#mail_smtp_smtp_host").val('smtp.daum.net'); + $("#mail_smtp_smtp_port").val('465'); + $("#mail_smtp_security_ssl").prop("checked", true).parent().addClass("checked"); + $("#mail_smtp_security_tls").parent().removeClass("checked"); + $("#mail_smtp_security_none").parent().removeClass("checked"); + $("#mail_force_sender").prop("checked", true).parent().addClass("checked"); + } + if (auto_fill === 'naver') { + $("#mail_smtp_smtp_host").val('smtp.naver.com'); + $("#mail_smtp_smtp_port").val('587'); + $("#mail_smtp_security_tls").prop("checked", true).parent().addClass("checked"); + $("#mail_smtp_security_ssl").parent().removeClass("checked"); + $("#mail_smtp_security_none").parent().removeClass("checked"); + $("#mail_force_sender").prop("checked", true).parent().addClass("checked"); + } + if (auto_fill === 'worksmobile') { + $("#mail_smtp_smtp_host").val('smtp.worksmobile.com'); + $("#mail_smtp_smtp_port").val('587'); + $("#mail_smtp_security_tls").prop("checked", true).parent().addClass("checked"); + $("#mail_smtp_security_ssl").parent().removeClass("checked"); + $("#mail_smtp_security_none").parent().removeClass("checked"); + $("#mail_force_sender").prop("checked", true).parent().addClass("checked"); + } + if (auto_fill === 'outlook') { + $("#mail_smtp_smtp_host").val('smtp-mail.outlook.com'); + $("#mail_smtp_smtp_port").val('587'); + $("#mail_smtp_security_tls").prop("checked", true).parent().addClass("checked"); + $("#mail_smtp_security_ssl").parent().removeClass("checked"); + $("#mail_smtp_security_none").parent().removeClass("checked"); + $("#mail_force_sender").prop("checked", true).parent().addClass("checked"); + } + if (auto_fill === 'yahoo') { + $("#mail_smtp_smtp_host").val('smtp.mail.yahoo.com'); + $("#mail_smtp_smtp_port").val('465'); + $("#mail_smtp_security_ssl").prop("checked", true).parent().addClass("checked"); + $("#mail_smtp_security_tls").parent().removeClass("checked"); + $("#mail_smtp_security_none").parent().removeClass("checked"); + $("#mail_force_sender").prop("checked", true).parent().addClass("checked"); + } + }); + + $("#mail_woorimail_account_type_free,#mail_woorimail_account_type_paid").on("change", function() { + if ($("#mail_woorimail_account_type_paid").is(":checked")) { + $("#mail_reply_to").attr("disabled", "disabled"); + } else { + $("#mail_reply_to").removeAttr("disabled"); + } + }).triggerHandler("change"); + + }); + +} (jQuery)); diff --git a/modules/advanced_mailer/lang/en.php b/modules/advanced_mailer/lang/en.php index 62088cf75..79e7a92b9 100644 --- a/modules/advanced_mailer/lang/en.php +++ b/modules/advanced_mailer/lang/en.php @@ -24,6 +24,8 @@ $lang->cmd_advanced_mailer_smtp_security_tls = 'TLS (STARTTLS)'; $lang->cmd_advanced_mailer_smtp_security_none = 'None'; $lang->cmd_advanced_mailer_smtp_user = 'Username'; $lang->cmd_advanced_mailer_smtp_pass = 'Password'; +$lang->cmd_advanced_mailer_api_key = 'API key'; +$lang->cmd_advanced_mailer_api_secret = 'API secret'; $lang->cmd_advanced_mailer_api_domain = 'Domain'; $lang->cmd_advanced_mailer_api_token = 'API token'; $lang->cmd_advanced_mailer_api_type = 'API type'; @@ -31,6 +33,7 @@ $lang->cmd_advanced_mailer_api_type_free = 'Free account'; $lang->cmd_advanced_mailer_api_type_paid = 'Paid account'; $lang->cmd_advanced_mailer_api_user = 'Username'; $lang->cmd_advanced_mailer_api_pass = 'Password'; +$lang->cmd_advanced_mailer_sender_key = 'Sender key'; $lang->cmd_advanced_mailer_sender_identity = 'Sender Identity'; $lang->cmd_advanced_mailer_about_sender_identity = 'Sender identity will be applied to the webmaster\'s name and email address in the member module as well.'; $lang->cmd_advanced_mailer_sender_name = 'Sender\'s name'; diff --git a/modules/advanced_mailer/lang/ko.php b/modules/advanced_mailer/lang/ko.php index 7da8ce9e2..540c84a71 100644 --- a/modules/advanced_mailer/lang/ko.php +++ b/modules/advanced_mailer/lang/ko.php @@ -24,6 +24,8 @@ $lang->cmd_advanced_mailer_smtp_security_tls = 'TLS (STARTTLS)'; $lang->cmd_advanced_mailer_smtp_security_none = '사용하지 않음'; $lang->cmd_advanced_mailer_smtp_user = '아이디'; $lang->cmd_advanced_mailer_smtp_pass = '비밀번호'; +$lang->cmd_advanced_mailer_api_key = 'API 키'; +$lang->cmd_advanced_mailer_api_secret = 'API 비밀'; $lang->cmd_advanced_mailer_api_domain = '도메인'; $lang->cmd_advanced_mailer_api_token = 'API 토큰'; $lang->cmd_advanced_mailer_api_type = 'API 구분'; @@ -31,6 +33,7 @@ $lang->cmd_advanced_mailer_api_type_free = '무료'; $lang->cmd_advanced_mailer_api_type_paid = '유료'; $lang->cmd_advanced_mailer_api_user = '아이디'; $lang->cmd_advanced_mailer_api_pass = '비밀번호'; +$lang->cmd_advanced_mailer_sender_key = '센더 키'; $lang->cmd_advanced_mailer_sender_identity = '보낸이 설정'; $lang->cmd_advanced_mailer_about_sender_identity = '보낸이 설정은 회원 모듈의 웹마스터 이름 및 메일 주소에도 동일하게 적용됩니다.'; $lang->cmd_advanced_mailer_sender_name = '보낸이 이름';