|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bernhard Posselt <[email protected]> |
|
6
|
|
|
* @author Lukas Reschke <[email protected]> |
|
7
|
|
|
* @author Morris Jobke <[email protected]> |
|
8
|
|
|
* @author Robin Appelman <[email protected]> |
|
9
|
|
|
* @author Robin McCorkell <[email protected]> |
|
10
|
|
|
* @author Thomas Müller <[email protected]> |
|
11
|
|
|
* |
|
12
|
|
|
* @license AGPL-3.0 |
|
13
|
|
|
* |
|
14
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
15
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
16
|
|
|
* as published by the Free Software Foundation. |
|
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, version 3, |
|
24
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
25
|
|
|
* |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
namespace OC\AppFramework\Core; |
|
30
|
|
|
use OCP\AppFramework\IApi; |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* This is used to wrap the owncloud static api calls into an object to make the |
|
35
|
|
|
* code better abstractable for use in the dependency injection container |
|
36
|
|
|
* |
|
37
|
|
|
* Should you find yourself in need for more methods, simply inherit from this |
|
38
|
|
|
* class and add your methods |
|
39
|
|
|
* @deprecated |
|
40
|
|
|
*/ |
|
41
|
|
|
class API implements IApi{ |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
private $appName; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* constructor |
|
47
|
|
|
* @param string $appName the name of your application |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct($appName){ |
|
50
|
|
|
$this->appName = $appName; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Gets the userid of the current user |
|
56
|
|
|
* @return string the user id of the current user |
|
57
|
|
|
* @deprecated Use \OC::$server->getUserSession()->getUser()->getUID() |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getUserId(){ |
|
60
|
|
|
return \OCP\User::getUser(); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Adds a new javascript file |
|
66
|
|
|
* @deprecated include javascript and css in template files |
|
67
|
|
|
* @param string $scriptName the name of the javascript in js/ without the suffix |
|
68
|
|
|
* @param string $appName the name of the app, defaults to the current one |
|
69
|
|
|
*/ |
|
70
|
|
|
public function addScript($scriptName, $appName=null){ |
|
71
|
|
|
if($appName === null){ |
|
72
|
|
|
$appName = $this->appName; |
|
73
|
|
|
} |
|
74
|
|
|
\OCP\Util::addScript($appName, $scriptName); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Adds a new css file |
|
80
|
|
|
* @deprecated include javascript and css in template files |
|
81
|
|
|
* @param string $styleName the name of the css file in css/without the suffix |
|
82
|
|
|
* @param string $appName the name of the app, defaults to the current one |
|
83
|
|
|
*/ |
|
84
|
|
|
public function addStyle($styleName, $appName=null){ |
|
85
|
|
|
if($appName === null){ |
|
86
|
|
|
$appName = $this->appName; |
|
87
|
|
|
} |
|
88
|
|
|
\OCP\Util::addStyle($appName, $styleName); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @deprecated include javascript and css in template files |
|
94
|
|
|
* shorthand for addScript for files in the 3rdparty directory |
|
95
|
|
|
* @param string $name the name of the file without the suffix |
|
96
|
|
|
*/ |
|
97
|
|
|
public function add3rdPartyScript($name){ |
|
98
|
|
|
\OCP\Util::addScript($this->appName . '/3rdparty', $name); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @deprecated include javascript and css in template files |
|
104
|
|
|
* shorthand for addStyle for files in the 3rdparty directory |
|
105
|
|
|
* @param string $name the name of the file without the suffix |
|
106
|
|
|
*/ |
|
107
|
|
|
public function add3rdPartyStyle($name){ |
|
108
|
|
|
\OCP\Util::addStyle($this->appName . '/3rdparty', $name); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @deprecated communication between apps should happen over built in |
|
114
|
|
|
* callbacks or interfaces (check the contacts and calendar managers) |
|
115
|
|
|
* Checks if an app is enabled |
|
116
|
|
|
* also use \OC::$server->getAppManager()->isEnabledForUser($appName) |
|
117
|
|
|
* @param string $appName the name of an app |
|
118
|
|
|
* @return bool true if app is enabled |
|
119
|
|
|
*/ |
|
120
|
|
|
public function isAppEnabled($appName){ |
|
121
|
|
|
return \OCP\App::isEnabled($appName); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* used to return and open a new event source |
|
127
|
|
|
* @return \OCP\IEventSource a new open EventSource class |
|
128
|
|
|
* @deprecated Use \OC::$server->createEventSource(); |
|
129
|
|
|
*/ |
|
130
|
|
|
public function openEventSource(){ |
|
131
|
|
|
return \OC::$server->createEventSource(); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @deprecated register hooks directly for class that build in hook interfaces |
|
136
|
|
|
* connects a function to a hook |
|
137
|
|
|
* @param string $signalClass class name of emitter |
|
138
|
|
|
* @param string $signalName name of signal |
|
139
|
|
|
* @param string $slotClass class name of slot |
|
140
|
|
|
* @param string $slotName name of slot, in another word, this is the |
|
141
|
|
|
* name of the method that will be called when registered |
|
142
|
|
|
* signal is emitted. |
|
143
|
|
|
* @return bool always true |
|
144
|
|
|
*/ |
|
145
|
|
|
public function connectHook($signalClass, $signalName, $slotClass, $slotName) { |
|
146
|
|
|
return \OCP\Util::connectHook($signalClass, $signalName, $slotClass, $slotName); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @deprecated implement the emitter interface instead |
|
151
|
|
|
* Emits a signal. To get data from the slot use references! |
|
152
|
|
|
* @param string $signalClass class name of emitter |
|
153
|
|
|
* @param string $signalName name of signal |
|
154
|
|
|
* @param array $params default: array() array with additional data |
|
155
|
|
|
* @return bool true if slots exists or false if not |
|
156
|
|
|
*/ |
|
157
|
|
|
public function emitHook($signalClass, $signalName, $params = array()) { |
|
158
|
|
|
return \OCP\Util::emitHook($signalClass, $signalName, $params); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* clear hooks |
|
163
|
|
|
* @deprecated clear hooks directly for class that build in hook interfaces |
|
164
|
|
|
* @param string $signalClass |
|
165
|
|
|
* @param string $signalName |
|
166
|
|
|
*/ |
|
167
|
|
|
public function clearHook($signalClass=false, $signalName=false) { |
|
168
|
|
|
if ($signalClass) { |
|
|
|
|
|
|
169
|
|
|
\OC_Hook::clear($signalClass, $signalName); |
|
|
|
|
|
|
170
|
|
|
} |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Tells ownCloud to include a template in the admin overview |
|
175
|
|
|
* @param string $mainPath the path to the main php file without the php |
|
176
|
|
|
* suffix, relative to your apps directory! not the template directory |
|
177
|
|
|
* @param string $appName the name of the app, defaults to the current one |
|
178
|
|
|
*/ |
|
179
|
|
|
public function registerAdmin($mainPath, $appName=null) { |
|
180
|
|
|
if($appName === null){ |
|
181
|
|
|
$appName = $this->appName; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
\OCP\App::registerAdmin($appName, $mainPath); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
|
|
188
|
|
|
} |
|
189
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.