|
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
|
|
|
namespace OCA\Circles\Api; |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
use OCA\Circles\AppInfo\Application; |
|
31
|
|
|
use OCA\Circles\Model\SharingFrame; |
|
32
|
|
|
|
|
33
|
|
|
class Circles { |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
protected static function getContainer() { |
|
37
|
|
|
$app = new Application(); |
|
38
|
|
|
|
|
39
|
|
|
return $app->getContainer(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public static function createCircle($type, $name) { |
|
43
|
|
|
$c = self::getContainer(); |
|
44
|
|
|
|
|
45
|
|
|
return $c->query('CirclesService') |
|
46
|
|
|
->createCircle($type, $name); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
public static function listCircles($type, $name = '', $level = 0) { |
|
51
|
|
|
$c = self::getContainer(); |
|
52
|
|
|
|
|
53
|
|
|
return $c->query('CirclesService') |
|
54
|
|
|
->listCircles($type, $name, $level); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
public static function detailsCircle($circleId) { |
|
59
|
|
|
$c = self::getContainer(); |
|
60
|
|
|
|
|
61
|
|
|
return $c->query('CirclesService') |
|
62
|
|
|
->detailsCircle($circleId); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
public static function destroyCircle($circleId) { |
|
67
|
|
|
$c = self::getContainer(); |
|
68
|
|
|
|
|
69
|
|
|
return $c->query('CirclesService') |
|
70
|
|
|
->removeCircle($circleId); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
public static function shareToCircle( |
|
75
|
|
|
$circleId, $source, $type, array $payload, $broadcaster |
|
76
|
|
|
) { |
|
77
|
|
|
$c = self::getContainer(); |
|
78
|
|
|
|
|
79
|
|
|
$frame = new SharingFrame((string)$source, (string)$type); |
|
80
|
|
|
$frame->setCircleId((int)$circleId); |
|
81
|
|
|
$frame->setPayload($payload); |
|
82
|
|
|
|
|
83
|
|
|
return $c->query('SharesService') |
|
84
|
|
|
->createFrame($frame, (string)$broadcaster); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
public static function addMember($circleId, $userId) { |
|
89
|
|
|
$c = self::getContainer(); |
|
90
|
|
|
|
|
91
|
|
|
return $c->query('MembersService') |
|
92
|
|
|
->addMember($circleId, $userId); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
} |