Add table and triggers for SMS logging

This commit is contained in:
Kijin Sung 2016-12-14 00:01:55 +09:00
parent 211a201e04
commit 137728d527
3 changed files with 47 additions and 0 deletions

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

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

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>