Fixed issue 220, redirect to the issue or the issue comment after an updating.

This commit is contained in:
Mehdi Kabab 2009-05-26 12:04:06 +02:00 committed by Loic d'Anterroches
parent 3476541bf4
commit 668b49df40

View File

@ -171,11 +171,8 @@ class IDF_Views_Issue
$params); $params);
if (!isset($request->POST['preview']) and $form->isValid()) { if (!isset($request->POST['preview']) and $form->isValid()) {
$issue = $form->save(); $issue = $form->save();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::index', $url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($prj->shortname));
$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));
$to_emails = array(); $to_emails = array();
if (null != $issue->get_owner() and $issue->owner != $issue->submitter) { if (null != $issue->get_owner() and $issue->owner != $issue->submitter) {
$to_emails[] = $issue->get_owner()->email; $to_emails[] = $issue->get_owner()->email;
@ -201,6 +198,7 @@ class IDF_Views_Issue
$email->sendMail(); $email->sendMail();
} }
if ($api) return $issue; if ($api) return $issue;
$request->user->setMessage(sprintf(__('<a href="%s">Issue %d</a> has been created.'), $url, $issue->id));
return new Pluf_HTTP_Response_Redirect($url); return new Pluf_HTTP_Response_Redirect($url);
} }
} else { } else {
@ -291,11 +289,8 @@ class IDF_Views_Issue
$params); $params);
if (!isset($request->POST['preview']) && $form->isValid()) { if (!isset($request->POST['preview']) && $form->isValid()) {
$issue = $form->save(); $issue = $form->save();
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::index', $comments = $issue->get_comments_list(array('order' => 'id DESC'));
array($prj->shortname)); $url .= '#ic' . $comments[0]->id;
$urlissue = Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($prj->shortname, $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 // Get the list of interested person + owner + submitter
if (!Pluf_Model_InArray($issue->get_submitter(), $interested)) { if (!Pluf_Model_InArray($issue->get_submitter(), $interested)) {
$interested[] = $issue->get_submitter(); $interested[] = $issue->get_submitter();
@ -304,15 +299,13 @@ class IDF_Views_Issue
!Pluf_Model_InArray($issue->get_owner(), $interested)) { !Pluf_Model_InArray($issue->get_owner(), $interested)) {
$interested[] = $issue->get_owner(); $interested[] = $issue->get_owner();
} }
$comments = $issue->get_comments_list(array('order' => 'id DESC'));
$context = new Pluf_Template_Context( $context = new Pluf_Template_Context(
array( array(
'issue' => $issue, 'issue' => $issue,
'comments' => $comments, 'comments' => $comments,
'project' => $prj, 'project' => $prj,
'url_base' => Pluf::f('url_base'), 'url_base' => Pluf::f('url_base'),
) ));
);
$tmpl = new Pluf_Template('idf/issues/issue-updated-email.txt'); $tmpl = new Pluf_Template('idf/issues/issue-updated-email.txt');
$text_email = $tmpl->render($context); $text_email = $tmpl->render($context);
$email = new Pluf_Mail_Batch(Pluf::f('from_email')); $email = new Pluf_Mail_Batch(Pluf::f('from_email'));
@ -334,6 +327,7 @@ class IDF_Views_Issue
$email->sendMail(); $email->sendMail();
} }
$email->close(); $email->close();
$request->user->setMessage(sprintf(__('<a href="%s">Issue %d</a> has been updated.'), $url, $issue->id));
return new Pluf_HTTP_Response_Redirect($url); return new Pluf_HTTP_Response_Redirect($url);
} }
} else { } else {