blob: 3c0493271ef5413a26dc4c5dd9457705c037adfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
namespace Event;
/**
* Notification listener
*
* @package event
* @author Frederic Guillot
*/
class NotificationListener extends Base
{
/**
* Template name
*
* @accesss private
* @var string
*/
private $template = '';
/**
* Set template name
*
* @access public
* @param string $template Template name
*/
public function setTemplate($template)
{
$this->template = $template;
}
/**
* Execute the action
*
* @access public
* @param array $data Event data dictionary
* @return bool True if the action was executed or false when not executed
*/
public function execute(array $data)
{
$values = $this->getTemplateData($data);
$users = $this->notification->getUsersList($values['task']['project_id']);
if ($users) {
$this->notification->sendEmails($this->template, $users, $values);
return true;
}
return false;
}
/**
* Fetch data for the mail template
*
* @access public
* @param array $data Event data
* @return array
*/
public function getTemplateData(array $data)
{
$values = array();
switch ($this->getEventNamespace()) {
case 'task':
$values['task'] = $this->taskFinder->getDetails($data['task_id']);
break;
case 'subtask':
$values['subtask'] = $this->subtask->getById($data['id'], true);
$values['task'] = $this->taskFinder->getDetails($data['task_id']);
break;
case 'file':
$values['file'] = $data;
$values['task'] = $this->taskFinder->getDetails($data['task_id']);
break;
case 'comment':
$values['comment'] = $this->comment->getById($data['id']);
$values['task'] = $this->taskFinder->getDetails($values['comment']['task_id']);
break;
}
return $values;
}
}
|