From e513d95dbe687ea1c420ed0e6a517cf0de63d122 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Sun, 25 Jan 2009 10:58:24 +0100 Subject: [PATCH] Added the notification for the tickets. --- src/IDF/Views/Issue.php | 27 ++++++++++++++++++++------- src/IDF/Views/Project.php | 1 + src/IDF/templates/idf/admin/tabs.html | 3 ++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/IDF/Views/Issue.php b/src/IDF/Views/Issue.php index 027ad04..106c11c 100644 --- a/src/IDF/Views/Issue.php +++ b/src/IDF/Views/Issue.php @@ -153,7 +153,14 @@ class IDF_Views_Issue $urlissue = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view', array($prj->shortname, $issue->id)); $request->user->setMessage(sprintf(__('Issue %d has been created.'), $urlissue, $issue->id)); + $to_emails = array(); if (null != $issue->get_owner() and $issue->owner != $issue->submitter) { + $to_emails[] = $issue->get_owner()->email; + } + if ('' != $request->conf->getVal('issues_notification_email', '')) { + $to_emails[] = $request->conf->getVal('issues_notification_email', ''); + } + foreach ($to_emails as $oemail) { $comments = $issue->get_comments_list(array('order' => 'id ASC')); $context = new Pluf_Template_Context( array( @@ -163,7 +170,6 @@ class IDF_Views_Issue 'url_base' => Pluf::f('url_base'), ) ); - $oemail = $issue->get_owner()->email; $email = new Pluf_Mail(Pluf::f('from_email'), $oemail, sprintf(__('Issue %s - %s (%s)'), $issue->id, $issue->summary, $prj->shortname)); @@ -284,16 +290,23 @@ class IDF_Views_Issue $tmpl = new Pluf_Template('idf/issues/issue-updated-email.txt'); $text_email = $tmpl->render($context); $email = new Pluf_Mail_Batch(Pluf::f('from_email')); + $to_emails = array(); foreach ($interested as $user) { if ($user->id != $request->user->id) { - $email->setSubject(sprintf(__('Updated Issue %s - %s (%s)'), - $issue->id, $issue->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('issues_notification_email', '')) { + $to_emails[] = $request->conf->getVal('issues_notification_email'); + } + foreach ($to_emails as $oemail) { + $email->setSubject(sprintf(__('Updated Issue %s - %s (%s)'), + $issue->id, $issue->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/Views/Project.php b/src/IDF/Views/Project.php index d41a1d9..6766161 100644 --- a/src/IDF/Views/Project.php +++ b/src/IDF/Views/Project.php @@ -452,6 +452,7 @@ class IDF_Views_Project array( 'page_title' => $title, 'form' => $form, + 'from_email' => Pluf::f('from_email'), ), $request); } diff --git a/src/IDF/templates/idf/admin/tabs.html b/src/IDF/templates/idf/admin/tabs.html index 366419a..b49da19 100644 --- a/src/IDF/templates/idf/admin/tabs.html +++ b/src/IDF/templates/idf/admin/tabs.html @@ -86,7 +86,8 @@ {block context}

{trans 'Instructions:'}

-

{blocktrans}You can configure here the project tabs access rights.{/blocktrans}

+

{blocktrans}You can configure here the project tabs access rights and notification emails.{/blocktrans}

+

{blocktrans}Notification emails will be sent by the {$from_email} address, if you send the email to a mailing list, you may need to register this email address. If you do not want to send emails for a given type of changes, simply leave the corresponding field empty.{/blocktrans}

{blocktrans}If you mark a project as private, only the project members and administrators, together with the extra authorized users you provide will have access to the project. You will still be able to define further access rights for the different tabs but the "Open to all" and "Signed in users" will default to authorized users only.{/blocktrans}

{blocktrans}Specify each person by its login. Each person must have already registered with the given login. Separate the logins with commas and/or new lines.{/blocktrans}