|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* Collapsible Categories extension for the phpBB Forum Software package. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2015 phpBB Limited <https://www.phpbb.com> |
|
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace phpbb\collapsiblecategories\controller; |
|
12
|
|
|
|
|
13
|
|
|
use phpbb\collapsiblecategories\operator\operator; |
|
14
|
|
|
use phpbb\request\request; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class main_controller implements main_interface |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var operator */ |
|
19
|
|
|
protected $operator; |
|
20
|
|
|
|
|
21
|
|
|
/** @var request */ |
|
22
|
|
|
protected $request; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Constructor |
|
26
|
|
|
* |
|
27
|
|
|
* @param operator $operator Operator object |
|
28
|
|
|
* @param request $request Request object |
|
29
|
|
|
*/ |
|
30
|
11 |
|
public function __construct(operator $operator, request $request) |
|
31
|
|
|
{ |
|
32
|
11 |
|
$this->operator = $operator; |
|
33
|
11 |
|
$this->request = $request; |
|
34
|
11 |
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* {@inheritdoc} |
|
38
|
|
|
*/ |
|
39
|
11 |
|
public function handle($forum_id) |
|
40
|
|
|
{ |
|
41
|
|
|
// Throw an exception for non-AJAX requests or invalid link requests |
|
42
|
11 |
|
if (!$this->request->is_ajax() || !$this->is_valid($forum_id) || !check_link_hash($this->request->variable('hash', ''), 'collapsible_' . $forum_id)) |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
9 |
|
throw new \phpbb\exception\http_exception(403, 'NO_AUTH_OPERATION'); |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
// Update the user's collapsed category data for the given forum |
|
48
|
2 |
|
$response = $this->operator->set_user_categories($forum_id); |
|
49
|
|
|
|
|
50
|
|
|
// Return a JSON response |
|
51
|
2 |
|
return new \Symfony\Component\HttpFoundation\JsonResponse(array( |
|
|
|
|
|
|
52
|
2 |
|
'success' => $response, |
|
53
|
|
|
)); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Validate values containing only letters, numbers and underscores |
|
58
|
|
|
* |
|
59
|
|
|
* @param string $value Value to test |
|
60
|
|
|
* |
|
61
|
|
|
* @return bool true if valid, false if invalid |
|
62
|
|
|
*/ |
|
63
|
10 |
|
protected function is_valid($value) |
|
64
|
|
|
{ |
|
65
|
10 |
|
return !empty($value) && preg_match('/^\w+$/', $value); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
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