Permalink
Browse files

Sending email when issue is edited. Added link to the email.

  • Loading branch information...
1 parent f5fa47b commit 9df9fc4b6e0e5a1b1a9a035b3649a0787db2054c filo committed Sep 1, 2010
View
BIN data/phpcollab_unit_test.db
Binary file not shown.
View
12 plugins/idProjectManagementPlugin/lib/generator/LogMessageGenerator.php
@@ -19,22 +19,22 @@ public static function getLinkForObject($object)
switch ($object_class)
{
case 'project':
- return link_to($object->name, '@show_project?id='.$object->id);
+ return link_to($object->name, '@show_project?id='.$object->id, array('absolute' => true));
break;
case 'milestone':
- return link_to($object->title, '@show_milestone?project_id='.$object->project_id.'&milestone_id='.$object->id);
+ return link_to($object->title, '@show_milestone?project_id='.$object->project_id.'&milestone_id='.$object->id, array('absolute' => true));
break;
case 'issue':
- return link_to('#'.$object->id.' '.$object->title, '@show_issue?project_id='.$object->project_id.'&issue_id='.$object->id);
+ return link_to('#'.$object->id.' '.$object->title, '@show_issue?project_id='.$object->project_id.'&issue_id='.$object->id, array('absolute' => true));
break;
case 'logtime':
- return "time (".$object->log_time." hours) for ".link_to('#'.$object->issue->id.' '.$object->issue->title, '@show_issue?project_id='.$object->issue->project_id.'&issue_id='.$object->issue->id);
+ return "time (".$object->log_time." hours) for ".link_to('#'.$object->issue->id.' '.$object->issue->title, '@show_issue?project_id='.$object->issue->project_id.'&issue_id='.$object->issue->id, array('absolute' => true));
break;
case 'message':
- return link_to($object->title, '@show_message?project_id='.$object->project_id.'&message_id='.$object->id);
+ return link_to($object->title, '@show_message?project_id='.$object->project_id.'&message_id='.$object->id, array('absolute' => true));
break;
default:
- return (method_exists($object, '__toString')) ? (string)$object : get_class($object);
+ return link_to((method_exists($object, '__toString')) ? (string)$object : get_class($object), '@homepage', array('absolute' => true));
}
}
View
5 plugins/idProjectManagementPlugin/lib/model/doctrine/PluginIssue.class.php
@@ -74,4 +74,9 @@ public function isClosed()
return (bool) ($this->status == 'closed');
}
+ public function getRelatedUsers()
+ {
+ return $this->getUsers();
+ }
+
}
View
13 plugins/idProjectManagementPlugin/modules/idIssue/actions/actions.class.php
@@ -19,7 +19,7 @@
* @subpackage idProjectManagementPlugin Modules
* @author Filippo (p16) De Santis <fd@ideato.it>
*/
-class idIssueActions extends sfActions
+class idIssueActions extends collabActions
{
/**
* Executes index action
@@ -216,6 +216,17 @@ protected function processForm(sfWebRequest $request, sfForm $form)
if ($form->isValid())
{
$issue = $form->save();
+
+ $this->sendEmail($issue,
+ $this->getPartial('idProject/mail', array('object' => $issue,
+ 'action' => 'edited',
+ 'user' => $this->getUser()->getGuardUser(),
+ 'show' => true,
+ 'body_field' => 'description'
+ )),
+ 'edited'
+ );
+
$this->getUser()->setFlash('notice', 'Issue saved');
$this->redirect('@edit_issue?project_id='.$issue->project_id.'&issue_id='.$issue->id);
}
View
7 plugins/idProjectManagementPlugin/modules/idProject/templates/_mail.php
@@ -1,11 +1,12 @@
+<?php $body_field = isset ($body_field) ? $body_field : 'body';?>
Hi, this is your collab installation mail system.<br/>
-A <?php echo strtolower(get_class($object)) ?> has been <?php echo $action ?>.<br/>
+Log: <?php echo strtolower(get_class($object)) ?> has been <?php echo $action ?>.<br/>
<br/>
<?php echo get_class($object) ?> <?php echo $object->title ?> has been <?php echo $action ?> by <?php echo $user->getUsername() ?> on <?php echo date('Y-m-d') ?>
<br/>
<?php if (isset($show) && $show === true): ?>
-<h3><?php echo $object->title ?></h3>
-<?php echo $object->body ?>
+<h3><?php echo LogMessageGenerator::getLinkForObject($object) ?></h3>
+<?php echo $object->$body_field ?>
<?php endif; ?>
<br/>
See you soon,
View
8 test/functional/fe/idProjectIssueEditTest.php
@@ -71,6 +71,14 @@
'users_list' => array('3')
)), array('methos'=>'post'))->
+ with('mailer')->begin()->
+ checkHeader('Subject', '/Issue .* edited/')->
+ checkHeader('To', '/example3@example.com/')->
+ checkBody('/Issue new ticket up has been edited by puser on/')->
+ checkBody('~http://~')->
+ checkBody('~en/idProject/3/idIssue/show/1~')->
+ end()->
+
followRedirect()->
with('request')->begin()->
View
2 test/functional/fe/idProjectMessageCreateTest.php
@@ -28,7 +28,7 @@
checkHeader('Subject', '/Message .* created/')->
checkHeader('To', '/example3@example.com/')->
checkHeader('To', '/example5@example.com/')->
- checkBody('/A message has been created/')->
+ checkBody('/Log: message has been created/')->
checkBody('/Terzo/')->
checkBody('/body terzo/')->
end()->
View
2 test/functional/fe/idProjectMessageDeleteTest.php
@@ -27,7 +27,7 @@
checkHeader('To', '/example3@example.com/')->
checkHeader('To', '/example5@example.com/')->
checkBody('/Hi, this is your collab installation mail system/')->
- checkBody('/A message has been deleted/')->
+ checkBody('/Log: message has been deleted/')->
checkBody('/has been deleted by puser on/')->
end()->
followRedirect()->
View
2 test/functional/fe/idProjectMessageEditTest.php
@@ -27,7 +27,7 @@
checkHeader('Subject', '/Message .* updated/')->
checkHeader('To', '/example3@example.com/')->
checkHeader('To', '/example5@example.com/')->
- checkBody('/A message has been updated/')->
+ checkBody('/Log: message has been updated/')->
checkBody('/Primo primo/')->
checkBody('/body primo primo/')->
end()->
View
11 test/unit/LogMessageGeneratorTest.php
@@ -5,12 +5,10 @@
initializeDatabase();
$configuration = ProjectConfiguration::getApplicationConfiguration( 'fe', 'unittest', true);
new sfDatabaseManager($configuration);
-
-$t = new lime_test(11, new lime_output_color());
-
-$configuration = ProjectConfiguration::getApplicationConfiguration( 'fe', 'unittest', true);
sfContext::createInstance($configuration);
+$t = new lime_test(12, new lime_output_color());
+
class Project
{
public $name = 'progetto';
@@ -65,7 +63,8 @@ class Message
class MyClass123456789 {}
$link = LogMessageGenerator::getLinkForObject(new MyClass123456789);
-$t->is($link, 'MyClass123456789', 'getLinkForObject ok for generic class class');
+$t->like($link, '/<a href=/', 'getLinkForObject ok for generic class class');
+$t->like($link, '/MyClass123456789<\/a>/', 'getLinkForObject ok for generic class class');
class MyClassToString
{
@@ -76,7 +75,7 @@ public function __toString()
}
$link = LogMessageGenerator::getLinkForObject(new MyClassToString);
-$t->is($link, 'my_class', 'getLinkForObject ok for generic class with to string method');
+$t->like($link, '/<a href=.*my_class<\/a>/', 'getLinkForObject ok for generic class with to string method');
class EventMock extends Doctrine_Event
{

0 comments on commit 9df9fc4

Please sign in to comment.