Skip to content

Commit 63490b0

Browse files
committed
Remove unused methods of OC_Json
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
1 parent bb59cc1 commit 63490b0

3 files changed

Lines changed: 6 additions & 86 deletions

File tree

lib/private/legacy/eventsource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ public function send($type, $data = null) {
110110
}
111111
if ($this->fallback) {
112112
$response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
113-
. $this->fallBackId . ',"' . $type . '",' . OCP\JSON::encode($data) . ')</script>' . PHP_EOL;
113+
. $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
114114
echo $response;
115115
} else {
116116
if ($type) {
117117
echo 'event: ' . $type . PHP_EOL;
118118
}
119-
echo 'data: ' . OCP\JSON::encode($data) . PHP_EOL;
119+
echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
120120
}
121121
echo PHP_EOL;
122122
flush();

lib/private/legacy/json.php

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@
3737
* @deprecated Use a AppFramework JSONResponse instead
3838
*/
3939
class OC_JSON{
40-
static protected $send_content_type_header = false;
41-
/**
42-
* set Content-Type header to jsonrequest
43-
* @deprecated Use a AppFramework JSONResponse instead
44-
*/
45-
public static function setContentTypeHeader($type='application/json') {
46-
if (!self::$send_content_type_header) {
47-
// We send json data
48-
header( 'Content-Type: '.$type . '; charset=utf-8');
49-
self::$send_content_type_header = true;
50-
}
51-
}
5240

5341
/**
5442
* Check if the app is enabled, send json error msg if not
@@ -111,21 +99,6 @@ public static function checkAdminUser() {
11199
}
112100
}
113101

114-
/**
115-
* Check is a given user exists - send json error msg if not
116-
* @param string $user
117-
* @deprecated Use a AppFramework JSONResponse instead
118-
* @suppress PhanDeprecatedFunction
119-
*/
120-
public static function checkUserExists($user) {
121-
if (!\OC::$server->getUserManager()->userExists($user)) {
122-
$l = \OC::$server->getL10N('lib');
123-
OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' )));
124-
exit;
125-
}
126-
}
127-
128-
129102
/**
130103
* Check if the user is a subadmin, send json error msg if not
131104
* @deprecated Use annotation based ACLs from the AppFramework instead
@@ -152,7 +125,8 @@ public static function checkSubAdminUser() {
152125
*/
153126
public static function error($data = array()) {
154127
$data['status'] = 'error';
155-
self::encodedPrint($data);
128+
header( 'Content-Type: application/json; charset=utf-8');
129+
echo self::encode($data);
156130
}
157131

158132
/**
@@ -162,7 +136,8 @@ public static function error($data = array()) {
162136
*/
163137
public static function success($data = array()) {
164138
$data['status'] = 'success';
165-
self::encodedPrint($data);
139+
header( 'Content-Type: application/json; charset=utf-8');
140+
echo self::encode($data);
166141
}
167142

168143
/**
@@ -174,18 +149,6 @@ protected static function to_string(&$value) {
174149
}
175150
}
176151

177-
/**
178-
* Encode and print $data in json format
179-
* @deprecated Use a AppFramework JSONResponse instead
180-
* @suppress PhanDeprecatedFunction
181-
*/
182-
public static function encodedPrint($data, $setContentType=true) {
183-
if($setContentType) {
184-
self::setContentTypeHeader();
185-
}
186-
echo self::encode($data);
187-
}
188-
189152
/**
190153
* Encode JSON
191154
* @deprecated Use a AppFramework JSONResponse instead

lib/public/JSON.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@
4141
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
4242
*/
4343
class JSON {
44-
/**
45-
* Encode and print $data in JSON format
46-
* @param array $data The data to use
47-
* @param bool $setContentType the optional content type
48-
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
49-
*
50-
* @suppress PhanDeprecatedFunction
51-
*/
52-
public static function encodedPrint( $data, $setContentType=true ) {
53-
\OC_JSON::encodedPrint($data, $setContentType);
54-
}
55-
5644
/**
5745
* Check if the user is logged in, send json error msg if not.
5846
*
@@ -135,16 +123,6 @@ public static function error( $data = array() ) {
135123
\OC_JSON::error($data);
136124
}
137125

138-
/**
139-
* Set Content-Type header to jsonrequest
140-
* @param string $type The content type header
141-
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
142-
* @suppress PhanDeprecatedFunction
143-
*/
144-
public static function setContentTypeHeader( $type='application/json' ) {
145-
\OC_JSON::setContentTypeHeader($type);
146-
}
147-
148126
/**
149127
* Check if the App is enabled and send JSON error message instead
150128
*
@@ -185,25 +163,4 @@ public static function checkAppEnabled( $app ) {
185163
public static function checkAdminUser() {
186164
\OC_JSON::checkAdminUser();
187165
}
188-
189-
/**
190-
* Encode JSON
191-
* @param array $data
192-
* @return string
193-
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
194-
* @suppress PhanDeprecatedFunction
195-
*/
196-
public static function encode($data) {
197-
return \OC_JSON::encode($data);
198-
}
199-
200-
/**
201-
* Check is a given user exists - send json error msg if not
202-
* @param string $user
203-
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
204-
* @suppress PhanDeprecatedFunction
205-
*/
206-
public static function checkUserExists($user) {
207-
\OC_JSON::checkUserExists($user);
208-
}
209166
}

0 commit comments

Comments
 (0)