|
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\Controller; |
|
28
|
|
|
|
|
29
|
|
|
use OCA\Circles\Model\Share; |
|
30
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
31
|
|
|
|
|
32
|
|
|
class SharesController extends BaseController { |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Called by the JavaScript API when creating a new Share item that will be |
|
37
|
|
|
* broadcasted to the circle itself, and any other circle linked to it. |
|
38
|
|
|
* |
|
39
|
|
|
* @NoAdminRequired |
|
40
|
|
|
* @NoSubAdminRequired |
|
41
|
|
|
* |
|
42
|
|
|
* @param $id |
|
43
|
|
|
* @param $source |
|
44
|
|
|
* @param $type |
|
45
|
|
|
* @param $item |
|
46
|
|
|
* |
|
47
|
|
|
* @return DataResponse |
|
48
|
|
|
* @internal param string $name |
|
49
|
|
|
* |
|
50
|
|
|
*/ |
|
51
|
|
|
public function create($id, $source, $type, $item) { |
|
52
|
|
|
|
|
53
|
|
|
try { |
|
54
|
|
|
$share = new Share($source, $type); |
|
55
|
|
|
$share->setCircleId($id); |
|
56
|
|
|
$share->setItem($item); |
|
57
|
|
|
|
|
58
|
|
|
$this->sharesService->shareItem($share); |
|
59
|
|
|
} catch (\Exception $e) { |
|
60
|
|
|
return $this->fail( |
|
61
|
|
|
[ |
|
62
|
|
|
'circle_id' => $id, |
|
63
|
|
|
'source' => $source, |
|
64
|
|
|
'type' => $type, |
|
65
|
|
|
'item' => $item, |
|
66
|
|
|
'error' => $e->getMessage() |
|
67
|
|
|
] |
|
68
|
|
|
); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $this->success( |
|
72
|
|
|
[ |
|
73
|
|
|
'circle_id' => $id, |
|
74
|
|
|
'source' => $source, |
|
75
|
|
|
'type' => $type, |
|
76
|
|
|
'item' => $item |
|
77
|
|
|
] |
|
78
|
|
|
); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
|