diff --git a/Westdc/Mail/Sender.php b/Westdc/Mail/Sender.php index b7c860c..51dbc9b 100644 --- a/Westdc/Mail/Sender.php +++ b/Westdc/Mail/Sender.php @@ -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 diff --git a/Westdc/Review/Review.php b/Westdc/Review/Review.php index 010988e..77c0a83 100644 --- a/Westdc/Review/Review.php +++ b/Westdc/Review/Review.php @@ -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){ }