1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Analytics |
4
|
|
|
* |
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
6
|
|
|
* later. See the LICENSE.md file. |
7
|
|
|
* |
8
|
|
|
* @author Marcel Scherello <[email protected]> |
9
|
|
|
* @copyright 2019-2022 Marcel Scherello |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace OCA\Analytics\Controller; |
13
|
|
|
|
14
|
|
|
use OCA\Analytics\Service\PanoramaService; |
15
|
|
|
use OCP\AppFramework\Controller; |
|
|
|
|
16
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
|
|
|
17
|
|
|
use OCP\DB\Exception; |
|
|
|
|
18
|
|
|
use OCP\IRequest; |
|
|
|
|
19
|
|
|
use OCP\PreConditionNotMetException; |
|
|
|
|
20
|
|
|
use Psr\Log\LoggerInterface; |
|
|
|
|
21
|
|
|
|
22
|
|
|
class PanoramaController extends Controller |
23
|
|
|
{ |
24
|
|
|
private $logger; |
25
|
|
|
private $PanoramaService; |
26
|
|
|
|
27
|
|
|
public function __construct( |
28
|
|
|
$appName, |
29
|
|
|
IRequest $request, |
30
|
|
|
LoggerInterface $logger, |
31
|
|
|
PanoramaService $PanoramaService |
32
|
|
|
) |
33
|
|
|
{ |
34
|
|
|
parent::__construct($appName, $request); |
35
|
|
|
$this->logger = $logger; |
36
|
|
|
$this->PanoramaService = $PanoramaService; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* get all reports |
41
|
|
|
* |
42
|
|
|
* @NoAdminRequired |
43
|
|
|
* @return DataResponse |
44
|
|
|
* @throws Exception |
45
|
|
|
* @throws PreConditionNotMetException |
46
|
|
|
*/ |
47
|
|
|
public function index() |
48
|
|
|
{ |
49
|
|
|
return new DataResponse($this->PanoramaService->index()); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* create new blank report |
54
|
|
|
* |
55
|
|
|
* @NoAdminRequired |
56
|
|
|
* @param int $type |
57
|
|
|
* @param int $parent |
58
|
|
|
* @return DataResponse |
59
|
|
|
* @throws Exception |
60
|
|
|
*/ |
61
|
|
|
public function create(int $type, int $parent) |
62
|
|
|
{ |
63
|
|
|
return new DataResponse($this->PanoramaService->create($type, $parent)); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* get own report details |
69
|
|
|
* |
70
|
|
|
* @NoAdminRequired |
71
|
|
|
* @param int $panoramaId |
72
|
|
|
* @return DataResponse |
73
|
|
|
*/ |
74
|
|
|
public function read(int $panoramaId) |
75
|
|
|
{ |
76
|
|
|
return new DataResponse($this->PanoramaService->read($panoramaId)); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Delete report and all depending objects |
81
|
|
|
* |
82
|
|
|
* @NoAdminRequired |
83
|
|
|
* @param int $panoramaId |
84
|
|
|
* @return DataResponse |
85
|
|
|
*/ |
86
|
|
|
public function delete(int $panoramaId) |
87
|
|
|
{ |
88
|
|
|
if ($this->PanoramaService->isOwn($panoramaId)) { |
89
|
|
|
return new DataResponse($this->PanoramaService->delete($panoramaId)); |
90
|
|
|
} else { |
91
|
|
|
return new DataResponse(false,400); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* get report details |
97
|
|
|
* |
98
|
|
|
* @NoAdminRequired |
99
|
|
|
* @param int $panoramaId |
100
|
|
|
* @param $name |
101
|
|
|
* @param int $type |
102
|
|
|
* @param int $parent |
103
|
|
|
* @param $pages |
104
|
|
|
* @return DataResponse |
105
|
|
|
* @throws Exception |
106
|
|
|
*/ |
107
|
|
|
public function update(int $panoramaId, $name, int $type, int $parent, $pages) |
108
|
|
|
{ |
109
|
|
|
$pages = json_encode($pages); |
110
|
|
|
return new DataResponse($this->PanoramaService->update($panoramaId, $name, $type, $parent, $pages)); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* get own reports which are marked as favorites |
115
|
|
|
* |
116
|
|
|
* @NoAdminRequired |
117
|
|
|
* @return DataResponse |
118
|
|
|
* @throws Exception |
119
|
|
|
*/ |
120
|
|
|
public function getOwnFavoriteReports() |
121
|
|
|
{ |
122
|
|
|
return new DataResponse($this->PanoramaService->getOwnFavoriteReports()); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* set/remove the favorite flag for a report |
127
|
|
|
* |
128
|
|
|
* @NoAdminRequired |
129
|
|
|
* @param int $panoramaId |
130
|
|
|
* @param string $favorite |
131
|
|
|
* @return DataResponse |
132
|
|
|
*/ |
133
|
|
|
public function setFavorite(int $panoramaId, string $favorite) |
134
|
|
|
{ |
135
|
|
|
return new DataResponse($this->PanoramaService->setFavorite($panoramaId, $favorite)); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
} |
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