/** * Send an email to watchers with the comment body * @param int $issue_id * @param int $comment_id */ public function issue_comment($issue_id, $comment_id) { $f3 = \Base::instance(); if ($f3->get("mail.from")) { $log = new \Log("mail.log"); // Get issue and comment data $issue = new \Model\Issue(); $issue->load($issue_id); $comment = new \Model\Issue\Comment\Detail(); $comment->load($comment_id); // Get issue parent if set if ($issue->parent_id) { $parent = new \Model\Issue(); $parent->load($issue->parent_id); $f3->set("parent", $parent); } // Get recipient list and remove current user $recipients = $this->_issue_watchers($issue_id); $recipients = array_diff($recipients, array($comment->user_email)); // Render message body $f3->set("issue", $issue); $f3->set("comment", $comment); $text = $this->_render("notification/comment.txt"); $body = $this->_render("notification/comment.html"); $subject = "[#{$issue->id}] - New comment on {$issue->name}"; // Send to recipients foreach ($recipients as $recipient) { $this->utf8mail($recipient, $subject, $body, $text); $log->write("Sent comment notification to: " . $recipient); } } }