|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* ideas. An extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2025 |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace phpbb\ideas\notification\type; |
|
12
|
|
|
|
|
13
|
|
|
use phpbb\ideas\ext; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Ideas status change notification class. |
|
17
|
|
|
*/ |
|
18
|
|
|
class status extends \phpbb\notification\type\base |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
/** @var \phpbb\controller\helper */ |
|
21
|
|
|
protected $helper; |
|
22
|
|
|
|
|
23
|
|
|
/** @var \phpbb\ideas\factory\idea */ |
|
24
|
|
|
protected $idea; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Set the controller helper |
|
28
|
|
|
* |
|
29
|
|
|
* @param \phpbb\controller\helper $helper |
|
30
|
|
|
* |
|
31
|
|
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
|
|
public function set_controller_helper(\phpbb\controller\helper $helper) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->helper = $helper; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Set the Idea helper |
|
40
|
|
|
* |
|
41
|
|
|
* @param \phpbb\ideas\factory\idea $idea |
|
42
|
|
|
* |
|
43
|
|
|
* @return void |
|
44
|
|
|
*/ |
|
45
|
|
|
public function set_idea_factory(\phpbb\ideas\factory\idea $idea) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->idea = $idea; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get notification type name |
|
52
|
|
|
* |
|
53
|
|
|
* @return string |
|
54
|
|
|
*/ |
|
55
|
|
|
public function get_type() |
|
56
|
|
|
{ |
|
57
|
|
|
return 'phpbb.ideas.notification.type.status'; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Notification option data (for outputting to the user) |
|
62
|
|
|
* |
|
63
|
|
|
* @var bool|array False if the service should use its default data |
|
64
|
|
|
* Array of data (including keys 'id', 'lang', and 'group') |
|
65
|
|
|
*/ |
|
66
|
|
|
public static $notification_option = [ |
|
67
|
|
|
'lang' => 'NOTIFICATION_TYPE_IDEAS', |
|
68
|
|
|
]; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Is this type available to the current user (defines whether it will be shown in the UCP Edit notification options) |
|
72
|
|
|
* |
|
73
|
|
|
* @return bool True/False whether this is available to the user |
|
74
|
|
|
*/ |
|
75
|
|
|
public function is_available() |
|
76
|
|
|
{ |
|
77
|
|
|
return true; //(bool) $this->config['ideas_forum_id']; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Get the id of the notification |
|
82
|
|
|
* |
|
83
|
|
|
* @param array $type_data The type-specific data |
|
84
|
|
|
* |
|
85
|
|
|
* @return int Id of the notification |
|
86
|
|
|
*/ |
|
87
|
|
|
public static function get_item_id($type_data) |
|
88
|
|
|
{ |
|
89
|
|
|
return $type_data['idea_id']; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get the id of the parent |
|
94
|
|
|
* |
|
95
|
|
|
* @param array $type_data The type-specific data |
|
96
|
|
|
* |
|
97
|
|
|
* @return int Id of the parent |
|
98
|
|
|
*/ |
|
99
|
|
|
public static function get_item_parent_id($type_data) |
|
100
|
|
|
{ |
|
101
|
|
|
// No parent |
|
102
|
|
|
return 0; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Find the users who want to receive notifications |
|
107
|
|
|
* |
|
108
|
|
|
* @param array $type_data The type-specific data |
|
109
|
|
|
* @param array $options Options for finding users for notification |
|
110
|
|
|
* ignore_users => array of users and user types that should not receive notifications from this type because they've already been notified |
|
111
|
|
|
* e.g.: [2 => [''], 3 => ['', 'email'], ...] |
|
112
|
|
|
* |
|
113
|
|
|
* @return array |
|
114
|
|
|
*/ |
|
115
|
|
|
public function find_users_for_notification($type_data, $options = []) |
|
116
|
|
|
{ |
|
117
|
|
|
$users = []; |
|
118
|
|
|
|
|
119
|
|
|
$idea = $this->idea->get_idea($type_data['idea_id']); |
|
120
|
|
|
|
|
121
|
|
|
if ($idea !== false) |
|
122
|
|
|
{ |
|
123
|
|
|
$users[$idea['idea_author']] = $this->notification_manager->get_default_methods(); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
return $users; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Users needed to query before this notification can be displayed |
|
131
|
|
|
* |
|
132
|
|
|
* @return array Array of user_ids |
|
133
|
|
|
*/ |
|
134
|
|
|
public function users_to_query() |
|
135
|
|
|
{ |
|
136
|
|
|
return []; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Get the HTML-formatted title of this notification |
|
141
|
|
|
* |
|
142
|
|
|
* @return string |
|
143
|
|
|
*/ |
|
144
|
|
|
public function get_title() |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->language->lang('PHPBB_IDEAS_NOTIFICATION', $this->get_data('idea_title')); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Get the HTML-formatted reference of the notification |
|
151
|
|
|
* |
|
152
|
|
|
* @return string |
|
153
|
|
|
*/ |
|
154
|
|
|
public function get_reference() |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->language->lang(ext::status_name($this->get_data('status'))); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Get the url to this item |
|
161
|
|
|
* |
|
162
|
|
|
* @return string URL |
|
163
|
|
|
*/ |
|
164
|
|
|
public function get_url() |
|
165
|
|
|
{ |
|
166
|
|
|
$params = ['idea_id' => $this->get_data('idea_id')]; |
|
167
|
|
|
|
|
168
|
|
|
return $this->helper->route('phpbb_ideas_idea_controller', $params); |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* Get email template |
|
173
|
|
|
* |
|
174
|
|
|
* @return string|bool |
|
175
|
|
|
*/ |
|
176
|
|
|
public function get_email_template() |
|
177
|
|
|
{ |
|
178
|
|
|
return false; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Get email template variables |
|
183
|
|
|
* |
|
184
|
|
|
* @return array |
|
185
|
|
|
*/ |
|
186
|
|
|
public function get_email_template_variables() |
|
187
|
|
|
{ |
|
188
|
|
|
return []; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
public function pre_create_insert_array($type_data, $notify_users) |
|
192
|
|
|
{ |
|
193
|
|
|
$pre_create_data = []; |
|
194
|
|
|
|
|
195
|
|
|
$idea = $this->idea->get_idea($type_data['idea_id']); |
|
196
|
|
|
if ($idea !== false) |
|
197
|
|
|
{ |
|
198
|
|
|
$pre_create_data['idea_title'] = $idea['idea_title']; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
return $pre_create_data; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* Function for preparing the data for insertion in an SQL query |
|
206
|
|
|
* (The service handles insertion) |
|
207
|
|
|
* |
|
208
|
|
|
* @param array $type_data The type-specific data |
|
209
|
|
|
* @param array $pre_create_data Data from pre_create_insert_array() |
|
210
|
|
|
*/ |
|
211
|
|
|
public function create_insert_array($type_data, $pre_create_data = []) |
|
212
|
|
|
{ |
|
213
|
|
|
$this->set_data('idea_id', $type_data['idea_id']); |
|
214
|
|
|
$this->set_data('status', $type_data['status']); |
|
215
|
|
|
$this->set_data('idea_title', $pre_create_data['idea_title']); |
|
216
|
|
|
|
|
217
|
|
|
parent::create_insert_array($type_data, $pre_create_data); |
|
218
|
|
|
} |
|
219
|
|
|
} |
|
220
|
|
|
|
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