Fixed issue 13, email notifications.
Email notifications are now sent at creation/modification of an issue.
This commit is contained in:
parent
4b2139fe99
commit
6360ea93be
@ -136,7 +136,7 @@ class IDF_Issue extends Pluf_Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function preSave()
|
function preSave($create=false)
|
||||||
{
|
{
|
||||||
if ($this->id == '') {
|
if ($this->id == '') {
|
||||||
$this->creation_dtime = gmdate('Y-m-d H:i:s');
|
$this->creation_dtime = gmdate('Y-m-d H:i:s');
|
||||||
@ -144,7 +144,7 @@ class IDF_Issue extends Pluf_Model
|
|||||||
$this->modif_dtime = gmdate('Y-m-d H:i:s');
|
$this->modif_dtime = gmdate('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
function postSave()
|
function postSave($create=false)
|
||||||
{
|
{
|
||||||
// This will be used to fire the indexing or send a
|
// This will be used to fire the indexing or send a
|
||||||
// notification email to the interested people, etc.
|
// notification email to the interested people, etc.
|
||||||
|
@ -90,7 +90,7 @@ class IDF_IssueComment extends Pluf_Model
|
|||||||
|
|
||||||
function changedIssue()
|
function changedIssue()
|
||||||
{
|
{
|
||||||
return count($this->changes) > 0;
|
return (is_array($this->changes) and count($this->changes) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _toIndex()
|
function _toIndex()
|
||||||
@ -98,14 +98,14 @@ class IDF_IssueComment extends Pluf_Model
|
|||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
function preSave()
|
function preSave($create=false)
|
||||||
{
|
{
|
||||||
if ($this->id == '') {
|
if ($this->id == '') {
|
||||||
$this->creation_dtime = gmdate('Y-m-d H:i:s');
|
$this->creation_dtime = gmdate('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function postSave()
|
function postSave($create=false)
|
||||||
{
|
{
|
||||||
// This will be used to fire the indexing or send a
|
// This will be used to fire the indexing or send a
|
||||||
// notification email to the interested people, etc.
|
// notification email to the interested people, etc.
|
||||||
|
@ -90,7 +90,7 @@ class IDF_Project extends Pluf_Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function preSave()
|
function preSave($create=false)
|
||||||
{
|
{
|
||||||
if ($this->id == '') {
|
if ($this->id == '') {
|
||||||
$this->creation_dtime = gmdate('Y-m-d H:i:s');
|
$this->creation_dtime = gmdate('Y-m-d H:i:s');
|
||||||
|
@ -89,7 +89,7 @@ class IDF_Tag extends Pluf_Model
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function preSave()
|
function preSave($create=false)
|
||||||
{
|
{
|
||||||
$this->lcname = mb_strtolower($this->name);
|
$this->lcname = mb_strtolower($this->name);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ class IDF_Upload extends Pluf_Model
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function preSave()
|
function preSave($create=false)
|
||||||
{
|
{
|
||||||
if ($this->id == '') {
|
if ($this->id == '') {
|
||||||
$this->creation_dtime = gmdate('Y-m-d H:i:s');
|
$this->creation_dtime = gmdate('Y-m-d H:i:s');
|
||||||
|
@ -144,6 +144,24 @@ class IDF_Views_Issue
|
|||||||
$urlissue = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
|
$urlissue = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
|
||||||
array($prj->shortname, $issue->id));
|
array($prj->shortname, $issue->id));
|
||||||
$request->user->setMessage(sprintf(__('<a href="%s">Issue %d</a> has been created.'), $urlissue, $issue->id));
|
$request->user->setMessage(sprintf(__('<a href="%s">Issue %d</a> has been created.'), $urlissue, $issue->id));
|
||||||
|
if (null != $issue->get_owner() and $issue->owner != $issue->submitter) {
|
||||||
|
$comments = $issue->get_comments_list(array('order' => 'id ASC'));
|
||||||
|
$context = new Pluf_Template_Context(
|
||||||
|
array(
|
||||||
|
'issue' => $issue,
|
||||||
|
'comment' => $comments[0],
|
||||||
|
'project' => $prj,
|
||||||
|
'url_base' => Pluf::f('url_base'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$oemail = $issue->get_owner()->email;
|
||||||
|
$email = new Pluf_Mail(Pluf::f('from_email'), $oemail,
|
||||||
|
sprintf(__('Issue %s - %s (InDefero)'),
|
||||||
|
$issue->id, $issue->summary));
|
||||||
|
$tmpl = new Pluf_Template('issues/issue-created-email.txt');
|
||||||
|
$email->addTextMessage($tmpl->render($context));
|
||||||
|
$email->sendMail();
|
||||||
|
}
|
||||||
return new Pluf_HTTP_Response_Redirect($url);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -186,6 +204,38 @@ class IDF_Views_Issue
|
|||||||
$urlissue = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
|
$urlissue = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
|
||||||
array($prj->shortname, $issue->id));
|
array($prj->shortname, $issue->id));
|
||||||
$request->user->setMessage(sprintf(__('<a href="%s">Issue %d</a> has been updated.'), $urlissue, $issue->id));
|
$request->user->setMessage(sprintf(__('<a href="%s">Issue %d</a> has been updated.'), $urlissue, $issue->id));
|
||||||
|
// Get the list of interested person + owner + submitter
|
||||||
|
$interested = $issue->get_interested_list();
|
||||||
|
if (!Pluf_Model_InArray($issue->get_submitter(), $interested)) {
|
||||||
|
$interested[] = $issue->get_submitter();
|
||||||
|
}
|
||||||
|
if (null != $issue->get_owner() and
|
||||||
|
!Pluf_Model_InArray($issue->get_owner(), $interested)) {
|
||||||
|
$interested[] = $issue->get_owner();
|
||||||
|
}
|
||||||
|
$comments = $issue->get_comments_list(array('order' => 'id DESC'));
|
||||||
|
$context = new Pluf_Template_Context(
|
||||||
|
array(
|
||||||
|
'issue' => $issue,
|
||||||
|
'comments' => $comments,
|
||||||
|
'project' => $prj,
|
||||||
|
'url_base' => Pluf::f('url_base'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$tmpl = new Pluf_Template('issues/issue-updated-email.txt');
|
||||||
|
$text_email = $tmpl->render($context);
|
||||||
|
$email = new Pluf_Mail_Batch(Pluf::f('from_email'));
|
||||||
|
foreach ($interested as $user) {
|
||||||
|
if ($user->id != $request->user->id) {
|
||||||
|
$email->setSubject(sprintf(__('Updated Issue %s - %s (InDefero)'),
|
||||||
|
$issue->id, $issue->summary));
|
||||||
|
$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);
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
18
src/IDF/templates/issues/issue-created-email.txt
Normal file
18
src/IDF/templates/issues/issue-created-email.txt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{trans 'Hello,'}
|
||||||
|
|
||||||
|
{blocktrans}A new issue has been created and assigned
|
||||||
|
to you:{/blocktrans}
|
||||||
|
|
||||||
|
{$issue.id} - {$issue.summary|safe}
|
||||||
|
{trans 'Project:'} {$project.name|safe}
|
||||||
|
{trans 'Status:'} {$issue.get_status.name|safe}
|
||||||
|
{trans 'Reported by:'} {$issue.get_submitter|safe}
|
||||||
|
{assign $tags = $issue.get_tags_list()}{if $tags.count()}{trans 'Labels:'}
|
||||||
|
{foreach $tags as $tag} {$tag.class|safe}:{$tag.name|safe}
|
||||||
|
{/foreach}{/if}
|
||||||
|
{trans 'Description:'}
|
||||||
|
|
||||||
|
{$comment.content|safe}
|
||||||
|
|
||||||
|
--
|
||||||
|
{trans 'Issue:'} {$url_base}{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}
|
24
src/IDF/templates/issues/issue-updated-email.txt
Normal file
24
src/IDF/templates/issues/issue-updated-email.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{trans 'Hello,'}
|
||||||
|
|
||||||
|
{blocktrans}The following issue has been updated:{/blocktrans}
|
||||||
|
|
||||||
|
{$issue.id} - {$issue.summary|safe}
|
||||||
|
{trans 'Project:'} {$project.name|safe}
|
||||||
|
{trans 'Status:'} {$issue.get_status.name}
|
||||||
|
{trans 'Reported by:'} {$issue.get_submitter|safe}
|
||||||
|
{trans 'URL:'} {$url_base}{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}
|
||||||
|
{assign $tags = $issue.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}:{/blocktrans}
|
||||||
|
|
||||||
|
{if strlen($c.content) > 0}{$c.content|safe}{else}{trans '(No comments were given for this change.)'}{/if}{if $c.changedIssue()}
|
||||||
|
{foreach $c.changes as $w => $v}
|
||||||
|
{if $w == 'su'}{trans 'Summary:'}{/if}{if $w == 'st'}{trans 'Status:'}{/if}{if $w == 'ow'}{trans 'Owner:'}{/if}{if $w == 'lb'}{trans 'Labels:'}{/if} {if $w == 'lb'}{assign $l = implode(', ', $v)}{$l}{else}{$v}{/if}{/foreach}{/if}
|
||||||
|
|
||||||
|
{/foreach}
|
||||||
|
|
||||||
|
--
|
||||||
|
{trans 'Issue:'} {$url_base}{url 'IDF_Views_Issue::view', array($project.shortname, $issue.id)}
|
Loading…
Reference in New Issue
Block a user