|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Circles - Bring cloud-users closer together. |
|
5
|
|
|
* |
|
6
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
7
|
|
|
* later. See the COPYING file. |
|
8
|
|
|
* |
|
9
|
|
|
* @author Maxence Lange <[email protected]> |
|
10
|
|
|
* @copyright 2017 |
|
11
|
|
|
* @license GNU AGPL version 3 or any later version |
|
12
|
|
|
* |
|
13
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
14
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
15
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
16
|
|
|
* License, or (at your option) any later version. |
|
17
|
|
|
* |
|
18
|
|
|
* This program is distributed in the hope that it will be useful, |
|
19
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21
|
|
|
* GNU Affero General Public License for more details. |
|
22
|
|
|
* |
|
23
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
24
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25
|
|
|
* |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
namespace OCA\Circles\Db; |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
use Doctrine\DBAL\Query\QueryBuilder; |
|
32
|
|
|
use OCA\Circles\Model\Member; |
|
33
|
|
|
use OCA\Circles\Service\MiscService; |
|
34
|
|
|
use OCP\DB\QueryBuilder\IQueryBuilder; |
|
35
|
|
|
use OCP\IDBConnection; |
|
36
|
|
|
use OCP\Share; |
|
37
|
|
|
use OCP\Share\IShare; |
|
38
|
|
|
|
|
39
|
|
|
class FederatedLinksRequestBuilder { |
|
40
|
|
|
|
|
41
|
|
|
const TABLE_FEDERATED = 'circles_federated'; |
|
42
|
|
|
|
|
43
|
|
|
/** @var IDBConnection */ |
|
44
|
|
|
protected $dbConnection; |
|
45
|
|
|
|
|
46
|
|
|
/** @var MiscService */ |
|
47
|
|
|
protected $miscService; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* CirclesRequest constructor. |
|
51
|
|
|
* |
|
52
|
|
|
* @param IDBConnection $connection |
|
53
|
|
|
* @param MiscService $miscService |
|
54
|
|
|
*/ |
|
55
|
|
|
public function __construct(IDBConnection $connection, MiscService $miscService) { |
|
56
|
|
|
$this->dbConnection = $connection; |
|
57
|
|
|
$this->miscService = $miscService; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Base of the Sql Insert request |
|
63
|
|
|
* |
|
64
|
|
|
* @return IQueryBuilder |
|
65
|
|
|
*/ |
|
66
|
|
|
protected function getLinksInsertSql() { |
|
67
|
|
|
$qb = $this->dbConnection->getQueryBuilder(); |
|
68
|
|
|
$qb->insert(self::TABLE_FEDERATED) |
|
69
|
|
|
->setValue('creation', $qb->createFunction('NOW()')); |
|
70
|
|
|
|
|
71
|
|
|
return $qb; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Base of the Sql Update request |
|
77
|
|
|
* |
|
78
|
|
|
* @return IQueryBuilder |
|
79
|
|
|
*/ |
|
80
|
|
|
protected function getLinksUpdateSql() { |
|
81
|
|
|
$qb = $this->dbConnection->getQueryBuilder(); |
|
82
|
|
|
$qb->update(self::TABLE_FEDERATED); |
|
83
|
|
|
|
|
84
|
|
|
return $qb; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Base of the Sql Select request |
|
90
|
|
|
* |
|
91
|
|
|
* @return IQueryBuilder |
|
92
|
|
|
*/ |
|
93
|
|
|
protected function getLinksSelectSql() { |
|
94
|
|
|
$qb = $this->dbConnection->getQueryBuilder(); |
|
95
|
|
|
$qb->select('f.id', 'f.unique_id', 'f.status', 'f.address', 'f.token', 'f.circle_id') |
|
96
|
|
|
->from(self::TABLE_FEDERATED, 'f'); |
|
97
|
|
|
|
|
98
|
|
|
return $qb; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Base of the Sql Delete request |
|
103
|
|
|
* |
|
104
|
|
|
* @return IQueryBuilder |
|
105
|
|
|
*/ |
|
106
|
|
|
protected function getLinksDeleteSql() { |
|
107
|
|
|
$qb = $this->dbConnection->getQueryBuilder(); |
|
108
|
|
|
$qb->delete(self::TABLE_FEDERATED); |
|
109
|
|
|
|
|
110
|
|
|
return $qb; |
|
111
|
|
|
} |
|
112
|
|
|
} |