|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Circles - Bring cloud-users closer together. |
|
4
|
|
|
* |
|
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
6
|
|
|
* later. See the COPYING file. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Maxence Lange <[email protected]> |
|
9
|
|
|
* @copyright 2017 |
|
10
|
|
|
* @license GNU AGPL version 3 or any later version |
|
11
|
|
|
* |
|
12
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
14
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
15
|
|
|
* License, or (at your option) any later version. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, |
|
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
* GNU Affero General Public License for more details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
namespace OCA\Circles\Db; |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
use daita\MySmallPhpTools\Traits\TStringTools; |
|
32
|
|
|
use OCA\Circles\Model\GlobalScale\GSShare; |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Class GSSharesRequest |
|
37
|
|
|
* |
|
38
|
|
|
* @package OCA\Circles\Db |
|
39
|
|
|
*/ |
|
40
|
|
|
class GSSharesRequest extends GSSharesRequestBuilder { |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
use TStringTools; |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param GSShare $gsShare |
|
48
|
|
|
*/ |
|
49
|
|
|
public function create(GSShare $gsShare): void { |
|
50
|
|
|
$hash = $this->token(); |
|
51
|
|
|
$qb = $this->getGSSharesInsertSql(); |
|
52
|
|
|
$qb->setValue('circle_unique_id', $qb->createNamedParameter($gsShare->getCircleId())) |
|
53
|
|
|
->setValue('owner', $qb->createNamedParameter($gsShare->getOwner())) |
|
54
|
|
|
->setValue('instance', $qb->createNamedParameter($gsShare->getInstance())) |
|
55
|
|
|
->setValue('token', $qb->createNamedParameter($gsShare->getToken())) |
|
56
|
|
|
->setValue('parent', $qb->createNamedParameter($gsShare->getParent())) |
|
57
|
|
|
->setValue('mountpoint', $qb->createNamedParameter($gsShare->getMountPoint())) |
|
58
|
|
|
->setValue('mountpoint_hash', $qb->createNamedParameter($hash)); |
|
59
|
|
|
$qb->execute(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param string $userId |
|
65
|
|
|
* |
|
66
|
|
|
* @return GSShare[] |
|
67
|
|
|
*/ |
|
68
|
|
View Code Duplication |
public function getForUser(string $userId): array { |
|
|
|
|
|
|
69
|
|
|
$qb = $this->getGSSharesSelectSql(); |
|
70
|
|
|
|
|
71
|
|
|
$shares = []; |
|
72
|
|
|
$cursor = $qb->execute(); |
|
73
|
|
|
while ($data = $cursor->fetch()) { |
|
74
|
|
|
$shares[] = $this->parseGSSharesSelectSql($data); |
|
75
|
|
|
} |
|
76
|
|
|
$cursor->closeCursor(); |
|
77
|
|
|
|
|
78
|
|
|
return $shares; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.