edit emailTemplate duplicate

This commit is contained in:
shayupi@qq.com 2014-12-22 13:57:24 +08:00
parent c705293d85
commit 658e1d9670
1 changed files with 16 additions and 6 deletions

View File

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