From da23f2b915183cdd13028f749da65c1ed9ea8b50 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Mon, 1 Dec 2008 21:39:17 +0100 Subject: [PATCH] Added review update notification. --- src/IDF/Views/Review.php | 34 +++++++++++++++++-- .../idf/review/review-updated-email.txt | 24 +++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/IDF/templates/idf/review/review-updated-email.txt diff --git a/src/IDF/Views/Review.php b/src/IDF/Views/Review.php index b183df7..cffe893 100644 --- a/src/IDF/Views/Review.php +++ b/src/IDF/Views/Review.php @@ -153,11 +153,41 @@ class IDF_Views_Review )); if ($form->isValid()) { $patch = $form->save(); + $review = $patch->get_review(); $urlr = Pluf_HTTP_URL_urlForView('IDF_Views_Review::view', - array($prj->shortname, $patch->get_review()->id)); - $request->user->setMessage(sprintf(__('Your code review %d has been published.'), $urlr, $patch->get_review()->id)); + array($prj->shortname, $review->id)); + $request->user->setMessage(sprintf(__('Your code review %d has been published.'), $urlr, $review->id)); $url = Pluf_HTTP_URL_urlForView('IDF_Views_Review::index', array($prj->shortname)); + // Get the list of reviewers + submitter + $reviewers = $review->get_reviewers_list(); + if (!Pluf_Model_InArray($review->get_submitter(), $reviewers)) { + $reviewers[] = $review->get_submitter(); + } + $comments = $patch->get_filecomments_list(array('order' => 'id DESC')); + $context = new Pluf_Template_Context( + array( + 'review' => $review, + 'patch' => $patch, + 'comments' => $comments, + 'project' => $prj, + 'url_base' => Pluf::f('url_base'), + ) + ); + $tmpl = new Pluf_Template('idf/review/review-updated-email.txt'); + $text_email = $tmpl->render($context); + $email = new Pluf_Mail_Batch(Pluf::f('from_email')); + 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(); + } + } + $email->close(); return new Pluf_HTTP_Response_Redirect($url); } } else { diff --git a/src/IDF/templates/idf/review/review-updated-email.txt b/src/IDF/templates/idf/review/review-updated-email.txt new file mode 100644 index 0000000..e75c5ba --- /dev/null +++ b/src/IDF/templates/idf/review/review-updated-email.txt @@ -0,0 +1,24 @@ +{trans 'Hello,'} + +{blocktrans}The following review has been updated:{/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 'Comments (last first):'} + +{foreach $comments as $c}{assign $who = $c.get_submitter()}# {blocktrans}By {$who|safe}, {$c.creation_dtime|date}, on file: +{$c.cfile|safe} +{/blocktrans} + +{$c.content|safe} + +{/foreach} + +-- +{trans 'Review:'} {$url_base}{url 'IDF_Views_Review::view', array($project.shortname, $review.id)}