From 211a201e042706f5ed904509fc635c871c94843e Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 13 Dec 2016 23:57:04 +0900 Subject: [PATCH 1/5] Update advanced mailer module to accommodate both email and SMS --- .../advanced_mailer.admin.controller.php | 4 +++- .../advanced_mailer.admin.view.php | 6 ++--- modules/advanced_mailer/conf/info.xml | 18 +++++++------- modules/advanced_mailer/conf/module.xml | 11 +++++---- modules/advanced_mailer/lang/en.php | 11 +++++---- modules/advanced_mailer/lang/ko.php | 11 +++++---- modules/advanced_mailer/tpl/common.html | 9 ++++--- modules/advanced_mailer/tpl/config.html | 24 +++++++++++++++++-- modules/advanced_mailer/tpl/js/config.js | 4 ++-- modules/advanced_mailer/tpl/test.html | 4 ++-- 10 files changed, 68 insertions(+), 34 deletions(-) diff --git a/modules/advanced_mailer/advanced_mailer.admin.controller.php b/modules/advanced_mailer/advanced_mailer.admin.controller.php index 70e69d07e..62ffbb92e 100644 --- a/modules/advanced_mailer/advanced_mailer.admin.controller.php +++ b/modules/advanced_mailer/advanced_mailer.admin.controller.php @@ -20,6 +20,8 @@ class Advanced_MailerAdminController extends Advanced_Mailer $config = $this->getConfig(); $config->log_sent_mail = toBool($vars->log_sent_mail); $config->log_errors = toBool($vars->log_errors); + $config->log_sent_sms = toBool($vars->log_sent_sms); + $config->log_sms_errors = toBool($vars->log_sms_errors); $output = getController('module')->insertModuleConfig('advanced_mailer', $config); if ($output->toBool()) { @@ -180,7 +182,7 @@ class Advanced_MailerAdminController extends Advanced_Mailer /** * Send a test email using a temporary configuration. */ - public function procAdvanced_MailerAdminTestSend() + public function procAdvanced_MailerAdminTestSendMail() { $advanced_mailer_config = $this->getConfig(); $recipient_config = Context::gets('recipient_name', 'recipient_email'); diff --git a/modules/advanced_mailer/advanced_mailer.admin.view.php b/modules/advanced_mailer/advanced_mailer.admin.view.php index 4b6129bff..b0092505e 100644 --- a/modules/advanced_mailer/advanced_mailer.admin.view.php +++ b/modules/advanced_mailer/advanced_mailer.admin.view.php @@ -112,7 +112,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer /** * Display the test send form. */ - public function dispAdvanced_MailerAdminTestConfig() + public function dispAdvanced_MailerAdminMailTest() { $advanced_mailer_config = $this->getConfig(); $sending_methods = Rhymix\Framework\Mail::getSupportedDrivers(); @@ -128,7 +128,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer /** * Display the sent mail log. */ - public function dispAdvanced_MailerAdminSentMail() + public function dispAdvanced_MailerAdminMailLog() { $obj = new stdClass(); $obj->status = 'success'; @@ -154,7 +154,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer /** * Display the error log. */ - public function dispAdvanced_MailerAdminErrors() + public function dispAdvanced_MailerAdminMailErrors() { $obj = new stdClass(); $obj->status = 'error'; diff --git a/modules/advanced_mailer/conf/info.xml b/modules/advanced_mailer/conf/info.xml index 59ae3da9f..15cfd096e 100644 --- a/modules/advanced_mailer/conf/info.xml +++ b/modules/advanced_mailer/conf/info.xml @@ -1,17 +1,17 @@ - 고급 메일 발송 모듈 - Advanced Mailer + 고급 메일 발송 모듈 (메일 및 SMS 관리) + Advanced Mailer (with SMS) - 외부 SMTP 서버 또는 API를 사용하여 메일을 발송합니다. + 라이믹스에서 발송하는 메일과 SMS를 기록하고 테스트하는 기능을 제공합니다. - Send mail using an external SMTP server or API service. + Log and test e-mails and SMS sent from Rhymix. - 2.0.0 - 2016-05-22 - - Kijin Sung - Kijin Sung + 2.1.0 + 2016-12-14 + + 포에시스 + POESIS diff --git a/modules/advanced_mailer/conf/module.xml b/modules/advanced_mailer/conf/module.xml index 0a16f0ca2..88ed22a98 100644 --- a/modules/advanced_mailer/conf/module.xml +++ b/modules/advanced_mailer/conf/module.xml @@ -6,14 +6,17 @@ - - - + + + + + + - + diff --git a/modules/advanced_mailer/lang/en.php b/modules/advanced_mailer/lang/en.php index 746a22217..d557f0ceb 100644 --- a/modules/advanced_mailer/lang/en.php +++ b/modules/advanced_mailer/lang/en.php @@ -1,12 +1,14 @@ cmd_advanced_mailer = 'Advanced Mailer'; +$lang->cmd_advanced_mailer = 'Advanced Mailer (with SMS)'; $lang->cmd_advanced_mailer_general_config = 'General settings'; $lang->cmd_advanced_mailer_is_enabled = 'Enable module'; $lang->cmd_advanced_mailer_is_enabled_yes = 'Enabled'; $lang->cmd_advanced_mailer_is_enabled_no = 'Disabled'; $lang->cmd_advanced_mailer_logging = 'Logging'; -$lang->cmd_advanced_mailer_log_sent_mail = 'Log Sent Mail'; -$lang->cmd_advanced_mailer_log_errors = 'Log Errors'; +$lang->cmd_advanced_mailer_log_mail = 'Log Mail'; +$lang->cmd_advanced_mailer_log_mail_errors = 'Log Mail Errors'; +$lang->cmd_advanced_mailer_log_sms = 'Log SMS'; +$lang->cmd_advanced_mailer_log_sms_errors = 'Log SMS Errors'; $lang->cmd_advanced_mailer_log_yes = 'Yes'; $lang->cmd_advanced_mailer_log_no = 'No'; $lang->cmd_advanced_mailer_sending_method_config = 'Default Sending Method'; @@ -62,7 +64,7 @@ $lang->cmd_advanced_mailer_other_info_mailgun_dkim = 'The DKIM hostname may be d $lang->cmd_advanced_mailer_other_info_postmark_dkim = 'Please see the Sender Signatures page of your Postmark account for the exact DKIm hostname to use.'; $lang->cmd_advanced_mailer_other_info_woorimail_dkim = 'Please log into Woorimail to see your DKIM settings.'; $lang->cmd_advanced_mailer_ellipsis = '(see API for full value)'; -$lang->cmd_advanced_mailer_test = 'Mail Test'; +$lang->cmd_advanced_mailer_mail_test = 'Mail Test'; $lang->cmd_advanced_mailer_recipient_name = 'Recipient\'s name'; $lang->cmd_advanced_mailer_recipient_email = 'Recipient\'s email'; $lang->cmd_advanced_mailer_send = 'Send'; @@ -115,3 +117,4 @@ $lang->cmd_advanced_mailer_status_calling_script = 'Called from'; $lang->cmd_advanced_mailer_clear_log_condition_all = 'Everything'; $lang->cmd_advanced_mailer_clear_log_condition = 'Over %d days'; $lang->cmd_advanced_mailer_clear_log_button = 'Clear old logs'; +$lang->cmd_advanced_mailer_sms_test = 'SMS Test'; diff --git a/modules/advanced_mailer/lang/ko.php b/modules/advanced_mailer/lang/ko.php index fe80343ac..114eb4aec 100644 --- a/modules/advanced_mailer/lang/ko.php +++ b/modules/advanced_mailer/lang/ko.php @@ -1,12 +1,14 @@ cmd_advanced_mailer = '고급 메일 발송 모듈'; +$lang->cmd_advanced_mailer = '고급 메일 발송 모듈 (메일 및 SMS 관리)'; $lang->cmd_advanced_mailer_general_config = '기본 설정'; $lang->cmd_advanced_mailer_is_enabled = '모듈 사용'; $lang->cmd_advanced_mailer_is_enabled_yes = '사용'; $lang->cmd_advanced_mailer_is_enabled_no = '사용하지 않음'; $lang->cmd_advanced_mailer_logging = '발송 내역 기록'; -$lang->cmd_advanced_mailer_log_sent_mail = '발송 내역'; -$lang->cmd_advanced_mailer_log_errors = '에러 내역'; +$lang->cmd_advanced_mailer_log_mail = '메일 발송 내역'; +$lang->cmd_advanced_mailer_log_mail_errors = '메일 에러 내역'; +$lang->cmd_advanced_mailer_log_sms = 'SMS 발송 내역'; +$lang->cmd_advanced_mailer_log_sms_errors = 'SMS 에러 내역'; $lang->cmd_advanced_mailer_log_yes = '기록'; $lang->cmd_advanced_mailer_log_no = '기록하지 않음'; $lang->cmd_advanced_mailer_sending_method_config = '기본 발송 방법 설정'; @@ -62,7 +64,7 @@ $lang->cmd_advanced_mailer_other_info_mailgun_dkim = 'DKIM 호스트명은 달 $lang->cmd_advanced_mailer_other_info_postmark_dkim = '정확한 DKIM 호스트명은 Postmark 계정의 Sender Signatures 페이지를 참고하시기 바랍니다.'; $lang->cmd_advanced_mailer_other_info_woorimail_dkim = 'DKIM 설정은 우리메일에 로그인하여 확인하십시오.'; $lang->cmd_advanced_mailer_ellipsis = '(중략)'; -$lang->cmd_advanced_mailer_test = '발송 테스트'; +$lang->cmd_advanced_mailer_mail_test = '메일 테스트'; $lang->cmd_advanced_mailer_recipient_name = '받는이 이름'; $lang->cmd_advanced_mailer_recipient_email = '받는이 메일 주소'; $lang->cmd_advanced_mailer_send = '발송'; @@ -115,3 +117,4 @@ $lang->cmd_advanced_mailer_status_calling_script = '호출 위치'; $lang->cmd_advanced_mailer_clear_log_condition_all = '모두'; $lang->cmd_advanced_mailer_clear_log_condition = '%d일 이상'; $lang->cmd_advanced_mailer_clear_log_button = '오래된 기록 삭제'; +$lang->cmd_advanced_mailer_sms_test = 'SMS 테스트'; diff --git a/modules/advanced_mailer/tpl/common.html b/modules/advanced_mailer/tpl/common.html index e254222ec..4b5c08526 100644 --- a/modules/advanced_mailer/tpl/common.html +++ b/modules/advanced_mailer/tpl/common.html @@ -7,7 +7,10 @@
  • {$lang->cmd_advanced_mailer_general_config}
  • {$lang->cmd_advanced_mailer_exception_domains}
  • {$lang->cmd_advanced_mailer_spf_dkim_setting}
  • -
  • {$lang->cmd_advanced_mailer_test}
  • -
  • {$lang->cmd_advanced_mailer_log_sent_mail}
  • -
  • {$lang->cmd_advanced_mailer_log_errors}
  • +
  • {$lang->cmd_advanced_mailer_mail_test}
  • +
  • {$lang->cmd_advanced_mailer_log_mail}
  • +
  • {$lang->cmd_advanced_mailer_log_mail_errors}
  • +
  • {$lang->cmd_advanced_mailer_sms_test}
  • +
  • {$lang->cmd_advanced_mailer_log_sms}
  • +
  • {$lang->cmd_advanced_mailer_log_sms_errors}
  • diff --git a/modules/advanced_mailer/tpl/config.html b/modules/advanced_mailer/tpl/config.html index 6265cd867..852f118fa 100644 --- a/modules/advanced_mailer/tpl/config.html +++ b/modules/advanced_mailer/tpl/config.html @@ -36,7 +36,7 @@

    {$lang->cmd_advanced_mailer_logging}

    - +
    @@ -55,6 +55,26 @@
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    diff --git a/modules/advanced_mailer/tpl/js/config.js b/modules/advanced_mailer/tpl/js/config.js index 43bb459e4..b4782e3f7 100644 --- a/modules/advanced_mailer/tpl/js/config.js +++ b/modules/advanced_mailer/tpl/js/config.js @@ -3,7 +3,7 @@ $(function() { - $("#advanced_mailer_test_send").click(function(event) { + $("#advanced_mailer_test_send_mail").click(function(event) { event.preventDefault(); $("#advanced_mailer_test_result").text(""); $(this).attr("disabled", "disabled"); @@ -12,7 +12,7 @@ recipient_email: $("#advanced_mailer_recipient_email").val(), }; $.exec_json( - "advanced_mailer.procAdvanced_mailerAdminTestSend", ajax_data, + "advanced_mailer.procAdvanced_mailerAdminTestSendMail", ajax_data, function(response) { $("#advanced_mailer_test_result").html(response.test_result); $("#advanced_mailer_test_send").removeAttr("disabled"); diff --git a/modules/advanced_mailer/tpl/test.html b/modules/advanced_mailer/tpl/test.html index 07c3517ec..28f80d0c0 100644 --- a/modules/advanced_mailer/tpl/test.html +++ b/modules/advanced_mailer/tpl/test.html @@ -13,7 +13,7 @@
    -

    {$lang->cmd_advanced_mailer_test}

    +

    {$lang->cmd_advanced_mailer_mail_test}

    @@ -39,7 +39,7 @@
    - +
    From 137728d527ec3e5c707f9958154b45ec1b4d0c7a Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 14 Dec 2016 00:01:55 +0900 Subject: [PATCH 2/5] Add table and triggers for SMS logging --- .../advanced_mailer/advanced_mailer.class.php | 8 ++++++ .../advanced_mailer.controller.php | 28 +++++++++++++++++++ .../schemas/advanced_mailer_sms_log.xml | 11 ++++++++ 3 files changed, 47 insertions(+) create mode 100644 modules/advanced_mailer/schemas/advanced_mailer_sms_log.xml diff --git a/modules/advanced_mailer/advanced_mailer.class.php b/modules/advanced_mailer/advanced_mailer.class.php index ec2afe6d6..2d25a82ae 100644 --- a/modules/advanced_mailer/advanced_mailer.class.php +++ b/modules/advanced_mailer/advanced_mailer.class.php @@ -196,6 +196,10 @@ class Advanced_Mailer extends ModuleObject { $oModuleController->insertTrigger('mail.send', 'advanced_mailer', 'controller', 'triggerAfterMailSend', 'after'); } + if (!$oModuleModel->getTrigger('sms.send', 'advanced_mailer', 'controller', 'triggerAfterSMSSend', 'after')) + { + $oModuleController->insertTrigger('sms.send', 'advanced_mailer', 'controller', 'triggerAfterSMSSend', 'after'); + } } /** @@ -225,6 +229,10 @@ class Advanced_Mailer extends ModuleObject { return true; } + if (!$oModuleModel->getTrigger('sms.send', 'advanced_mailer', 'controller', 'triggerAfterSMSSend', 'after')) + { + return true; + } return false; } diff --git a/modules/advanced_mailer/advanced_mailer.controller.php b/modules/advanced_mailer/advanced_mailer.controller.php index 5a07ae045..8ac3d558d 100644 --- a/modules/advanced_mailer/advanced_mailer.controller.php +++ b/modules/advanced_mailer/advanced_mailer.controller.php @@ -145,4 +145,32 @@ class Advanced_MailerController extends Advanced_Mailer return null; } + + /** + * After SMS send trigger. + */ + public function triggerAfterSMSSend($sms) + { + $config = $this->getConfig(); + + if (toBool($config->log_sent_sms) || (toBool($config->log_sms_errors) && count($sms->errors))) + { + return new Object(); + + $obj = new \stdClass(); + $obj->sms_srl = getNextSequence(); + $obj->sms_from = ''; + $obj->sms_to = ''; + $obj->content = $sms->getContent(); + $obj->calling_script = $sms->getCaller(); + $obj->sending_method = strtolower(class_basename($sms->driver)); + $obj->status = !count($sms->errors) ? 'success' : 'error'; + $obj->errors = count($sms->errors) ? implode("\n", $sms->errors) : null; + $output = executeQuery('advanced_mailer.insertLog', $obj); + if (!$output->toBool()) + { + return $output; + } + } + } } diff --git a/modules/advanced_mailer/schemas/advanced_mailer_sms_log.xml b/modules/advanced_mailer/schemas/advanced_mailer_sms_log.xml new file mode 100644 index 000000000..1a17fa3d3 --- /dev/null +++ b/modules/advanced_mailer/schemas/advanced_mailer_sms_log.xml @@ -0,0 +1,11 @@ + + + + + + + + + + +
    From 85c9b633ec8ab97d863a6e3da2308218f3787818 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 14 Dec 2016 00:22:01 +0900 Subject: [PATCH 3/5] Implement SMS logging and viewing --- .../advanced_mailer.admin.controller.php | 39 ++++++++- .../advanced_mailer.admin.view.php | 84 +++++++++++++++++-- .../advanced_mailer.controller.php | 34 +++++--- modules/advanced_mailer/conf/module.xml | 2 + modules/advanced_mailer/lang/en.php | 1 + modules/advanced_mailer/lang/ko.php | 1 + .../{deleteLogs.xml => deleteMailLogs.xml} | 2 +- .../advanced_mailer/queries/deleteSMSLogs.xml | 9 ++ ...{getLogByType.xml => getMailLogByType.xml} | 2 +- .../queries/getSMSLogByType.xml | 17 ++++ .../{insertLog.xml => insertMailLog.xml} | 2 +- .../advanced_mailer/queries/insertSMSLog.xml | 15 ++++ modules/advanced_mailer/tpl/common.html | 4 +- .../tpl/{view_log.html => mail_log.html} | 0 .../tpl/{test.html => mail_test.html} | 2 +- modules/advanced_mailer/tpl/sms_log.html | 79 +++++++++++++++++ modules/advanced_mailer/tpl/sms_test.html | 45 ++++++++++ 17 files changed, 307 insertions(+), 31 deletions(-) rename modules/advanced_mailer/queries/{deleteLogs.xml => deleteMailLogs.xml} (85%) create mode 100644 modules/advanced_mailer/queries/deleteSMSLogs.xml rename modules/advanced_mailer/queries/{getLogByType.xml => getMailLogByType.xml} (91%) create mode 100644 modules/advanced_mailer/queries/getSMSLogByType.xml rename modules/advanced_mailer/queries/{insertLog.xml => insertMailLog.xml} (94%) create mode 100644 modules/advanced_mailer/queries/insertSMSLog.xml rename modules/advanced_mailer/tpl/{view_log.html => mail_log.html} (100%) rename modules/advanced_mailer/tpl/{test.html => mail_test.html} (98%) create mode 100644 modules/advanced_mailer/tpl/sms_log.html create mode 100644 modules/advanced_mailer/tpl/sms_test.html diff --git a/modules/advanced_mailer/advanced_mailer.admin.controller.php b/modules/advanced_mailer/advanced_mailer.admin.controller.php index 62ffbb92e..7489bb978 100644 --- a/modules/advanced_mailer/advanced_mailer.admin.controller.php +++ b/modules/advanced_mailer/advanced_mailer.admin.controller.php @@ -149,7 +149,7 @@ class Advanced_MailerAdminController extends Advanced_Mailer } /** - * Clear old sending log. + * Clear old mail sending log. */ public function procAdvanced_mailerAdminClearSentMail() { @@ -167,15 +167,46 @@ class Advanced_MailerAdminController extends Advanced_Mailer $obj = new stdClass(); $obj->status = $status; $obj->regdate = date('YmdHis', time() - ($clear_before_days * 86400) + zgap()); - $output = executeQuery('advanced_mailer.deleteLogs', $obj); + $output = executeQuery('advanced_mailer.deleteMailLogs', $obj); if ($status === 'success') { - $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminSentMail')); + $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminMailLog')); } else { - $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminErrors')); + $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminMailErrors')); + } + } + + /** + * Clear old SMS sending log. + */ + public function procAdvanced_mailerAdminClearSentSMS() + { + $status = Context::get('status'); + $clear_before_days = intval(Context::get('clear_before_days')); + if (!in_array($status, array('success', 'error'))) + { + return new Object(-1, 'msg_invalid_request'); + } + if ($clear_before_days < 0) + { + return new Object(-1, 'msg_invalid_request'); + } + + $obj = new stdClass(); + $obj->status = $status; + $obj->regdate = date('YmdHis', time() - ($clear_before_days * 86400) + zgap()); + $output = executeQuery('advanced_mailer.deleteSMSLogs', $obj); + + if ($status === 'success') + { + $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminSMSLog')); + } + else + { + $this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminSMSErrors')); } } diff --git a/modules/advanced_mailer/advanced_mailer.admin.view.php b/modules/advanced_mailer/advanced_mailer.admin.view.php index b0092505e..5ef461bed 100644 --- a/modules/advanced_mailer/advanced_mailer.admin.view.php +++ b/modules/advanced_mailer/advanced_mailer.admin.view.php @@ -110,7 +110,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer } /** - * Display the test send form. + * Display the mail test form. */ public function dispAdvanced_MailerAdminMailTest() { @@ -122,18 +122,18 @@ class Advanced_MailerAdminView extends Advanced_Mailer Context::set('sending_method', config('mail.type')); $this->setTemplatePath($this->module_path.'tpl'); - $this->setTemplateFile('test'); + $this->setTemplateFile('mail_test'); } /** - * Display the sent mail log. + * Display the mail log. */ public function dispAdvanced_MailerAdminMailLog() { $obj = new stdClass(); $obj->status = 'success'; $obj->page = $page = Context::get('page') ?: 1; - $maillog = executeQuery('advanced_mailer.getLogByType', $obj); + $maillog = executeQueryArray('advanced_mailer.getMailLogByType', $obj); $maillog = $maillog->toBool() ? $this->procMailLog($maillog->data) : array(); Context::set('advanced_mailer_log', $maillog); Context::set('advanced_mailer_status', 'success'); @@ -148,18 +148,18 @@ class Advanced_MailerAdminView extends Advanced_Mailer Context::set('sending_methods', $sending_methods); $this->setTemplatePath($this->module_path.'tpl'); - $this->setTemplateFile('view_log'); + $this->setTemplateFile('mail_log'); } /** - * Display the error log. + * Display the mail error log. */ public function dispAdvanced_MailerAdminMailErrors() { $obj = new stdClass(); $obj->status = 'error'; $obj->page = $page = Context::get('page') ?: 1; - $maillog = executeQuery('advanced_mailer.getLogByType', $obj); + $maillog = executeQueryArray('advanced_mailer.getMailLogByType', $obj); $maillog = $maillog->toBool() ? $this->procMailLog($maillog->data) : array(); Context::set('advanced_mailer_log', $maillog); Context::set('advanced_mailer_status', 'error'); @@ -174,7 +174,75 @@ class Advanced_MailerAdminView extends Advanced_Mailer Context::set('sending_methods', $sending_methods); $this->setTemplatePath($this->module_path.'tpl'); - $this->setTemplateFile('view_log'); + $this->setTemplateFile('mail_log'); + } + + /** + * Display the SMS test form. + */ + public function dispAdvanced_MailerAdminSMSTest() + { + $advanced_mailer_config = $this->getConfig(); + $sending_methods = Rhymix\Framework\Mail::getSupportedDrivers(); + + Context::set('advanced_mailer_config', $advanced_mailer_config); + Context::set('sending_methods', $sending_methods); + Context::set('sending_method', config('mail.type')); + + $this->setTemplatePath($this->module_path.'tpl'); + $this->setTemplateFile('sms_test'); + } + + /** + * Display the SMS log. + */ + public function dispAdvanced_MailerAdminSMSLog() + { + $obj = new stdClass(); + $obj->status = 'success'; + $obj->page = $page = Context::get('page') ?: 1; + $smslog = executeQueryArray('advanced_mailer.getSMSLogByType', $obj); + $smslog = $smslog->toBool() ? $smslog->data : array(); + Context::set('advanced_mailer_log', $smslog); + Context::set('advanced_mailer_status', 'success'); + + $paging = $this->procPaging('success', $page); + Context::set('total_count', $paging->total_count); + Context::set('total_page', $paging->total_page); + Context::set('page', $paging->page); + Context::set('page_navigation', $paging->page_navigation); + + $sending_methods = Rhymix\Framework\SMS::getSupportedDrivers(); + Context::set('sending_methods', $sending_methods); + + $this->setTemplatePath($this->module_path.'tpl'); + $this->setTemplateFile('sms_log'); + } + + /** + * Display the SMS error log. + */ + public function dispAdvanced_MailerAdminSMSErrors() + { + $obj = new stdClass(); + $obj->status = 'error'; + $obj->page = $page = Context::get('page') ?: 1; + $smslog = executeQueryArray('advanced_mailer.getSMSLogByType', $obj); + $smslog = $smslog->toBool() ? $smslog->data : array(); + Context::set('advanced_mailer_log', $smslog); + Context::set('advanced_mailer_status', 'error'); + + $paging = $this->procPaging('error', $page); + Context::set('total_count', $paging->total_count); + Context::set('total_page', $paging->total_page); + Context::set('page', $paging->page); + Context::set('page_navigation', $paging->page_navigation); + + $sending_methods = Rhymix\Framework\SMS::getSupportedDrivers(); + Context::set('sending_methods', $sending_methods); + + $this->setTemplatePath($this->module_path.'tpl'); + $this->setTemplateFile('sms_log'); } /** diff --git a/modules/advanced_mailer/advanced_mailer.controller.php b/modules/advanced_mailer/advanced_mailer.controller.php index 8ac3d558d..78bc8d219 100644 --- a/modules/advanced_mailer/advanced_mailer.controller.php +++ b/modules/advanced_mailer/advanced_mailer.controller.php @@ -58,7 +58,6 @@ class Advanced_MailerController extends Advanced_Mailer if (toBool($config->log_sent_mail) || (toBool($config->log_errors) && count($mail->errors))) { $obj = new \stdClass(); - $obj->mail_srl = getNextSequence(); $obj->mail_from = ''; $obj->mail_to = ''; @@ -99,9 +98,9 @@ class Advanced_MailerController extends Advanced_Mailer $obj->subject = $mail->message->getSubject(); $obj->calling_script = $mail->getCaller(); $obj->sending_method = strtolower(class_basename($mail->driver)); - $obj->status = !count($mail->errors) ? 'success' : 'error'; - $obj->errors = count($mail->errors) ? implode("\n", $mail->errors) : null; - $output = executeQuery('advanced_mailer.insertLog', $obj); + $obj->status = !count($mail->getErrors()) ? 'success' : 'error'; + $obj->errors = count($mail->getErrors()) ? implode("\n", $mail->getErrors()) : null; + $output = executeQuery('advanced_mailer.insertMailLog', $obj); if (!$output->toBool()) { return $output; @@ -155,18 +154,27 @@ class Advanced_MailerController extends Advanced_Mailer if (toBool($config->log_sent_sms) || (toBool($config->log_sms_errors) && count($sms->errors))) { - return new Object(); - $obj = new \stdClass(); - $obj->sms_srl = getNextSequence(); - $obj->sms_from = ''; - $obj->sms_to = ''; - $obj->content = $sms->getContent(); + $obj->sms_from = $sms->getFrom(); + $obj->sms_to = array(); + foreach ($sms->getRecipientsWithCountry() as $to) + { + if ($to->country) + { + $obj->sms_to[] = '+' . $to->country . '.' . $to->number; + } + else + { + $obj->sms_to[] = $to->number; + } + } + $obj->sms_to = implode(', ', $obj->sms_to); + $obj->content = trim($sms->getSubject() . "\n" . $sms->getBody()); $obj->calling_script = $sms->getCaller(); $obj->sending_method = strtolower(class_basename($sms->driver)); - $obj->status = !count($sms->errors) ? 'success' : 'error'; - $obj->errors = count($sms->errors) ? implode("\n", $sms->errors) : null; - $output = executeQuery('advanced_mailer.insertLog', $obj); + $obj->status = !count($sms->getErrors()) ? 'success' : 'error'; + $obj->errors = count($sms->getErrors()) ? implode("\n", $sms->getErrors()) : null; + $output = executeQuery('advanced_mailer.insertSMSLog', $obj); if (!$output->toBool()) { return $output; diff --git a/modules/advanced_mailer/conf/module.xml b/modules/advanced_mailer/conf/module.xml index 88ed22a98..2b341a7a8 100644 --- a/modules/advanced_mailer/conf/module.xml +++ b/modules/advanced_mailer/conf/module.xml @@ -16,7 +16,9 @@ + + diff --git a/modules/advanced_mailer/lang/en.php b/modules/advanced_mailer/lang/en.php index d557f0ceb..ee1fc6843 100644 --- a/modules/advanced_mailer/lang/en.php +++ b/modules/advanced_mailer/lang/en.php @@ -107,6 +107,7 @@ $lang->msg_advanced_mailer_log_is_empty = 'There are no entries to display.'; $lang->cmd_advanced_mailer_status_sender = 'Sender'; $lang->cmd_advanced_mailer_status_recipient = 'Recipient'; $lang->cmd_advanced_mailer_status_subject = 'Subject'; +$lang->cmd_advanced_mailer_status_content = 'Content'; $lang->cmd_advanced_mailer_status_sending_method = 'Method'; $lang->cmd_advanced_mailer_status_time = 'Time'; $lang->cmd_advanced_mailer_status = 'Status'; diff --git a/modules/advanced_mailer/lang/ko.php b/modules/advanced_mailer/lang/ko.php index 114eb4aec..cf6fd6ffa 100644 --- a/modules/advanced_mailer/lang/ko.php +++ b/modules/advanced_mailer/lang/ko.php @@ -107,6 +107,7 @@ $lang->msg_advanced_mailer_log_is_empty = '표시할 항목이 없습니다.'; $lang->cmd_advanced_mailer_status_sender = '보낸이'; $lang->cmd_advanced_mailer_status_recipient = '받는이'; $lang->cmd_advanced_mailer_status_subject = '제목'; +$lang->cmd_advanced_mailer_status_content = '내용'; $lang->cmd_advanced_mailer_status_sending_method = '발송 방법'; $lang->cmd_advanced_mailer_status_time = '발송 시간'; $lang->cmd_advanced_mailer_status = '상태'; diff --git a/modules/advanced_mailer/queries/deleteLogs.xml b/modules/advanced_mailer/queries/deleteMailLogs.xml similarity index 85% rename from modules/advanced_mailer/queries/deleteLogs.xml rename to modules/advanced_mailer/queries/deleteMailLogs.xml index 690e64ed8..d76928fff 100644 --- a/modules/advanced_mailer/queries/deleteLogs.xml +++ b/modules/advanced_mailer/queries/deleteMailLogs.xml @@ -1,4 +1,4 @@ - + diff --git a/modules/advanced_mailer/queries/deleteSMSLogs.xml b/modules/advanced_mailer/queries/deleteSMSLogs.xml new file mode 100644 index 000000000..21676d22b --- /dev/null +++ b/modules/advanced_mailer/queries/deleteSMSLogs.xml @@ -0,0 +1,9 @@ + + +
    + + + + + + diff --git a/modules/advanced_mailer/queries/getLogByType.xml b/modules/advanced_mailer/queries/getMailLogByType.xml similarity index 91% rename from modules/advanced_mailer/queries/getLogByType.xml rename to modules/advanced_mailer/queries/getMailLogByType.xml index 655b85e30..60285b793 100644 --- a/modules/advanced_mailer/queries/getLogByType.xml +++ b/modules/advanced_mailer/queries/getMailLogByType.xml @@ -1,4 +1,4 @@ - +
    diff --git a/modules/advanced_mailer/queries/getSMSLogByType.xml b/modules/advanced_mailer/queries/getSMSLogByType.xml new file mode 100644 index 000000000..d7c4e36e7 --- /dev/null +++ b/modules/advanced_mailer/queries/getSMSLogByType.xml @@ -0,0 +1,17 @@ + + +
    + + + + + + + + + + + + + + diff --git a/modules/advanced_mailer/queries/insertLog.xml b/modules/advanced_mailer/queries/insertMailLog.xml similarity index 94% rename from modules/advanced_mailer/queries/insertLog.xml rename to modules/advanced_mailer/queries/insertMailLog.xml index 2f2580c34..006fbf166 100644 --- a/modules/advanced_mailer/queries/insertLog.xml +++ b/modules/advanced_mailer/queries/insertMailLog.xml @@ -1,4 +1,4 @@ - +
    diff --git a/modules/advanced_mailer/queries/insertSMSLog.xml b/modules/advanced_mailer/queries/insertSMSLog.xml new file mode 100644 index 000000000..f1bb6460d --- /dev/null +++ b/modules/advanced_mailer/queries/insertSMSLog.xml @@ -0,0 +1,15 @@ + + +
    + + + + + + + + + + + + diff --git a/modules/advanced_mailer/tpl/common.html b/modules/advanced_mailer/tpl/common.html index 4b5c08526..29ecbd984 100644 --- a/modules/advanced_mailer/tpl/common.html +++ b/modules/advanced_mailer/tpl/common.html @@ -10,7 +10,7 @@
  • {$lang->cmd_advanced_mailer_mail_test}
  • {$lang->cmd_advanced_mailer_log_mail}
  • {$lang->cmd_advanced_mailer_log_mail_errors}
  • -
  • {$lang->cmd_advanced_mailer_sms_test}
  • -
  • {$lang->cmd_advanced_mailer_log_sms}
  • +
  • {$lang->cmd_advanced_mailer_sms_test}
  • +
  • {$lang->cmd_advanced_mailer_log_sms}
  • {$lang->cmd_advanced_mailer_log_sms_errors}
  • diff --git a/modules/advanced_mailer/tpl/view_log.html b/modules/advanced_mailer/tpl/mail_log.html similarity index 100% rename from modules/advanced_mailer/tpl/view_log.html rename to modules/advanced_mailer/tpl/mail_log.html diff --git a/modules/advanced_mailer/tpl/test.html b/modules/advanced_mailer/tpl/mail_test.html similarity index 98% rename from modules/advanced_mailer/tpl/test.html rename to modules/advanced_mailer/tpl/mail_test.html index 28f80d0c0..4234b9956 100644 --- a/modules/advanced_mailer/tpl/test.html +++ b/modules/advanced_mailer/tpl/mail_test.html @@ -4,7 +4,7 @@ - +
    diff --git a/modules/advanced_mailer/tpl/sms_log.html b/modules/advanced_mailer/tpl/sms_log.html new file mode 100644 index 000000000..964ee1093 --- /dev/null +++ b/modules/advanced_mailer/tpl/sms_log.html @@ -0,0 +1,79 @@ + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + Total: {number_format($total_count)}, Page: {number_format($page)}/{number_format($total_page)} +
    {$lang->cmd_advanced_mailer_status_sender}{$lang->cmd_advanced_mailer_status_recipient}{$lang->cmd_advanced_mailer_status_content}{$lang->cmd_advanced_mailer_status_sending_method}{$lang->cmd_advanced_mailer_status_time}{$lang->cmd_advanced_mailer_status}
    + {htmlspecialchars($val->sms_from)} + + {htmlspecialchars($val->sms_to)} + {nl2br(htmlspecialchars($val->content))} + {@ if($val->sending_method === 'mail') $val->sending_method = 'mailfunction'} + {strval(isset($sending_methods[$val->sending_method]['name']) ? $sending_methods[$val->sending_method]['name'] : $val->sending_method)} + {(zdate($val->regdate, "Y-m-d\nH:i:s"))} + + {$lang->cmd_advanced_mailer_status_success} + + {$lang->cmd_advanced_mailer_status_error} +
    + {$lang->cmd_advanced_mailer_status_error_msg}:
    + {nl2br(htmlspecialchars(trim($val->errors)))}

    + {$lang->cmd_advanced_mailer_status_calling_script}:
    + {htmlspecialchars($val->calling_script)} +
    + +
    {$lang->msg_advanced_mailer_log_is_empty}
    + +
    + + + + +
    + + + + + +
    +
    diff --git a/modules/advanced_mailer/tpl/sms_test.html b/modules/advanced_mailer/tpl/sms_test.html new file mode 100644 index 000000000..4234b9956 --- /dev/null +++ b/modules/advanced_mailer/tpl/sms_test.html @@ -0,0 +1,45 @@ + + + + +
    + + + + +
    +

    {$XE_VALIDATOR_MESSAGE}

    +
    + +
    + +

    {$lang->cmd_advanced_mailer_mail_test}

    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    +
    +
    + +
    + +
    + +
    + +
    From b44175aba210781e884e112a0eed10910bd6cc30 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 14 Dec 2016 00:38:14 +0900 Subject: [PATCH 4/5] Implement test SMS sending --- .../advanced_mailer.admin.controller.php | 62 +++++++++++++++++-- modules/advanced_mailer/lang/en.php | 7 +++ modules/advanced_mailer/lang/ko.php | 7 +++ modules/advanced_mailer/tpl/js/config.js | 24 ++++++- modules/advanced_mailer/tpl/sms_test.html | 17 ++--- 5 files changed, 104 insertions(+), 13 deletions(-) diff --git a/modules/advanced_mailer/advanced_mailer.admin.controller.php b/modules/advanced_mailer/advanced_mailer.admin.controller.php index 7489bb978..5019ba688 100644 --- a/modules/advanced_mailer/advanced_mailer.admin.controller.php +++ b/modules/advanced_mailer/advanced_mailer.admin.controller.php @@ -211,7 +211,7 @@ class Advanced_MailerAdminController extends Advanced_Mailer } /** - * Send a test email using a temporary configuration. + * Send a test mail. */ public function procAdvanced_MailerAdminTestSendMail() { @@ -250,23 +250,23 @@ class Advanced_MailerAdminController extends Advanced_Mailer if (!$result) { - if (count($oMail->errors)) + if (count($oMail->getErrors())) { if (config('mail.type') === 'smtp') { - if (strpos(config('mail.smtp.smtp_host'), 'gmail.com') !== false && strpos(implode("\n", $oMail->errors), 'code "535"') !== false) + if (strpos(config('mail.smtp.smtp_host'), 'gmail.com') !== false && strpos(implode("\n", $oMail->getErrors()), 'code "535"') !== false) { $this->add('test_result', Context::getLang('msg_advanced_mailer_google_account_security')); return; } - if (strpos(config('mail.smtp.smtp_host'), 'naver.com') !== false && strpos(implode("\n", $oMail->errors), 'Failed to authenticate') !== false) + if (strpos(config('mail.smtp.smtp_host'), 'naver.com') !== false && strpos(implode("\n", $oMail->getErrors()), 'Failed to authenticate') !== false) { $this->add('test_result', Context::getLang('msg_advanced_mailer_naver_smtp_disabled')); return; } } - $this->add('test_result', nl2br(htmlspecialchars(implode("\n", $oMail->errors)))); + $this->add('test_result', nl2br(htmlspecialchars(implode("\n", $oMail->getErrors())))); return; } else @@ -285,4 +285,56 @@ class Advanced_MailerAdminController extends Advanced_Mailer $this->add('test_result', Context::getLang('msg_advanced_mailer_test_success')); return; } + + /** + * Send a test SMS. + */ + public function procAdvanced_MailerAdminTestSendSMS() + { + $advanced_mailer_config = $this->getConfig(); + $recipient_number = Context::get('recipient_number'); + $country_code = intval(Context::get('country_code')); + $content = trim(Context::get('content')); + + if (!$recipient_number) + { + $this->add('test_result', 'Error: ' . Context::getLang('msg_advanced_mailer_recipient_number_is_empty')); + return; + } + if (!$content) + { + $this->add('test_result', 'Error: ' . Context::getLang('msg_advanced_mailer_content_is_empty')); + return; + } + + try + { + $oSMS = new Rhymix\Framework\SMS(); + $oSMS->addTo($recipient_number, $country_code); + $oSMS->setBody($content); + $result = $oSMS->send(); + + if (!$result) + { + if (count($oSMS->getErrors())) + { + $this->add('test_result', nl2br(htmlspecialchars(implode("\n", $oSMS->getErrors())))); + return; + } + else + { + $this->add('test_result', Context::getLang('msg_advanced_mailer_unknown_error')); + return; + } + } + } + catch (Exception $e) + { + $this->add('test_result', nl2br(htmlspecialchars($e->getMessage()))); + return; + } + + $this->add('test_result', Context::getLang('msg_advanced_mailer_test_success_sms')); + return; + } } diff --git a/modules/advanced_mailer/lang/en.php b/modules/advanced_mailer/lang/en.php index ee1fc6843..168a52cd6 100644 --- a/modules/advanced_mailer/lang/en.php +++ b/modules/advanced_mailer/lang/en.php @@ -119,3 +119,10 @@ $lang->cmd_advanced_mailer_clear_log_condition_all = 'Everything'; $lang->cmd_advanced_mailer_clear_log_condition = 'Over %d days'; $lang->cmd_advanced_mailer_clear_log_button = 'Clear old logs'; $lang->cmd_advanced_mailer_sms_test = 'SMS Test'; +$lang->cmd_advanced_mailer_recipient_number = 'Recipient\'s number'; +$lang->cmd_advanced_mailer_country_code = 'Country code'; +$lang->cmd_advanced_mailer_country_code_help = 'Please leave the country code empty if you are sending to a domestic number.'; +$lang->cmd_advanced_mailer_test_content = 'This is an SMS test from Rhymix.'; +$lang->msg_advanced_mailer_recipient_number_is_empty = 'Please enter a phone number for the recipient.'; +$lang->msg_advanced_mailer_content_is_empty = 'Please enter the content for your test SMS.'; +$lang->msg_advanced_mailer_test_success_sms = 'The test was successful. Please check your SMS.'; \ No newline at end of file diff --git a/modules/advanced_mailer/lang/ko.php b/modules/advanced_mailer/lang/ko.php index cf6fd6ffa..db607462e 100644 --- a/modules/advanced_mailer/lang/ko.php +++ b/modules/advanced_mailer/lang/ko.php @@ -119,3 +119,10 @@ $lang->cmd_advanced_mailer_clear_log_condition_all = '모두'; $lang->cmd_advanced_mailer_clear_log_condition = '%d일 이상'; $lang->cmd_advanced_mailer_clear_log_button = '오래된 기록 삭제'; $lang->cmd_advanced_mailer_sms_test = 'SMS 테스트'; +$lang->cmd_advanced_mailer_recipient_number = '받는이 전화번호'; +$lang->cmd_advanced_mailer_country_code = '국가코드'; +$lang->cmd_advanced_mailer_country_code_help = '국내 번호로 발송하실 경우 국가코드는 비워 두시기 바랍니다.'; +$lang->cmd_advanced_mailer_test_content = '라이믹스 SMS 발송 테스트입니다.'; +$lang->msg_advanced_mailer_recipient_number_is_empty = '받는이 전화번호를 입력해 주십시오.'; +$lang->msg_advanced_mailer_content_is_empty = 'SMS 내용을 입력해 주십시오.'; +$lang->msg_advanced_mailer_test_success_sms = '테스트에 성공하였습니다. SMS를 확인해 보시기 바랍니다.'; \ No newline at end of file diff --git a/modules/advanced_mailer/tpl/js/config.js b/modules/advanced_mailer/tpl/js/config.js index b4782e3f7..15ef43849 100644 --- a/modules/advanced_mailer/tpl/js/config.js +++ b/modules/advanced_mailer/tpl/js/config.js @@ -9,7 +9,7 @@ $(this).attr("disabled", "disabled"); var ajax_data = { recipient_name: $("#advanced_mailer_recipient_name").val(), - recipient_email: $("#advanced_mailer_recipient_email").val(), + recipient_email: $("#advanced_mailer_recipient_email").val() }; $.exec_json( "advanced_mailer.procAdvanced_mailerAdminTestSendMail", ajax_data, @@ -24,6 +24,28 @@ ); }); + $("#advanced_mailer_test_send_sms").click(function(event) { + event.preventDefault(); + $("#advanced_mailer_test_result").text(""); + $(this).attr("disabled", "disabled"); + var ajax_data = { + recipient_number: $("#advanced_mailer_recipient_number").val(), + country_code: $("#advanced_mailer_country_code").val(), + content: $("#advanced_mailer_content").val() + }; + $.exec_json( + "advanced_mailer.procAdvanced_mailerAdminTestSendSMS", ajax_data, + function(response) { + $("#advanced_mailer_test_result").html(response.test_result); + $("#advanced_mailer_test_send").removeAttr("disabled"); + }, + function(response) { + $("#advanced_mailer_test_result").text("AJAX Error"); + $("#advanced_mailer_test_send").removeAttr("disabled"); + } + ); + }); + }); } (jQuery)); diff --git a/modules/advanced_mailer/tpl/sms_test.html b/modules/advanced_mailer/tpl/sms_test.html index 4234b9956..8819a3dba 100644 --- a/modules/advanced_mailer/tpl/sms_test.html +++ b/modules/advanced_mailer/tpl/sms_test.html @@ -4,7 +4,7 @@
    - +
    @@ -13,19 +13,22 @@
    -

    {$lang->cmd_advanced_mailer_mail_test}

    +

    {$lang->cmd_advanced_mailer_sms_test}

    - +
    - + +  {$lang->cmd_advanced_mailer_country_code}  + +

    {$lang->cmd_advanced_mailer_country_code_help}

    - +
    - +
    @@ -39,7 +42,7 @@
    - +
    From 44b9c3d38f7f2d3038d89c77a3317821ae7118ee Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 14 Dec 2016 00:41:51 +0900 Subject: [PATCH 5/5] Update procPaging() to distinguish mail count from SMS count --- .../advanced_mailer.admin.view.php | 19 +++++++++++++------ ...ntLogByType.xml => countMailLogByType.xml} | 2 +- .../queries/countSMSLogByType.xml | 11 +++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) rename modules/advanced_mailer/queries/{countLogByType.xml => countMailLogByType.xml} (84%) create mode 100644 modules/advanced_mailer/queries/countSMSLogByType.xml diff --git a/modules/advanced_mailer/advanced_mailer.admin.view.php b/modules/advanced_mailer/advanced_mailer.admin.view.php index 5ef461bed..385c1a508 100644 --- a/modules/advanced_mailer/advanced_mailer.admin.view.php +++ b/modules/advanced_mailer/advanced_mailer.admin.view.php @@ -138,7 +138,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer Context::set('advanced_mailer_log', $maillog); Context::set('advanced_mailer_status', 'success'); - $paging = $this->procPaging('success', $page); + $paging = $this->procPaging('success', 'mail', $page); Context::set('total_count', $paging->total_count); Context::set('total_page', $paging->total_page); Context::set('page', $paging->page); @@ -164,7 +164,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer Context::set('advanced_mailer_log', $maillog); Context::set('advanced_mailer_status', 'error'); - $paging = $this->procPaging('error', $page); + $paging = $this->procPaging('error', 'mail', $page); Context::set('total_count', $paging->total_count); Context::set('total_page', $paging->total_page); Context::set('page', $paging->page); @@ -206,7 +206,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer Context::set('advanced_mailer_log', $smslog); Context::set('advanced_mailer_status', 'success'); - $paging = $this->procPaging('success', $page); + $paging = $this->procPaging('success', 'sms', $page); Context::set('total_count', $paging->total_count); Context::set('total_page', $paging->total_page); Context::set('page', $paging->page); @@ -232,7 +232,7 @@ class Advanced_MailerAdminView extends Advanced_Mailer Context::set('advanced_mailer_log', $smslog); Context::set('advanced_mailer_status', 'error'); - $paging = $this->procPaging('error', $page); + $paging = $this->procPaging('error', 'sms', $page); Context::set('total_count', $paging->total_count); Context::set('total_page', $paging->total_page); Context::set('page', $paging->page); @@ -287,11 +287,18 @@ class Advanced_MailerAdminView extends Advanced_Mailer /** * Process paging. */ - public function procPaging($status, $page = 1) + public function procPaging($status, $type, $page = 1) { $args = new stdClass; $args->status = $status; - $count = executeQuery('advanced_mailer.countLogByType', $args); + if ($type === 'mail') + { + $count = executeQuery('advanced_mailer.countMailLogByType', $args); + } + else + { + $count = executeQuery('advanced_mailer.countSMSLogByType', $args); + } $total_count = $count->data->count; $total_page = max(1, ceil($total_count / 20)); diff --git a/modules/advanced_mailer/queries/countLogByType.xml b/modules/advanced_mailer/queries/countMailLogByType.xml similarity index 84% rename from modules/advanced_mailer/queries/countLogByType.xml rename to modules/advanced_mailer/queries/countMailLogByType.xml index 652275ffc..40e17bdbb 100644 --- a/modules/advanced_mailer/queries/countLogByType.xml +++ b/modules/advanced_mailer/queries/countMailLogByType.xml @@ -1,4 +1,4 @@ - + diff --git a/modules/advanced_mailer/queries/countSMSLogByType.xml b/modules/advanced_mailer/queries/countSMSLogByType.xml new file mode 100644 index 000000000..9a0ece76e --- /dev/null +++ b/modules/advanced_mailer/queries/countSMSLogByType.xml @@ -0,0 +1,11 @@ + + +
    + + + + + + + +