示例#1
0
 /**
  * Sends notification to users
  *
  * @param modxTalksPost $comment A reference to the actual comment
  *
  * @return bool True if successful
  */
 public function notifyUser(&$comment)
 {
     if (!$comment instanceof modxTalksPost) {
         return false;
     }
     $this->modx->lexicon->load('modxtalks:emails');
     /**
      * Get User info
      */
     $user = $comment->getUserData();
     $cid = $comment->conversationId;
     $idx = $comment->idx;
     $link = $this->generateLink($cid, $idx, 'full');
     $images_url = $this->modx->getOption('site_url') . substr($this->config['imgUrl'], 1);
     $subject = $this->modx->lexicon('modxtalks.email_comment_approved');
     $text = $this->modx->lexicon('modxtalks.email_user_approve_comment', array('link' => $link));
     $params = array('title' => 'Заголовок', 'content' => $this->modx->stripTags($this->bbcode($comment->content)), 'images_url' => $images_url, 'avatar' => $this->getAvatar($user['email'], 50), 'text' => $text, 'date' => date($this->config['dateFormat'] . ' O', $comment->time));
     /**
      * Get email body
      */
     $body = $this->getChunk('mt_send_mail', $params);
     /**
      * Send notifications to user
      */
     $success = false;
     if (!empty($user['email'])) {
         if ($this->sendEmail($subject, $body, $user['email'])) {
             $success = true;
         }
     }
     return $success;
 }