Skip to content

Commit

Permalink
Remove unused methods of OC_Json
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Mar 13, 2018
1 parent 3655951 commit 0a004fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 86 deletions.
4 changes: 2 additions & 2 deletions lib/private/legacy/eventsource.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ public function send($type, $data = null) {
}
if ($this->fallback) {
$response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
. $this->fallBackId . ',"' . $type . '",' . OCP\JSON::encode($data) . ')</script>' . PHP_EOL;
. $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
echo $response;
} else {
if ($type) {
echo 'event: ' . $type . PHP_EOL;
}
echo 'data: ' . OCP\JSON::encode($data) . PHP_EOL;
echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
}
echo PHP_EOL;
flush();
Expand Down
45 changes: 4 additions & 41 deletions lib/private/legacy/json.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@
* @deprecated Use a AppFramework JSONResponse instead
*/
class OC_JSON{
static protected $send_content_type_header = false;
/**
* set Content-Type header to jsonrequest
* @deprecated Use a AppFramework JSONResponse instead
*/
public static function setContentTypeHeader($type='application/json') {
if (!self::$send_content_type_header) {
// We send json data
header( 'Content-Type: '.$type . '; charset=utf-8');
self::$send_content_type_header = true;
}
}

/**
* Check if the app is enabled, send json error msg if not
Expand Down Expand Up @@ -111,21 +99,6 @@ public static function checkAdminUser() {
}
}

/**
* Check is a given user exists - send json error msg if not
* @param string $user
* @deprecated Use a AppFramework JSONResponse instead
* @suppress PhanDeprecatedFunction
*/
public static function checkUserExists($user) {
if (!\OC::$server->getUserManager()->userExists($user)) {
$l = \OC::$server->getL10N('lib');
OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' )));
exit;
}
}


/**
* Check if the user is a subadmin, send json error msg if not
* @deprecated Use annotation based ACLs from the AppFramework instead
Expand All @@ -152,7 +125,8 @@ public static function checkSubAdminUser() {
*/
public static function error($data = array()) {
$data['status'] = 'error';
self::encodedPrint($data);
header( 'Content-Type: application/json; charset=utf-8');
echo self::encode($data);
}

/**
Expand All @@ -162,7 +136,8 @@ public static function error($data = array()) {
*/
public static function success($data = array()) {
$data['status'] = 'success';
self::encodedPrint($data);
header( 'Content-Type: application/json; charset=utf-8');
echo self::encode($data);
}

/**
Expand All @@ -174,18 +149,6 @@ protected static function to_string(&$value) {
}
}

/**
* Encode and print $data in json format
* @deprecated Use a AppFramework JSONResponse instead
* @suppress PhanDeprecatedFunction
*/
public static function encodedPrint($data, $setContentType=true) {
if($setContentType) {
self::setContentTypeHeader();
}
echo self::encode($data);
}

/**
* Encode JSON
* @deprecated Use a AppFramework JSONResponse instead
Expand Down
43 changes: 0 additions & 43 deletions lib/public/JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
*/
class JSON {
/**
* Encode and print $data in JSON format
* @param array $data The data to use
* @param bool $setContentType the optional content type
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
*
* @suppress PhanDeprecatedFunction
*/
public static function encodedPrint( $data, $setContentType=true ) {
\OC_JSON::encodedPrint($data, $setContentType);
}

/**
* Check if the user is logged in, send json error msg if not.
*
Expand Down Expand Up @@ -135,16 +123,6 @@ public static function error( $data = array() ) {
\OC_JSON::error($data);
}

/**
* Set Content-Type header to jsonrequest
* @param string $type The content type header
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
* @suppress PhanDeprecatedFunction
*/
public static function setContentTypeHeader( $type='application/json' ) {
\OC_JSON::setContentTypeHeader($type);
}

/**
* Check if the App is enabled and send JSON error message instead
*
Expand Down Expand Up @@ -185,25 +163,4 @@ public static function checkAppEnabled( $app ) {
public static function checkAdminUser() {
\OC_JSON::checkAdminUser();
}

/**
* Encode JSON
* @param array $data
* @return string
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
* @suppress PhanDeprecatedFunction
*/
public static function encode($data) {
return \OC_JSON::encode($data);
}

/**
* Check is a given user exists - send json error msg if not
* @param string $user
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
* @suppress PhanDeprecatedFunction
*/
public static function checkUserExists($user) {
\OC_JSON::checkUserExists($user);
}
}

0 comments on commit 0a004fb

Please sign in to comment.