blob: aeeee4cd6e444b6ccf1f0c9ee884c1fdbf87099e (
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
|
<?php
namespace Kanboard\Model;
use Kanboard\Core\Base;
/**
* Project Notification
*
* @package Kanboard\Model
* @author Frederic Guillot
*/
class ProjectNotificationModel extends Base
{
/**
* Send notifications
*
* @access public
* @param integer $project_id
* @param string $event_name
* @param array $event_data
*/
public function sendNotifications($project_id, $event_name, array $event_data)
{
$project = $this->projectModel->getById($project_id);
$types = array_merge(
$this->projectNotificationTypeModel->getHiddenTypes(),
$this->projectNotificationTypeModel->getSelectedTypes($project_id)
);
foreach ($types as $type) {
$this->projectNotificationTypeModel->getType($type)->notifyProject($project, $event_name, $event_data);
}
}
/**
* Save settings for the given project
*
* @access public
* @param integer $project_id
* @param array $values
*/
public function saveSettings($project_id, array $values)
{
$this->db->startTransaction();
$types = empty($values['notification_types']) ? array() : array_keys($values['notification_types']);
$this->projectNotificationTypeModel->saveSelectedTypes($project_id, $types);
$this->db->closeTransaction();
}
/**
* Read user settings to display the form
*
* @access public
* @param integer $project_id
* @return array
*/
public function readSettings($project_id)
{
return array(
'notification_types' => $this->projectNotificationTypeModel->getSelectedTypes($project_id),
);
}
}
|