diff --git a/application/admin/controllers/SysController.php b/application/admin/controllers/SysController.php index 0a3ac65b..074b8665 100644 --- a/application/admin/controllers/SysController.php +++ b/application/admin/controllers/SysController.php @@ -91,14 +91,29 @@ class Admin_SysController extends Zend_Controller_Action { try{ $subject = $this->_request->getParam('subject'); - $email = $this->_request->getParam('email'); - $body = $this->_request->getParam('body'); - $body=str_replace("[username]",$this->_request->getParam('user'),$body); + $email = $this->_request->getParam('email'); + $body = $this->_request->getParam('body'); + if(empty($subject) || empty($email)) { $this->messenger->addMessage('请填写测试邮件发送信息'); $this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id); - } + } + + $mailtp=new EmailText(); + $mailtp->db = $this->db; + $mailtp->tmpid = $this->_request->getParam('id'); + $mailtp->data = array( + 'user' => $this->_request->getParam('user') + ); + $body = $mailtp->loadtmp(); + if($body === false) + { + $this->messenger->addMessage('模板加载失败'); + $this->_redirect('/admin/sys/emailtext/ac/test/id/'.$id); + } + + $mail=new WestdcMailer($this->view->config->smtp); $mail->setBodyText($body); @@ -119,7 +134,7 @@ class Admin_SysController extends Zend_Controller_Action } } else - { + { $sql = "select * from emailtext where id='$id'"; $rs = $this->db->query($sql); $rows = $rs->fetch(); @@ -129,8 +144,14 @@ class Admin_SysController extends Zend_Controller_Action }//模板测试 + else if($ac=='help') + { + $this->_helper->viewRenderer('emailtexthelp'); + } + else { + try{ $sql = "select id,subject,template,ts_created,ts_changed from emailtext"; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); @@ -141,6 +162,9 @@ class Admin_SysController extends Zend_Controller_Action $paginator->setView($this->view); Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml'); $this->view->paginator=$paginator; + }catch (Exception $e){ + echo $e->getMessage(); + } }//邮件模板管理首页 }//emailtextAction 邮件模板管理 diff --git a/application/admin/views/scripts/sys/emailtexthelp.phtml b/application/admin/views/scripts/sys/emailtexthelp.phtml new file mode 100644 index 00000000..11bbe822 --- /dev/null +++ b/application/admin/views/scripts/sys/emailtexthelp.phtml @@ -0,0 +1,79 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('系统管理'); + $this->breadcrumb('邮件模板管理'); + $this->breadcrumb()->setSeparator(' > '); +?> +
邮件模板编写时暂时不支持html格式,只能使用纯文本编写
++模板中可以使用变量标记,比如 {user} 将被替换为用户名,变量的起始使用“{”,结束使用"}",完整的变量格式应类似“{param}” +
++目前程序中已预制的变量包括: +
变量名 | +说明 | +输出值举例 | +作用域 | +
{user} | +用户名 | +张三 | +全局 | +
{uuid} | +元数据UUID | +76bce7bb-e1b2-49c4-9537-668a6bac42a2 | +全局 | +
{title} | +元数据title | +黑河流域气象观测站点分布图 | +专家邀请模板 | +
+一个邮件模板例子:
+
+
+尊敬的{user}您好!想获得元数据《{title}》,请访问 http://westdc.westgis.ac.cn/data/{uuid}
+