diff --git a/src/IDF/Form/ReviewCreate.php b/src/IDF/Form/ReviewCreate.php index 57a8ca7..22b7b8d 100644 --- a/src/IDF/Form/ReviewCreate.php +++ b/src/IDF/Form/ReviewCreate.php @@ -179,6 +179,26 @@ class IDF_Form_ReviewCreate extends Pluf_Form $patch->commit = self::findCommit($this->cleaned_data['commit']); $patch->patch = $this->cleaned_data['patch']; $patch->create(); + // Send create notification + if ('' != $this->project->getConf()->getVal('review_notification_email', '')) { + $context = new Pluf_Template_Context( + array( + 'review' => $review, + 'patch' => $patch, + 'comments' => array(), + 'project' => $this->project, + 'url_base' => Pluf::f('url_base'), + ) + ); + $tmpl = new Pluf_Template('idf/review/review-created-email.txt'); + $text_email = $tmpl->render($context); + $email = new Pluf_Mail(Pluf::f('from_email'), + $this->project->getConf()->getVal('review_notification_email'), + sprintf(__('New Code Review %s - %s (%s)'), + $review->id, $review->summary, $this->project->shortname)); + $email->addTextMessage($text_email); + $email->sendMail(); + } return $review; } diff --git a/src/IDF/Views/Review.php b/src/IDF/Views/Review.php index 4578bbb..8a53a38 100644 --- a/src/IDF/Views/Review.php +++ b/src/IDF/Views/Review.php @@ -177,16 +177,23 @@ class IDF_Views_Review $tmpl = new Pluf_Template('idf/review/review-updated-email.txt'); $text_email = $tmpl->render($context); $email = new Pluf_Mail_Batch(Pluf::f('from_email')); + $to_emails = array(); foreach ($reviewers as $user) { if ($user->id != $request->user->id) { - $email->setSubject(sprintf(__('Updated Code Review %s - %s (%s)'), - $review->id, $review->summary, $prj->shortname)); - $email->setTo($user->email); - $email->setReturnPath(Pluf::f('from_email')); - $email->addTextMessage($text_email); - $email->sendMail(); + $to_emails[] = $user->email; } } + if ('' != $request->conf->getVal('review_notification_email', '')) { + $to_emails[] = $request->conf->getVal('review_notification_email'); + } + foreach ($to_emails as $oemail) { + $email->setSubject(sprintf(__('Updated Code Review %s - %s (%s)'), + $review->id, $review->summary, $prj->shortname)); + $email->setTo($oemail); + $email->setReturnPath(Pluf::f('from_email')); + $email->addTextMessage($text_email); + $email->sendMail(); + } $email->close(); return new Pluf_HTTP_Response_Redirect($url); } diff --git a/src/IDF/templates/idf/review/review-created-email.txt b/src/IDF/templates/idf/review/review-created-email.txt new file mode 100644 index 0000000..af19808 --- /dev/null +++ b/src/IDF/templates/idf/review/review-created-email.txt @@ -0,0 +1,16 @@ +{trans 'Hello,'} + +{blocktrans}The following review has been created:{/blocktrans} + +{$review.id} - {$review.summary|safe} +{trans 'Project:'} {$project.name|safe} +{trans 'Status:'} {$review.get_status.name} +{trans 'Reported by:'} {$review.get_submitter|safe} +{trans 'URL:'} {$url_base}{url 'IDF_Views_Review::view', array($project.shortname, $review.id)} +{assign $tags = $review.get_tags_list()}{if $tags.count()}{trans 'Labels:'} +{foreach $tags as $tag} {$tag.class|safe}:{$tag.name|safe} +{/foreach} +{/if} + +-- +{trans 'Review:'} {$url_base}{url 'IDF_Views_Review::view', array($project.shortname, $review.id)}