Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 9df9fc4b6e0e5a1b1a9a035b3649a0787db2054c 1 parent f5fa47b
authored September 01, 2010
BIN  data/phpcollab_unit_test.db
Binary file not shown
12  plugins/idProjectManagementPlugin/lib/generator/LogMessageGenerator.php
@@ -19,22 +19,22 @@ public static function getLinkForObject($object)
19 19
     switch ($object_class)
20 20
     {
21 21
       case 'project':
22  
-        return link_to($object->name, '@show_project?id='.$object->id);
  22
+        return link_to($object->name, '@show_project?id='.$object->id, array('absolute' => true));
23 23
         break;
24 24
       case 'milestone':
25  
-        return link_to($object->title, '@show_milestone?project_id='.$object->project_id.'&milestone_id='.$object->id);
  25
+        return link_to($object->title, '@show_milestone?project_id='.$object->project_id.'&milestone_id='.$object->id, array('absolute' => true));
26 26
         break;
27 27
       case 'issue':
28  
-        return link_to('#'.$object->id.' '.$object->title, '@show_issue?project_id='.$object->project_id.'&issue_id='.$object->id);
  28
+        return link_to('#'.$object->id.' '.$object->title, '@show_issue?project_id='.$object->project_id.'&issue_id='.$object->id, array('absolute' => true));
29 29
         break;
30 30
       case 'logtime':
31  
-        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);
  31
+        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));
32 32
         break;
33 33
       case 'message':
34  
-        return link_to($object->title, '@show_message?project_id='.$object->project_id.'&message_id='.$object->id);
  34
+        return link_to($object->title, '@show_message?project_id='.$object->project_id.'&message_id='.$object->id, array('absolute' => true));
35 35
         break;
36 36
       default:
37  
-        return (method_exists($object, '__toString')) ? (string)$object : get_class($object);
  37
+        return link_to((method_exists($object, '__toString')) ? (string)$object : get_class($object), '@homepage', array('absolute' => true));
38 38
     }
39 39
   }
40 40
 
5  plugins/idProjectManagementPlugin/lib/model/doctrine/PluginIssue.class.php
@@ -74,4 +74,9 @@ public function isClosed()
74 74
     return (bool) ($this->status == 'closed');
75 75
   }
76 76
 
  77
+  public function getRelatedUsers()
  78
+  {
  79
+    return $this->getUsers();
  80
+  }
  81
+
77 82
 }
13  plugins/idProjectManagementPlugin/modules/idIssue/actions/actions.class.php
@@ -19,7 +19,7 @@
19 19
  * @subpackage idProjectManagementPlugin Modules
20 20
  * @author     Filippo (p16) De Santis <fd@ideato.it>
21 21
  */
22  
-class idIssueActions extends sfActions
  22
