From 658e1d96702dd45e35d1fb60779c23151db2ad93 Mon Sep 17 00:00:00 2001 From: "shayupi@qq.com" Date: Mon, 22 Dec 2014 13:57:24 +0800 Subject: [PATCH] edit emailTemplate duplicate --- Westdc/Mail/Template.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Westdc/Mail/Template.php b/Westdc/Mail/Template.php index 312a95d..374717b 100644 --- a/Westdc/Mail/Template.php +++ b/Westdc/Mail/Template.php @@ -33,8 +33,14 @@ class Template implements ServiceManagerAwareInterface return $rs->fetchAll(\PDO::FETCH_ASSOC); } - public function insert($data,$id=0) + //插入邮件模板 + public function insert($data) { + $temp=$this->fetch($data['template']); + if(isset($temp['id']) && is_numeric($temp['id']) && $temp['id']>0) + { + return '该邮件模板标识已经存在,请更换标识!'; + } $dbhService = $this->serviceManager->get('Db'); $dbh = $dbhService->getDbh(); @@ -44,8 +50,6 @@ class Template implements ServiceManagerAwareInterface $data['subject']='未命名模板'; } - // 替换邮件内容中的 ' 为 '' - $data['body']=str_replace("'","''",$data['body']); $rs = $dbh->insert('emailtext',$data,1); return $rs; @@ -60,13 +64,19 @@ class Template implements ServiceManagerAwareInterface } //更新邮件模板 - public function update($table,$data,$id) + public function update($data,$id) { + $temp=$this->fetch($data['template']); + if(isset($temp['id']) && is_numeric($temp['id']) && $temp['id']>0) + { + if($id!=$temp['id']) + return '该邮件模板标识已经存在,请更换标识!'; + } + $dbhService = $this->serviceManager->get('Db'); $dbh = $dbhService->getDbh(); - // 替换邮件内容中的 ' 为 '' - $data['body']=str_replace("'","''",$data['body']); + $rs = $dbh->update('emailtext',$data,"id=$id",1); return $rs; }