1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Topic Preview |
5
|
|
|
* |
6
|
|
|
* @copyright (c) 2013 Matt Friedman |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace vse\topicpreview\event; |
12
|
|
|
|
13
|
|
|
use phpbb\config\config; |
|
|
|
|
14
|
|
|
use phpbb\language\language; |
|
|
|
|
15
|
|
|
use phpbb\request\request; |
|
|
|
|
16
|
|
|
use phpbb\template\template; |
|
|
|
|
17
|
|
|
use phpbb\user; |
|
|
|
|
18
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Event listener for UCP related actions |
22
|
|
|
*/ |
23
|
|
|
class ucp_listener implements EventSubscriberInterface |
24
|
|
|
{ |
25
|
|
|
/** @var config */ |
26
|
|
|
protected $config; |
27
|
|
|
|
28
|
|
|
/** @var language */ |
29
|
|
|
protected $language; |
30
|
|
|
|
31
|
|
|
/** @var request */ |
32
|
|
|
protected $request; |
33
|
|
|
|
34
|
|
|
/** @var template */ |
35
|
|
|
protected $template; |
36
|
|
|
|
37
|
|
|
/** @var user */ |
38
|
|
|
protected $user; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Constructor |
42
|
|
|
* |
43
|
|
|
* @param config $config Config object |
44
|
|
|
* @param language $language Language object |
45
|
|
|
* @param request $request Request object |
46
|
|
|
* @param template $template Template object |
47
|
|
|
* @param user $user User object |
48
|
|
|
*/ |
49
|
10 |
|
public function __construct(config $config, language $language, request $request, template $template, user $user) |
50
|
|
|
{ |
51
|
10 |
|
$this->config = $config; |
52
|
10 |
|
$this->language = $language; |
53
|
10 |
|
$this->request = $request; |
54
|
10 |
|
$this->template = $template; |
55
|
10 |
|
$this->user = $user; |
56
|
10 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Assign functions defined in this class to event listeners in the core |
60
|
|
|
* |
61
|
|
|
* @return array |
62
|
|
|
*/ |
63
|
1 |
|
public static function getSubscribedEvents() |
64
|
|
|
{ |
65
|
|
|
return array( |
66
|
1 |
|
'core.ucp_prefs_view_data' => 'ucp_prefs_get_data', |
67
|
1 |
|
'core.ucp_prefs_view_update_data' => 'ucp_prefs_set_data', |
68
|
1 |
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get user's Topic Preview option and display it in UCP Prefs View page |
73
|
|
|
* |
74
|
|
|
* @param \phpbb\event\data $event The event object |
|
|
|
|
75
|
|
|
*/ |
76
|
6 |
|
public function ucp_prefs_get_data($event) |
77
|
|
|
{ |
78
|
|
|
// Request the user option vars and add them to the data array |
79
|
6 |
|
$event['data'] = array_merge($event['data'], array( |
80
|
6 |
|
'topic_preview' => $this->request->variable('topic_preview', (int) $this->user->data['user_topic_preview']), |
81
|
6 |
|
)); |
82
|
|
|
|
83
|
|
|
// Output the data vars to the template (except on form submit) |
84
|
6 |
|
if (!$event['submit']) |
85
|
6 |
|
{ |
86
|
3 |
|
$this->language->add_lang('topic_preview_ucp', 'vse/topicpreview'); |
87
|
3 |
|
$this->template->assign_vars(array( |
88
|
3 |
|
'S_TOPIC_PREVIEW' => $this->config['topic_preview_limit'], |
89
|
3 |
|
'S_DISPLAY_TOPIC_PREVIEW' => $event['data']['topic_preview'], |
90
|
3 |
|
)); |
91
|
3 |
|
} |
92
|
6 |
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Add user's Topic Preview option state into the sql_array |
96
|
|
|
* |
97
|
|
|
* @param \phpbb\event\data $event The event object |
98
|
|
|
*/ |
99
|
3 |
|
public function ucp_prefs_set_data($event) |
100
|
|
|
{ |
101
|
3 |
|
$event['sql_ary'] = array_merge($event['sql_ary'], array( |
102
|
3 |
|
'user_topic_preview' => $event['data']['topic_preview'], |
103
|
3 |
|
)); |
104
|
3 |
|
} |
105
|
|
|
} |
106
|
|
|
|
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