+class idIssueActions extends collabActions
23 23
 {
24 24
   /**
25 25
    * Executes index action
@@ -216,6 +216,17 @@ protected function processForm(sfWebRequest $request, sfForm $form)
216 216
     if ($form->isValid())
217 217
     {
218 218
       $issue = $form->save();
  219
+
  220
+      $this->sendEmail($issue,
  221
+                       $this->getPartial('idProject/mail', array('object' => $issue,
  222
+                                                       'action' => 'edited',
  223
+                                                       'user' =>  $this->getUser()->getGuardUser(),
  224
+                                                       'show' => true,
  225
+                                                       'body_field' => 'description'
  226
+                           )),
  227
+                        'edited'
  228
+                      );
  229
+
219 230
       $this->getUser()->setFlash('notice', 'Issue saved');
220 231
       $this->redirect('@edit_issue?project_id='.$issue->project_id.'&issue_id='.$issue->id);
221 232
     }
7  plugins/idProjectManagementPlugin/modules/idProject/templates/_mail.php
... ...
@@ -1,11 +1,12 @@
  1
+<?php $body_field = isset ($body_field) ? $body_field : 'body';?>
1 2
 Hi, this is your collab installation mail system.<br/>
2  
-A <?php echo strtolower(get_class($object)) ?> has been <?php echo $action ?>.<br/>
  3
+Log: <?php echo strtolower(get_class($object)) ?> has been <?php echo $action ?>.<br/>
3 4
 <br/>
4 5
 <?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') ?>
5 6
 <br/>
6 7
 <?php if (isset($show) && $show === true): ?>
7  
-<h3><?php echo $object->title ?></h3>
8  
-<?php echo $object->body ?>
  8
+<h3><?php echo LogMessageGenerator::getLinkForObject($object) ?></h3>
  9
+<?php echo $object->$body_field ?>
9 10
 <?php endif; ?>
10 11
 <br/>
11 12
 See you soon,
8  test/functional/fe/idProjectIssueEditTest.php
@@ -71,6 +71,14 @@
71 71
     'users_list'      => array('3')
72 72
   )), array('methos'=>'post'))->
73 73
 
  74
+  with('mailer')->begin()->
  75
+    checkHeader('Subject', '/Issue .* edited/')->
  76
+    checkHeader('To', '/example3@example.com/')->
  77
+    checkBody('/Issue new ticket up has been edited by puser on/')->
  78
+    checkBody('~http://~')->
  79
+    checkBody('~en/idProject/3/idIssue/show/1~')->
  80
+  end()->
  81
+
74 82
   followRedirect()->
75 83
 
76 84
   with('request')->begin()->
2  test/functional/fe/idProjectMessageCreateTest.php
@@ -28,7 +28,7 @@
28 28
     checkHeader('Subject', '/Message .* created/')->
29 29
     checkHeader('To', '/example3@example.com/')->
30 30
     checkHeader('To', '/example5@example.com/')->
31  
-    checkBody('/A message has been created/')->
  31
+    checkBody('/Log: message has been created/')->
32 32
     checkBody('/Terzo/')->
33 33
     checkBody('/body terzo/')->
34 34
   end()->
2  test/functional/fe/idProjectMessageDeleteTest.php
@@ -27,7 +27,7 @@
27 27
     checkHeader('To', '/example3@example.com/')->
28 28
     checkHeader('To', '/example5@example.com/')->
29 29
     checkBody('/Hi, this is your collab installation mail system/')->
30  
-    checkBody('/A message has been deleted/')->
  30
+    checkBody('/Log: message has been deleted/')->
31 31
     checkBody('/has been deleted by puser on/')->
32 32
   end()->
33 33
   followRedirect()->
2  test/functional/fe/idProjectMessageEditTest.php
@@ -27,7 +27,7 @@
27 27
     checkHeader('Subject', '/Message .* updated/')->
28 28
     checkHeader('To', '/example3@example.com/')->
29 29
     checkHeader('To', '/example5@example.com/')->
30  
-    checkBody('/A message has been updated/')->
  30
+    checkBody('/Log: message has been updated/')->
31 31
     checkBody('/Primo primo/')->
32 32
     checkBody('/body primo primo/')->
33 33
   end()->
11  test/unit/LogMessageGeneratorTest.php
@@ -5,12 +5,10 @@
5 5
 initializeDatabase();
6 6
 $configuration = ProjectConfiguration::getApplicationConfiguration( 'fe', 'unittest', true);
7 7
 new sfDatabaseManager($configuration);
8  
-
9  
-$t = new lime_test(11, new lime_output_color());
10  
-
11  
-$configuration = ProjectConfiguration::getApplicationConfiguration( 'fe', 'unittest', true);
12 8
 sfContext::createInstance($configuration);
13 9
 
  10
+$t = new lime_test(12, new lime_output_color());
  11
+
14 12
 class Project
15 13
 {
16 14
   public $name = 'progetto';
@@ -65,7 +63,8 @@ class Message
65 63
 class MyClass123456789 {}
66 64
 
67 65
 $link = LogMessageGenerator::getLinkForObject(new MyClass123456789);
68  
-$t->is($link, 'MyClass123456789', 'getLinkForObject ok for generic class class');
  66
+$t->like($link, '/<a href=/', 'getLinkForObject ok for generic class class');
  67
+$t->like($link, '/MyClass123456789<\/a>/', 'getLinkForObject ok for generic class class');
69 68
 
70 69
 class MyClassToString
71 70
 {
@@ -76,7 +75,7 @@ public function __toString()
76 75
 }
77 76
 
78 77
 $link = LogMessageGenerator::getLinkForObject(new MyClassToString);
79  
-$t->is($link, 'my_class', 'getLinkForObject ok for generic class with to string method');
  78
+$t->like($link, '/<a href=.*my_class<\/a>/', 'getLinkForObject ok for generic class with to string method');
80 79
 
81 80
 class EventMock extends Doctrine_Event
82 81
 {

0 notes on commit 9df9fc4

Please sign in to comment.
Something went wrong with that request. Please try again.