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