Exemple #1
0
 /**
  * @param Psn_Model_Rule $rule
  * @param $post
  */
 public function execute(Psn_Model_Rule $rule, $post)
 {
     if ((int) $rule->get('service_email') !== 1) {
         return;
     }
     $this->_reset();
     $this->_rule = $rule;
     $this->_post = $post;
     // create email object
     $this->_email = new IfwPsn_Wp_Email(self::EMAIL_IDENTIFIER);
     // prepare recipients
     $this->_prepareRecipients($rule, $post);
     if (!empty($this->_to)) {
         // send email
         $this->_email->setTo($this->getFormattedEmails($this->_to))->setSubject($this->_getPreparedSubject($rule))->setMessage($this->_getPreparedBody($rule));
         if ($this->hasCc()) {
             $this->_email->setCc($this->getFormattedEmails($this->_cc));
         }
         if ($this->hasBcc()) {
             $this->_email->setBcc($this->getFormattedEmails($this->_bcc));
         }
         if ((int) $this->_rule->get('service_log') === 1) {
             $this->_email->setOption('service_log', true);
         } else {
             $this->_email->setOption('service_log', false);
         }
         IfwPsn_Wp_Proxy_Action::doAction('psn_before_notification_email_send', $this);
         $this->_email->send();
         IfwPsn_Wp_Proxy_Action::doAction('psn_after_notification_email_send', $this);
     }
 }