|
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 OC\AppFramework\Http; |
|
30
|
|
|
use OCA\Circles\Service\CirclesService; |
|
31
|
|
|
use OCA\Circles\Service\ConfigService; |
|
32
|
|
|
use OCA\Circles\Service\MembersService; |
|
33
|
|
|
|
|
34
|
|
|
use OCA\Circles\Service\MiscService; |
|
35
|
|
|
use OCP\AppFramework\Controller; |
|
36
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
37
|
|
|
use OCP\IL10N; |
|
38
|
|
|
use OCP\IRequest; |
|
39
|
|
|
|
|
40
|
|
|
class BaseController extends Controller { |
|
41
|
|
|
|
|
42
|
|
|
/** @var string */ |
|
43
|
|
|
protected $userId; |
|
44
|
|
|
|
|
45
|
|
|
/** @var IL10N */ |
|
46
|
|
|
protected $l10n; |
|
47
|
|
|
|
|
48
|
|
|
/** @var ConfigService */ |
|
49
|
|
|
protected $configService; |
|
50
|
|
|
|
|
51
|
|
|
/** @var CirclesService */ |
|
52
|
|
|
protected $circlesService; |
|
53
|
|
|
|
|
54
|
|
|
/** @var MembersService */ |
|
55
|
|
|
protected $membersService; |
|
56
|
|
|
|
|
57
|
|
|
/** @var MiscService */ |
|
58
|
|
|
protected $miscService; |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* BaseController constructor. |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $appName |
|
65
|
|
|
* @param IRequest $request |
|
66
|
|
|
* @param $userId |
|
67
|
|
|
* @param IL10N $l10n |
|
68
|
|
|
* @param ConfigService $configService |
|
69
|
|
|
* @param CirclesService $circlesService |
|
70
|
|
|
* @param MembersService $membersService |
|
71
|
|
|
* @param MiscService $miscService |
|
72
|
|
|
*/ |
|
73
|
|
|
public function __construct( |
|
74
|
|
|
$appName, |
|
75
|
|
|
IRequest $request, |
|
76
|
|
|
$userId, |
|
77
|
|
|
IL10N $l10n, |
|
78
|
|
|
ConfigService $configService, |
|
79
|
|
|
CirclesService $circlesService, |
|
80
|
|
|
MembersService $membersService, |
|
81
|
|
|
MiscService $miscService |
|
82
|
|
|
) { |
|
83
|
|
|
parent::__construct($appName, $request); |
|
84
|
|
|
|
|
85
|
|
|
$this->userId = $userId; |
|
86
|
|
|
$this->l10n = $l10n; |
|
87
|
|
|
$this->configService = $configService; |
|
88
|
|
|
$this->circlesService = $circlesService; |
|
89
|
|
|
$this->membersService = $membersService; |
|
90
|
|
|
$this->miscService = $miscService; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param $data |
|
95
|
|
|
* |
|
96
|
|
|
* @return DataResponse |
|
97
|
|
|
*/ |
|
98
|
|
|
protected function fail($data) { |
|
99
|
|
|
return new DataResponse( |
|
100
|
|
|
array_merge($data, array('status' => 0)), |
|
101
|
|
|
Http::STATUS_NON_AUTHORATIVE_INFORMATION |
|
102
|
|
|
); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @param $data |
|
107
|
|
|
* |
|
108
|
|
|
* @return DataResponse |
|
109
|
|
|
*/ |
|
110
|
|
|
protected function success($data) { |
|
111
|
|
|
return new DataResponse( |
|
112
|
|
|
array_merge($data, array('status' => 1)), |
|
113
|
|
|
Http::STATUS_CREATED |
|
114
|
|
|
); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
} |