add non-MVC framework calling to MailSender,add event review.accepted in Review module

This commit is contained in:
Jianxuan Li 2015-01-04 13:57:48 +08:00
parent 40b58bda04
commit ab512665b0
2 changed files with 11 additions and 32 deletions

View File

@ -10,6 +10,7 @@ namespace Westdc\Mail;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Westdc\Service\ServiceManager as WestdcServiceManager;
class Sender implements ServiceManagerAwareInterface{
@ -24,6 +25,15 @@ class Sender implements ServiceManagerAwareInterface{
return $this;
}
public function __construct()
{
if(!$this->serviceManager instanceof ServiceManager)
{
$serviceManager = new WestdcServiceManager();
$this->serviceManager = $serviceManager->getServiceManager();
}
}
/**
* 发送即时邮件
* @param $options

View File

@ -159,43 +159,12 @@ class Review extends AbstractEventManager implements ServiceManagerAwareInterfac
return false;
}
$authorEmail = $this->getAuthor($id);
foreach($authorEmail as $v)
{
$mailSender = $this->serviceManager->get('Mail/Sender');
$mailSender->backend([
'email' => $v['email'],
'name' => !empty($v['realname']) ? $v['realname']:$v['username'],
'template' => 'review-new-accept',
'data' => [
'uuid' => $v['uuid'],
'title' => $v['title'],
]
]);
}
$this->getEventManager()->trigger('review.accepted', $this, compact('id'));
return true;
}//accept($id)
/**
* 获得某条评审涉及的元数据相关作者信息email,元数据标题uuid)
* @param $id
* @return mixed
*/
public function getAuthor($id){
$sql = "SELECT DISTINCT u.email,u.realname,u.username,m.title,m.uuid FROM mdstatus s
LEFT JOIN metadata m ON s.uuid=m.uuid
RIGHT JOIN mdauthor a ON s.uuid=a.uuid
LEFT JOIN users u ON a.userid=u.id
WHERE s.id=$id
ORDER BY u.email";
$rs = $this->db->query($sql);
return $rs->fetchAll(\PDO::FETCH_ASSOC);
}
public function reset($id){
}