blob: 803d4f184ad06273c1af1d01d01d3cb3924aac28 (
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
<?php
namespace Kanboard\Model;
use Kanboard\Core\Base;
use Kanboard\EventBuilder\CommentEventBuilder;
use Kanboard\EventBuilder\EventIteratorBuilder;
use Kanboard\EventBuilder\SubtaskEventBuilder;
use Kanboard\EventBuilder\TaskEventBuilder;
use Kanboard\EventBuilder\TaskFileEventBuilder;
use Kanboard\EventBuilder\TaskLinkEventBuilder;
/**
* Notification Model
*
* @package Kanboard\Model
* @author Frederic Guillot
*/
class NotificationModel extends Base
{
/**
* Get the event title with author
*
* @access public
* @param string $eventAuthor
* @param string $eventName
* @param array $eventData
* @return string
*/
public function getTitleWithAuthor($eventAuthor, $eventName, array $eventData)
{
foreach ($this->getIteratorBuilder() as $builder) {
$title = $builder->buildTitleWithAuthor($eventAuthor, $eventName, $eventData);
if ($title !== '') {
return $title;
}
}
return e('Notification');
}
/**
* Get the event title without author
*
* @access public
* @param string $eventName
* @param array $eventData
* @return string
*/
public function getTitleWithoutAuthor($eventName, array $eventData)
{
foreach ($this->getIteratorBuilder() as $builder) {
$title = $builder->buildTitleWithoutAuthor($eventName, $eventData);
if ($title !== '') {
return $title;
}
}
return e('Notification');
}
/**
* Get task id from event
*
* @access public
* @param string $eventName
* @param array $eventData
* @return integer
*/
public function getTaskIdFromEvent($eventName, array $eventData)
{
if ($eventName === TaskModel::EVENT_OVERDUE) {
return $eventData['tasks'][0]['id'];
}
return isset($eventData['task']['id']) ? $eventData['task']['id'] : 0;
}
/**
* Get iterator builder
*
* @access protected
* @return EventIteratorBuilder
*/
protected function getIteratorBuilder()
{
$iterator = new EventIteratorBuilder();
$iterator
->withBuilder(TaskEventBuilder::getInstance($this->container))
->withBuilder(CommentEventBuilder::getInstance($this->container))
->withBuilder(SubtaskEventBuilder::getInstance($this->container))
->withBuilder(TaskFileEventBuilder::getInstance($this->container))
->withBuilder(TaskLinkEventBuilder::getInstance($this->container))
;
return $iterator;
}
}
|