Merge pull request #657 from kijin/pr/advanced-mailer-sms

advanced_mailer 모듈에 SMS 테스트 및 기록 기능을 추가
This commit is contained in:
Kijin Sung 2016-12-14 00:51:25 +09:00 committed by GitHub
commit 5618a1c361
24 changed files with 531 additions and 65 deletions

View file

@ -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())
{
@ -147,7 +149,7 @@ class Advanced_MailerAdminController extends Advanced_Mailer
}
/**
* Clear old sending log.
* Clear old mail sending log.
*/
public function procAdvanced_mailerAdminClearSentMail()
{
@ -165,22 +167,53 @@ 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'));
}
}
/**
* Send a test email using a temporary configuration.
* Clear old SMS sending log.
*/
public function procAdvanced_MailerAdminTestSend()
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'));
}
}
/**
* Send a test mail.
*/
public function procAdvanced_MailerAdminTestSendMail()
{
$advanced_mailer_config = $this->getConfig();
$recipient_config = Context::gets('recipient_name', 'recipient_email');
@ -217,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
@ -252,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;
}
}

View file

@ -110,9 +110,9 @@ class Advanced_MailerAdminView extends Advanced_Mailer
}
/**
* Display the test send form.
* Display the mail test form.
*/
public function dispAdvanced_MailerAdminTestConfig()
public function dispAdvanced_MailerAdminMailTest()
{
$advanced_mailer_config = $this->getConfig();
$sending_methods = Rhymix\Framework\Mail::getSupportedDrivers();
@ -122,23 +122,23 @@ 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_MailerAdminSentMail()
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');
$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);
@ -148,23 +148,23 @@ 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_MailerAdminErrors()
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');
$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);
@ -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', 'sms', $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', 'sms', $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');
}
/**
@ -219,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));

View file

@ -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;
}

View file

@ -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;
@ -145,4 +144,41 @@ 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)))
{
$obj = new \stdClass();
$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->getErrors()) ? 'success' : 'error';
$obj->errors = count($sms->getErrors()) ? implode("\n", $sms->getErrors()) : null;
$output = executeQuery('advanced_mailer.insertSMSLog', $obj);
if (!$output->toBool())
{
return $output;
}
}
}
}

View file

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="0.2">
<title xml:lang="ko">고급 메일 발송 모듈</title>
<title xml:lang="en">Advanced Mailer</title>
<title xml:lang="ko">고급 메일 발송 모듈 (메일 및 SMS 관리)</title>
<title xml:lang="en">Advanced Mailer (with SMS)</title>
<description xml:lang="ko">
외부 SMTP 서버 또는 API를 사용하여 메일을 발송합니다.
라이믹스에서 발송하는 메일과 SMS를 기록하고 테스트하는 기능을 제공합니다.
</description>
<description xml:lang="en">
Send mail using an external SMTP server or API service.
Log and test e-mails and SMS sent from Rhymix.
</description>
<version>2.0.0</version>
<date>2016-05-22</date>
<author email_address="kijin@kijinsung.com" link="https://github.com/kijin">
<name xml:lang="ko">Kijin Sung</name>
<name xml:lang="en">Kijin Sung</name>
<version>2.1.0</version>
<date>2016-12-14</date>
<author link="https://www.poesis.org">
<name xml:lang="ko">포에시스</name>
<name xml:lang="en">POESIS</name>
</author>
</module>

View file

@ -6,14 +6,19 @@
<action name="dispAdvanced_mailerAdminConfig" type="view" admin_index="true" menu_name="advanced_mailer" />
<action name="dispAdvanced_mailerAdminExceptions" type="view" />
<action name="dispAdvanced_mailerAdminSpfDkim" type="view" />
<action name="dispAdvanced_mailerAdminTestConfig" type="view" />
<action name="dispAdvanced_mailerAdminSentMail" type="view" />
<action name="dispAdvanced_mailerAdminErrors" type="view" />
<action name="dispAdvanced_mailerAdminMailTest" type="view" />
<action name="dispAdvanced_mailerAdminMailLog" type="view" />
<action name="dispAdvanced_mailerAdminMailErrors" type="view" />
<action name="dispAdvanced_mailerAdminSMSTest" type="view" />
<action name="dispAdvanced_mailerAdminSMSLog" type="view" />
<action name="dispAdvanced_mailerAdminSMSErrors" type="view" />
<action name="procAdvanced_mailerAdminInsertConfig" type="controller" />
<action name="procAdvanced_mailerAdminInsertExceptions" type="controller" />
<action name="procAdvanced_mailerAdminCheckDNSRecord" type="controller" />
<action name="procAdvanced_mailerAdminClearSentMail" type="controller" />
<action name="procAdvanced_mailerAdminTestSend" type="controller" />
<action name="procAdvanced_mailerAdminClearSentSMS" type="controller" />
<action name="procAdvanced_mailerAdminTestSendMail" type="controller" />
<action name="procAdvanced_mailerAdminTestSendSMS" type="controller" />
</actions>
<menus>
<menu name="advanced_mailer" type="all">

View file

@ -1,12 +1,14 @@
<?php
$lang->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';
@ -105,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';
@ -115,3 +118,11 @@ $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';
$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.';

View file

@ -1,12 +1,14 @@
<?php
$lang->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 = '발송';
@ -105,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 = '상태';
@ -115,3 +118,11 @@ $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 테스트';
$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를 확인해 보시기 바랍니다.';

View file

@ -1,4 +1,4 @@
<query id="countLogByType" action="select">
<query id="countMailLogByType" action="select">
<tables>
<table name="advanced_mailer_log" />
</tables>

View file

@ -0,0 +1,11 @@
<query id="countSMSLogByType" action="select">
<tables>
<table name="advanced_mailer_sms_log" />
</tables>
<columns>
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="status" var="status" />
</conditions>
</query>

View file

@ -1,4 +1,4 @@
<query id="deleteLogs" action="delete">
<query id="deleteMailLogs" action="delete">
<tables>
<table name="advanced_mailer_log" />
</tables>

View file

@ -0,0 +1,9 @@
<query id="deleteSMSLogs" action="delete">
<tables>
<table name="advanced_mailer_sms_log" />
</tables>
<conditions>
<condition operation="equal" column="status" var="status" />
<condition operation="less" column="regdate" var="regdate" pipe="and" />
</conditions>
</query>

View file

@ -1,4 +1,4 @@
<query id="getLogByType" action="select">
<query id="getMailLogByType" action="select">
<tables>
<table name="advanced_mailer_log" />
</tables>

View file

@ -0,0 +1,17 @@
<query id="getSMSLogByType" action="select">
<tables>
<table name="advanced_mailer_sms_log" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="status" var="status" />
</conditions>
<navigation>
<index var="sort_index" default="sms_id" order="desc" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -1,4 +1,4 @@
<query id="insertLog" action="insert">
<query id="insertMailLog" action="insert">
<tables>
<table name="advanced_mailer_log" />
</tables>

View file

@ -0,0 +1,15 @@
<query id="insertSMSLog" action="insert">
<tables>
<table name="advanced_mailer_sms_log" />
</tables>
<columns>
<column name="sms_from" var="sms_from" notnull="notnull" />
<column name="sms_to" var="sms_to" notnull="notnull" />
<column name="content" var="content" notnull="notnull" />
<column name="calling_script" var="calling_script" notnull="notnull" />
<column name="sending_method" var="sending_method" notnull="notnull" />
<column name="regdate" var="regdate" notnull="notnull" default="curdate()" />
<column name="status" var="status" notnull="notnull" default="success" />
<column name="errors" var="errors" />
</columns>
</query>

View file

@ -0,0 +1,11 @@
<table name="advanced_mailer_sms_log">
<column name="sms_id" type="number" size="11" notnull="notnull" primary_key="primary_key" auto_increment="auto_increment" />
<column name="sms_from" type="varchar" size="250" notnull="notnull" />
<column name="sms_to" type="text" notnull="notnull" />
<column name="content" type="text" notnull="notnull" />
<column name="calling_script" type="varchar" size="250" notnull="notnull" />
<column name="sending_method" type="varchar" size="40" notnull="notnull" />
<column name="regdate" type="date" notnull="notnull" index="idx_regdate" />
<column name="status" type="varchar" size="40" notnull="notnull" index="idx_status" />
<column name="errors" type="bigtext" />
</table>

View file

@ -7,7 +7,10 @@
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminConfig'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminConfig')}">{$lang->cmd_advanced_mailer_general_config}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminExceptions'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminExceptions')}">{$lang->cmd_advanced_mailer_exception_domains}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminSpfDkim'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminSpfDkim')}">{$lang->cmd_advanced_mailer_spf_dkim_setting}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminTestConfig'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminTestConfig')}">{$lang->cmd_advanced_mailer_test}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminSentMail'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminSentMail')}">{$lang->cmd_advanced_mailer_log_sent_mail}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminErrors'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminErrors')}">{$lang->cmd_advanced_mailer_log_errors}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminMailTest'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminMailTest')}">{$lang->cmd_advanced_mailer_mail_test}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminMailLog'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminMailLog')}">{$lang->cmd_advanced_mailer_log_mail}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminMailErrors'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminMailErrors')}">{$lang->cmd_advanced_mailer_log_mail_errors}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminSMSTest'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminSMSTest')}">{$lang->cmd_advanced_mailer_sms_test}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminSMSLog'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminSMSLog')}">{$lang->cmd_advanced_mailer_log_sms}</a></li>
<li class="x_active"|cond="$act == 'dispAdvanced_mailerAdminSMSErrors'"><a href="{getUrl('', 'module', 'admin', 'act', 'dispAdvanced_mailerAdminSMSErrors')}">{$lang->cmd_advanced_mailer_log_sms_errors}</a></li>
</ul>

View file

@ -36,7 +36,7 @@
<h2 style="padding-top:12px">{$lang->cmd_advanced_mailer_logging}</h2>
<div class="x_control-group">
<label class="x_control-label" for="advanced_mailer_log_sent_mail">{$lang->cmd_advanced_mailer_log_sent_mail}</label>
<label class="x_control-label" for="advanced_mailer_log_sent_mail">{$lang->cmd_advanced_mailer_log_mail}</label>
<div class="x_controls">
<select name="log_sent_mail" id="advanced_mailer_log_sent_mail">
<option value="Y" selected="selected"|cond="toBool($advanced_mailer_config->log_sent_mail)" />{$lang->cmd_advanced_mailer_log_yes}</option>
@ -46,7 +46,7 @@
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_advanced_mailer_log_errors}</label>
<label class="x_control-label">{$lang->cmd_advanced_mailer_log_mail_errors}</label>
<div class="x_controls">
<select name="log_errors" id="advanced_mailer_log_errors">
<option value="Y" selected="selected"|cond="toBool($advanced_mailer_config->log_errors)" />{$lang->cmd_advanced_mailer_log_yes}</option>
@ -55,6 +55,26 @@
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="advanced_mailer_log_sent_sms">{$lang->cmd_advanced_mailer_log_sms}</label>
<div class="x_controls">
<select name="log_sent_sms" id="advanced_mailer_log_sent_sms">
<option value="Y" selected="selected"|cond="toBool($advanced_mailer_config->log_sent_sms)" />{$lang->cmd_advanced_mailer_log_yes}</option>
<option value="N" selected="selected"|cond="!toBool($advanced_mailer_config->log_sent_sms)" />{$lang->cmd_advanced_mailer_log_no}</option>
</select>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_advanced_mailer_log_sms_errors}</label>
<div class="x_controls">
<select name="log_sms_errors" id="advanced_mailer_log_sms_errors">
<option value="Y" selected="selected"|cond="toBool($advanced_mailer_config->log_sms_errors)" />{$lang->cmd_advanced_mailer_log_yes}</option>
<option value="N" selected="selected"|cond="!toBool($advanced_mailer_config->log_sms_errors)" />{$lang->cmd_advanced_mailer_log_no}</option>
</select>
</div>
</div>
</section>
<div class="btnArea x_clearfix">

View file

@ -3,16 +3,38 @@
$(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");
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_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");
},
function(response) {
$("#advanced_mailer_test_result").text("AJAX Error");
$("#advanced_mailer_test_send").removeAttr("disabled");
}
);
});
$("#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");

View file

@ -4,7 +4,7 @@
<form class="x_form-horizontal" action="./" method="post" id="advanced_mailer">
<input type="hidden" name="module" value="advanced_mailer" />
<input type="hidden" name="act" value="procAdvanced_mailerAdminTestConfig" />
<input type="hidden" name="act" value="procAdvanced_mailerAdminTestSendMail" />
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
@ -13,7 +13,7 @@
<section class="section">
<h2>{$lang->cmd_advanced_mailer_test}</h2>
<h2>{$lang->cmd_advanced_mailer_mail_test}</h2>
<div class="x_control-group">
<label class="x_control-label" for="advanced_mailer_recipient_name">{$lang->cmd_advanced_mailer_recipient_name}</label>
@ -39,7 +39,7 @@
</section>
<div class="btnArea x_clearfix">
<button id="advanced_mailer_test_send" type="submit" class="x_btn x_btn-primary x_pull-right">{$lang->cmd_advanced_mailer_send}</button>
<button id="advanced_mailer_test_send_mail" type="submit" class="x_btn x_btn-primary x_pull-right">{$lang->cmd_advanced_mailer_send}</button>
</div>
</form>

View file

@ -0,0 +1,79 @@
<include target="./common.html" />
<load target="css/view_log.css" />
<load target="js/view_log.js" />
<table id="advanced_mailer_log" class="x_table x_table-striped x_table-hover">
<caption>
<strong>Total: {number_format($total_count)}, Page: {number_format($page)}/{number_format($total_page)}</strong>
</caption>
<thead>
<tr>
<th scope="col" class="nowr">{$lang->cmd_advanced_mailer_status_sender}</th>
<th scope="col" class="nowr">{$lang->cmd_advanced_mailer_status_recipient}</th>
<th scope="col" class="nowr">{$lang->cmd_advanced_mailer_status_content}</th>
<th scope="col" class="nowr">{$lang->cmd_advanced_mailer_status_sending_method}</th>
<th scope="col" class="nowr">{$lang->cmd_advanced_mailer_status_time}</th>
<th scope="col" class="nowr">{$lang->cmd_advanced_mailer_status}</th>
</tr>
</thead>
<tbody>
<tr loop="$advanced_mailer_log => $sms_id, $val">
<td class="nowr">
{htmlspecialchars($val->sms_from)}
</td>
<td class="nowr">
{htmlspecialchars($val->sms_to)}
</td>
<td class="nowr">{nl2br(htmlspecialchars($val->content))}</td>
<td class="nowr">
{@ 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)}
</td>
<td class="nowr">{(zdate($val->regdate, "Y-m-d\nH:i:s"))}</td>
<td class="nowr">
<!--@if($val->status === 'success')-->
{$lang->cmd_advanced_mailer_status_success}
<!--@else-->
<a href="javascript:void(0)" class="show-errors">{$lang->cmd_advanced_mailer_status_error}</a>
<div class="mail-log-errors">
<strong>{$lang->cmd_advanced_mailer_status_error_msg}:</strong><br />
{nl2br(htmlspecialchars(trim($val->errors)))}<br /><br />
<strong>{$lang->cmd_advanced_mailer_status_calling_script}:</strong><br />
{htmlspecialchars($val->calling_script)}
</div>
<!--@end-->
</td>
</tr>
<tr cond="!$advanced_mailer_log">
<td>{$lang->msg_advanced_mailer_log_is_empty}</td>
</tr>
</tbody>
</table>
<div class="x_clearfix">
<form class="x_pagination x_pull-left" style="margin-top:8px" action="{Context::getUrl('')}" method="post" no-error-return-url="true">
<input loop="$param => $key, $val" cond="!in_array($key, array('mid', 'vid', 'act'))" type="hidden" name="{$key}" value="{$val}" />
<ul>
<li class="x_disabled"|cond="$page == 1"><a href="{getUrl('page', '')}">&laquo; {$lang->first_page}</a></li>
<!--@while($page_no = $page_navigation->getNextPage())-->
<li class="x_active"|cond="$page_no == $page"><a href="{getUrl('page', $page_no)}">{$page_no}</a></li>
<!--@end-->
<li class="x_disabled"|cond="$page == $page_navigation->last_page"><a href="{getUrl('page', $page_navigation->last_page)}">{$lang->last_page} &raquo;</a></li>
</ul>
</form>
<form class="x_pull-right x_input-append" style="margin-top:8px" action="{Context::getUrl('')}" method="post">
<input type="hidden" name="module" value="advanced_mailer" />
<input type="hidden" name="act" value="procAdvanced_mailerAdminClearSentSMS" />
<input type="hidden" name="status" value="{$advanced_mailer_status}" />
<select name="clear_before_days" style="width:120px">
<option value="0">{$lang->cmd_advanced_mailer_clear_log_condition_all}</option>
<option value="1">{sprintf($lang->cmd_advanced_mailer_clear_log_condition, 1)}</option>
<option value="3">{sprintf($lang->cmd_advanced_mailer_clear_log_condition, 3)}</option>
<option value="7" selected="selected">{sprintf($lang->cmd_advanced_mailer_clear_log_condition, 7)}</option>
<option value="14">{sprintf($lang->cmd_advanced_mailer_clear_log_condition, 14)}</option>
<option value="30">{sprintf($lang->cmd_advanced_mailer_clear_log_condition, 30)}</option>
<option value="60">{sprintf($lang->cmd_advanced_mailer_clear_log_condition, 60)}</option>
</select>
<button class="x_btn" type="submit" disabled="disabled"|cond="!count($advanced_mailer_log)">{$lang->cmd_advanced_mailer_clear_log_button}</button>
</form>
</div>

View file

@ -0,0 +1,48 @@
<include target="./common.html" />
<load target="css/config.css" />
<load target="js/config.js" />
<form class="x_form-horizontal" action="./" method="post" id="advanced_mailer">
<input type="hidden" name="module" value="advanced_mailer" />
<input type="hidden" name="act" value="procAdvanced_mailerAdminTestSendSMS" />
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>
<section class="section">
<h2>{$lang->cmd_advanced_mailer_sms_test}</h2>
<div class="x_control-group">
<label class="x_control-label" for="advanced_mailer_recipient_number">{$lang->cmd_advanced_mailer_recipient_number}</label>
<div class="x_controls">
<input type="text" id="advanced_mailer_recipient_number" value="{config('sms.default_from')}" />
&nbsp;{$lang->cmd_advanced_mailer_country_code}&nbsp;
<input type="number" id="advanced_mailer_country_code" value="" />
<p class="x_help-block">{$lang->cmd_advanced_mailer_country_code_help}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="advanced_mailer_content">{$lang->cmd_advanced_mailer_status_content}</label>
<div class="x_controls">
<textarea id="advanced_mailer_content">{$lang->cmd_advanced_mailer_test_content}</textarea>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_advanced_mailer_test_result}</label>
<div class="x_controls">
<div id="advanced_mailer_test_result"></div>
</div>
</div>
</section>
<div class="btnArea x_clearfix">
<button id="advanced_mailer_test_send_sms" type="submit" class="x_btn x_btn-primary x_pull-right">{$lang->cmd_advanced_mailer_send}</button>
</div>
</form>