Passed
Push — master ( da7451...5b8a4a )
by Marcel
07:08
created

ShareController::generateToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
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 2021 Marcel Scherello
10
 */
11
12
namespace OCA\Analytics\Controller;
13
14
use OCA\Analytics\Service\ShareService;
15
use OCP\AppFramework\Controller;
16
use OCP\AppFramework\Http\DataResponse;
17
use OCP\IRequest;
18
use Psr\Log\LoggerInterface;
19
20
class ShareController extends Controller
21
{
22
    const SHARE_TYPE_USER = 0;
23
    const SHARE_TYPE_GROUP = 1;
24
    const SHARE_TYPE_USERGROUP = 2;
25
    const SHARE_TYPE_LINK = 3;
26
    const SHARE_TYPE_ROOM = 10;
27
28
    /** @var LoggerInterface */
29
    private $logger;
30
    private $ShareService;
31
32
    public function __construct(
33
        $appName,
34
        IRequest $request,
35
        LoggerInterface $logger,
36
        ShareService $ShareService,
37
    )
38
    {
39
        parent::__construct($appName, $request);
40
        $this->logger = $logger;
41
        $this->ShareService = $ShareService;
42
    }
43
44
    /**
45
     * create a new share
46
     *
47
     * @NoAdminRequired
48
     * @param $datasetId
49
     * @param $type
50
     * @param $user
51
     * @return DataResponse
52
     */
53
    public function create($datasetId, $type, $user)
54
    {
55
        return new DataResponse($this->ShareService->create($datasetId, $type, $user));
56
    }
57
58
    /**
59
     * get all shares for a dataset
60
     *
61
     * @NoAdminRequired
62
     * @param $datasetId
63
     * @return DataResponse
64
     */
65
    public function read($datasetId)
66
    {
67
        return new DataResponse($this->ShareService->read($datasetId));
68
    }
69
70
    /**
71
     * update/set share password
72
     *
73
     * @NoAdminRequired
74
     * @param $shareId
75
     * @param $password
76
     * @param $canEdit
77
     * @return DataResponse
78
     */
79
    public function update($shareId, $password = null, $canEdit = null)
80
    {
81
        return new DataResponse($this->ShareService->update($shareId, $password, $canEdit));
82
    }
83
84
    /**
85
     * delete a share
86
     *
87
     * @NoAdminRequired
88
     * @param $shareId
89
     * @return DataResponse
90
     */
91
    public function delete($shareId)
92
    {
93
        return new DataResponse($this->ShareService->delete($shareId));
94
    }
95
}