1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Analytics |
4
|
|
|
* |
5
|
|
|
* SPDX-FileCopyrightText: 2019-2022 Marcel Scherello |
6
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace OCA\Analytics\Controller; |
10
|
|
|
|
11
|
|
|
use OCA\Analytics\Service\PanoramaService; |
12
|
|
|
use OCA\Analytics\Service\ShareService; |
13
|
|
|
use OCA\Analytics\Service\ReportService; |
14
|
|
|
use OCP\AppFramework\Controller; |
|
|
|
|
15
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
|
|
|
16
|
|
|
use OCP\DB\Exception; |
|
|
|
|
17
|
|
|
use OCP\IRequest; |
|
|
|
|
18
|
|
|
use Psr\Log\LoggerInterface; |
|
|
|
|
19
|
|
|
|
20
|
|
|
class ShareController extends Controller { |
21
|
|
|
const SHARE_TYPE_USER = 0; |
22
|
|
|
const SHARE_TYPE_GROUP = 1; |
23
|
|
|
const SHARE_TYPE_USERGROUP = 2; |
24
|
|
|
const SHARE_TYPE_LINK = 3; |
25
|
|
|
const SHARE_TYPE_ROOM = 10; |
26
|
|
|
|
27
|
|
|
/** @var LoggerInterface */ |
28
|
|
|
private $logger; |
29
|
|
|
private $ShareService; |
30
|
|
|
private $ReportService; |
31
|
|
|
private $PanoramaService; |
32
|
|
|
|
33
|
|
|
public function __construct( |
34
|
|
|
$appName, |
35
|
|
|
IRequest $request, |
36
|
|
|
LoggerInterface $logger, |
37
|
|
|
ShareService $ShareService, |
38
|
|
|
ReportService $ReportService, |
39
|
|
|
PanoramaService $PanoramaService |
40
|
|
|
) { |
41
|
|
|
parent::__construct($appName, $request); |
42
|
|
|
$this->logger = $logger; |
43
|
|
|
$this->ShareService = $ShareService; |
44
|
|
|
$this->ReportService = $ReportService; |
45
|
|
|
$this->PanoramaService = $PanoramaService; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* create a new share |
50
|
|
|
* |
51
|
|
|
* @NoAdminRequired |
52
|
|
|
* @param $item_type |
53
|
|
|
* @param $item_source |
54
|
|
|
* @param $type |
55
|
|
|
* @param $user |
56
|
|
|
* @return DataResponse |
57
|
|
|
* @throws Exception |
58
|
|
|
*/ |
59
|
|
|
public function create($item_type, $item_source, $type, $user) { |
60
|
|
|
if (($item_type === ShareService::SHARE_ITEM_TYPE_REPORT && $this->ReportService->isOwn($item_source)) |
61
|
|
|
|| ($item_type === ShareService::SHARE_ITEM_TYPE_PANORAMA && $this->PanoramaService->isOwn($item_source))) { |
62
|
|
|
return new DataResponse($this->ShareService->create($item_type, $item_source, $type, $user)); |
63
|
|
|
} else { |
64
|
|
|
return new DataResponse(false); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* get all shares for a report |
70
|
|
|
* |
71
|
|
|
* @NoAdminRequired |
72
|
|
|
* @param $item_source |
73
|
|
|
* @return DataResponse |
74
|
|
|
* @throws Exception |
75
|
|
|
*/ |
76
|
|
|
public function readReport($item_source) { |
77
|
|
|
if ($this->ReportService->isOwn($item_source)) { |
78
|
|
|
return new DataResponse($this->ShareService->read(ShareService::SHARE_ITEM_TYPE_REPORT, $item_source)); |
79
|
|
|
} else { |
80
|
|
|
return new DataResponse(false); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* get all shares for a panorama |
86
|
|
|
* |
87
|
|
|
* @NoAdminRequired |
88
|
|
|
* @param $item_source |
89
|
|
|
* @return DataResponse |
90
|
|
|
* @throws Exception |
91
|
|
|
*/ |
92
|
|
|
public function readPanorama($item_source) { |
93
|
|
|
if ($this->PanoramaService->isOwn($item_source)) { |
94
|
|
|
return new DataResponse($this->ShareService->read(ShareService::SHARE_ITEM_TYPE_PANORAMA, $item_source)); |
95
|
|
|
} else { |
96
|
|
|
return new DataResponse(false); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* update/set share password |
102
|
|
|
* |
103
|
|
|
* @NoAdminRequired |
104
|
|
|
* @param $shareId |
105
|
|
|
* @param null $password |
|
|
|
|
106
|
|
|
* @param null $canEdit |
|
|
|
|
107
|
|
|
* @param null $domain |
|
|
|
|
108
|
|
|
* @return DataResponse |
109
|
|
|
*/ |
110
|
|
|
public function update($shareId, $password = null, $canEdit = null, $domain = null) { |
111
|
|
|
return new DataResponse($this->ShareService->update($shareId, $password, $canEdit, $domain)); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* delete a share |
116
|
|
|
* |
117
|
|
|
* @NoAdminRequired |
118
|
|
|
* @param $shareId |
119
|
|
|
* @return DataResponse |
120
|
|
|
*/ |
121
|
|
|
public function delete($shareId) { |
122
|
|
|
return new DataResponse($this->ShareService->delete($shareId)); |
123
|
|
|
} |
124
|
|
|
} |
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