|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Ideas extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com> |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace phpbb\ideas\notification\type; |
|
12
|
|
|
|
|
13
|
|
|
use phpbb\config\config; |
|
14
|
|
|
use phpbb\controller\helper; |
|
15
|
|
|
use phpbb\ideas\ext; |
|
16
|
|
|
use phpbb\ideas\factory\idea; |
|
17
|
|
|
use phpbb\user_loader; |
|
18
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Ideas status change notification class. |
|
22
|
|
|
*/ |
|
23
|
|
|
class status extends \phpbb\notification\type\base |
|
|
|
|
|
|
24
|
|
|
{ |
|
25
|
|
|
/** @var config */ |
|
26
|
|
|
protected $config; |
|
27
|
|
|
|
|
28
|
|
|
/** @var helper */ |
|
29
|
|
|
protected $helper; |
|
30
|
|
|
|
|
31
|
|
|
/** @var idea */ |
|
32
|
|
|
protected $idea; |
|
33
|
|
|
|
|
34
|
|
|
/** @var user_loader */ |
|
35
|
|
|
protected $user_loader; |
|
36
|
|
|
|
|
37
|
|
|
/** @var int */ |
|
38
|
|
|
protected $ideas_forum_id; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Set additional services and properties |
|
42
|
|
|
* |
|
43
|
|
|
* @param config $config |
|
44
|
|
|
* @param helper $helper |
|
45
|
|
|
* @param idea $idea |
|
46
|
|
|
* @param user_loader $user_loader |
|
47
|
|
|
* @return void |
|
48
|
|
|
*/ |
|
49
|
|
|
public function set_additional_services(config $config, helper $helper, idea $idea, user_loader $user_loader) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->helper = $helper; |
|
52
|
|
|
$this->idea = $idea; |
|
53
|
|
|
$this->user_loader = $user_loader; |
|
54
|
|
|
$this->ideas_forum_id = (int) $config['ideas_forum_id']; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Email template to use to send notifications |
|
59
|
|
|
* |
|
60
|
|
|
* @var string |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $email_template = '@phpbb_ideas/status_notification'; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Language key used to output the text |
|
66
|
|
|
* |
|
67
|
|
|
* @var string |
|
68
|
|
|
*/ |
|
69
|
|
|
protected $language_key = 'IDEA_STATUS_CHANGE'; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* {@inheritDoc} |
|
73
|
|
|
*/ |
|
74
|
|
|
public static $notification_option = [ |
|
75
|
|
|
'lang' => 'NOTIFICATION_TYPE_IDEAS', |
|
76
|
|
|
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS', |
|
77
|
|
|
]; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* {@inheritDoc} |
|
81
|
|
|
*/ |
|
82
|
|
|
public function get_type() |
|
83
|
|
|
{ |
|
84
|
|
|
return 'phpbb.ideas.notification.type.status'; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* {@inheritDoc} |
|
89
|
|
|
*/ |
|
90
|
|
|
public static function get_item_id($type_data) |
|
91
|
|
|
{ |
|
92
|
|
|
return (int) $type_data['idea_id']; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* {@inheritDoc} |
|
97
|
|
|
*/ |
|
98
|
|
|
public static function get_item_parent_id($type_data) |
|
99
|
|
|
{ |
|
100
|
|
|
return 0; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* {@inheritDoc} |
|
105
|
|
|
*/ |
|
106
|
|
|
public function is_available() |
|
107
|
|
|
{ |
|
108
|
|
|
return (bool) $this->auth->acl_get('f_read', $this->ideas_forum_id); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* {@inheritDoc} |
|
113
|
|
|
*/ |
|
114
|
|
|
public function find_users_for_notification($type_data, $options = []) |
|
115
|
|
|
{ |
|
116
|
|
|
$options = array_merge([ |
|
117
|
|
|
'ignore_users' => [], |
|
118
|
|
|
], $options); |
|
119
|
|
|
|
|
120
|
|
|
$idea = $this->idea->get_idea($type_data['idea_id']); |
|
121
|
|
|
|
|
122
|
|
|
$users = $idea ? [$idea['idea_author']] : []; |
|
123
|
|
|
|
|
124
|
|
|
return $this->get_authorised_recipients($users, $this->ideas_forum_id, $options); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* {@inheritDoc} |
|
129
|
|
|
*/ |
|
130
|
|
|
public function users_to_query() |
|
131
|
|
|
{ |
|
132
|
|
|
return [$this->get_data('idea_author')]; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* {@inheritDoc} |
|
137
|
|
|
*/ |
|
138
|
|
|
public function get_title() |
|
139
|
|
|
{ |
|
140
|
|
|
if (!$this->language->is_set($this->language_key)) |
|
141
|
|
|
{ |
|
142
|
|
|
$this->language->add_lang('common', 'phpbb/ideas'); |
|
143
|
|
|
} |
|
144
|
|
|
return $this->language->lang($this->language_key, $this->get_data('idea_title')); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* {@inheritDoc} |
|
149
|
|
|
*/ |
|
150
|
|
|
public function get_reference() |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->language->lang(ext::status_name($this->get_data('status'))); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* {@inheritDoc} |
|
157
|
|
|
*/ |
|
158
|
|
|
public function get_url($reference_type = UrlGeneratorInterface::ABSOLUTE_PATH) |
|
159
|
|
|
{ |
|
160
|
|
|
$params = ['idea_id' => $this->get_data('idea_id')]; |
|
161
|
|
|
|
|
162
|
|
|
return $this->helper->route('phpbb_ideas_idea_controller', $params, true, false, $reference_type); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* {@inheritDoc} |
|
167
|
|
|
*/ |
|
168
|
|
|
public function get_avatar() |
|
169
|
|
|
{ |
|
170
|
|
|
return $this->user_loader->get_avatar($this->get_data('idea_author'), false, true); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* {@inheritDoc} |
|
175
|
|
|
*/ |
|
176
|
|
|
public function get_email_template() |
|
177
|
|
|
{ |
|
178
|
|
|
return $this->email_template; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* {@inheritDoc} |
|
183
|
|
|
*/ |
|
184
|
|
|
public function get_email_template_variables() |
|
185
|
|
|
{ |
|
186
|
|
|
return [ |
|
187
|
|
|
'IDEA_TITLE' => html_entity_decode(censor_text($this->get_data('idea_title')), ENT_COMPAT), |
|
|
|
|
|
|
188
|
|
|
'STATUS' => html_entity_decode($this->language->lang(ext::status_name($this->get_data('status'))), ENT_COMPAT), |
|
189
|
|
|
'U_VIEW_IDEA' => $this->get_url(UrlGeneratorInterface::ABSOLUTE_URL), |
|
190
|
|
|
]; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* {@inheritDoc} |
|
195
|
|
|
*/ |
|
196
|
|
|
public function create_insert_array($type_data, $pre_create_data = []) |
|
197
|
|
|
{ |
|
198
|
|
|
$idea = $this->idea->get_idea($type_data['idea_id']); |
|
199
|
|
|
|
|
200
|
|
|
$this->set_data('idea_id', $type_data['idea_id']); |
|
201
|
|
|
$this->set_data('status', $type_data['status']); |
|
202
|
|
|
$this->set_data('idea_title', $idea['idea_title']); |
|
203
|
|
|
$this->set_data('idea_author', $idea['idea_author']); |
|
204
|
|
|
|
|
205
|
|
|
parent::create_insert_array($type_data, $pre_create_data); |
|
206
|
|
|
} |
|
207
|
|
|
} |
|
208
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths