Completed
Pull Request — master (#8791)
by Morris
17:41
created
lib/private/legacy/json.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
  * Class OC_JSON
37 37
  * @deprecated Use a AppFramework JSONResponse instead
38 38
  */
39
-class OC_JSON{
39
+class OC_JSON {
40 40
 	static protected $send_content_type_header = false;
41 41
 	/**
42 42
 	 * set Content-Type header to jsonrequest
43 43
 	 * @deprecated Use a AppFramework JSONResponse instead
44 44
 	 */
45
-	public static function setContentTypeHeader($type='application/json') {
45
+	public static function setContentTypeHeader($type = 'application/json') {
46 46
 		if (!self::$send_content_type_header) {
47 47
 			// We send json data
48
-			header( 'Content-Type: '.$type . '; charset=utf-8');
48
+			header('Content-Type: '.$type.'; charset=utf-8');
49 49
 			self::$send_content_type_header = true;
50 50
 		}
51 51
 	}
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @suppress PhanDeprecatedFunction
58 58
 	 */
59 59
 	public static function checkAppEnabled($app) {
60
-		if( !\OC::$server->getAppManager()->isEnabledForUser($app)) {
60
+		if (!\OC::$server->getAppManager()->isEnabledForUser($app)) {
61 61
 			$l = \OC::$server->getL10N('lib');
62
-			self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' )));
62
+			self::error(array('data' => array('message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled')));
63 63
 			exit();
64 64
 		}
65 65
 	}
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public static function checkLoggedIn() {
73 73
 		$twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
74
-		if( !\OC::$server->getUserSession()->isLoggedIn()
74
+		if (!\OC::$server->getUserSession()->isLoggedIn()
75 75
 			|| $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
76 76
 			$l = \OC::$server->getL10N('lib');
77 77
 			http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
78
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
78
+			self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
79 79
 			exit();
80 80
 		}
81 81
 	}
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
 	 * @suppress PhanDeprecatedFunction
87 87
 	 */
88 88
 	public static function callCheck() {
89
-		if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
89
+		if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
90 90
 			header('Location: '.\OC::$WEBROOT);
91 91
 			exit();
92 92
 		}
93 93
 
94
-		if( !\OC::$server->getRequest()->passesCSRFCheck()) {
94
+		if (!\OC::$server->getRequest()->passesCSRFCheck()) {
95 95
 			$l = \OC::$server->getL10N('lib');
96
-			self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' )));
96
+			self::error(array('data' => array('message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired')));
97 97
 			exit();
98 98
 		}
99 99
 	}
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 	 * @suppress PhanDeprecatedFunction
105 105
 	 */
106 106
 	public static function checkAdminUser() {
107
-		if( !OC_User::isAdminUser(OC_User::getUser())) {
107
+		if (!OC_User::isAdminUser(OC_User::getUser())) {
108 108
 			$l = \OC::$server->getL10N('lib');
109
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
109
+			self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
110 110
 			exit();
111 111
 		}
112 112
 	}
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 	public static function checkSubAdminUser() {
120 120
 		$userObject = \OC::$server->getUserSession()->getUser();
121 121
 		$isSubAdmin = false;
122
-		if($userObject !== null) {
122
+		if ($userObject !== null) {
123 123
 			$isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
124 124
 		}
125 125
 
126
-		if(!$isSubAdmin) {
126
+		if (!$isSubAdmin) {
127 127
 			$l = \OC::$server->getL10N('lib');
128
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
128
+			self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
129 129
 			exit();
130 130
 		}
131 131
 	}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	protected static function to_string(&$value) {
157 157
 		if ($value instanceof \OC\L10N\L10NString) {
158
-			$value = (string)$value;
158
+			$value = (string) $value;
159 159
 		}
160 160
 	}
161 161
 
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -37,138 +37,138 @@
 block discarded – undo
37 37
  * @deprecated Use a AppFramework JSONResponse instead
38 38
  */
39 39
 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
-	}
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
+    }
52 52
 
53
-	/**
54
-	 * Check if the app is enabled, send json error msg if not
55
-	 * @param string $app
56
-	 * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled.
57
-	 * @suppress PhanDeprecatedFunction
58
-	 */
59
-	public static function checkAppEnabled($app) {
60
-		if( !\OC::$server->getAppManager()->isEnabledForUser($app)) {
61
-			$l = \OC::$server->getL10N('lib');
62
-			self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' )));
63
-			exit();
64
-		}
65
-	}
53
+    /**
54
+     * Check if the app is enabled, send json error msg if not
55
+     * @param string $app
56
+     * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled.
57
+     * @suppress PhanDeprecatedFunction
58
+     */
59
+    public static function checkAppEnabled($app) {
60
+        if( !\OC::$server->getAppManager()->isEnabledForUser($app)) {
61
+            $l = \OC::$server->getL10N('lib');
62
+            self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' )));
63
+            exit();
64
+        }
65
+    }
66 66
 
67
-	/**
68
-	 * Check if the user is logged in, send json error msg if not
69
-	 * @deprecated Use annotation based ACLs from the AppFramework instead
70
-	 * @suppress PhanDeprecatedFunction
71
-	 */
72
-	public static function checkLoggedIn() {
73
-		$twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
74
-		if( !\OC::$server->getUserSession()->isLoggedIn()
75
-			|| $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
76
-			$l = \OC::$server->getL10N('lib');
77
-			http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
78
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
79
-			exit();
80
-		}
81
-	}
67
+    /**
68
+     * Check if the user is logged in, send json error msg if not
69
+     * @deprecated Use annotation based ACLs from the AppFramework instead
70
+     * @suppress PhanDeprecatedFunction
71
+     */
72
+    public static function checkLoggedIn() {
73
+        $twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
74
+        if( !\OC::$server->getUserSession()->isLoggedIn()
75
+            || $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
76
+            $l = \OC::$server->getL10N('lib');
77
+            http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
78
+            self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
79
+            exit();
80
+        }
81
+    }
82 82
 
83
-	/**
84
-	 * Check an ajax get/post call if the request token is valid, send json error msg if not.
85
-	 * @deprecated Use annotation based CSRF checks from the AppFramework instead
86
-	 * @suppress PhanDeprecatedFunction
87
-	 */
88
-	public static function callCheck() {
89
-		if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
90
-			header('Location: '.\OC::$WEBROOT);
91
-			exit();
92
-		}
83
+    /**
84
+     * Check an ajax get/post call if the request token is valid, send json error msg if not.
85
+     * @deprecated Use annotation based CSRF checks from the AppFramework instead
86
+     * @suppress PhanDeprecatedFunction
87
+     */
88
+    public static function callCheck() {
89
+        if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
90
+            header('Location: '.\OC::$WEBROOT);
91
+            exit();
92
+        }
93 93
 
94
-		if( !\OC::$server->getRequest()->passesCSRFCheck()) {
95
-			$l = \OC::$server->getL10N('lib');
96
-			self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' )));
97
-			exit();
98
-		}
99
-	}
94
+        if( !\OC::$server->getRequest()->passesCSRFCheck()) {
95
+            $l = \OC::$server->getL10N('lib');
96
+            self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' )));
97
+            exit();
98
+        }
99
+    }
100 100
 
101
-	/**
102
-	 * Check if the user is a admin, send json error msg if not.
103
-	 * @deprecated Use annotation based ACLs from the AppFramework instead
104
-	 * @suppress PhanDeprecatedFunction
105
-	 */
106
-	public static function checkAdminUser() {
107
-		if( !OC_User::isAdminUser(OC_User::getUser())) {
108
-			$l = \OC::$server->getL10N('lib');
109
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
110
-			exit();
111
-		}
112
-	}
101
+    /**
102
+     * Check if the user is a admin, send json error msg if not.
103
+     * @deprecated Use annotation based ACLs from the AppFramework instead
104
+     * @suppress PhanDeprecatedFunction
105
+     */
106
+    public static function checkAdminUser() {
107
+        if( !OC_User::isAdminUser(OC_User::getUser())) {
108
+            $l = \OC::$server->getL10N('lib');
109
+            self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
110
+            exit();
111
+        }
112
+    }
113 113
 
114
-	/**
115
-	 * Check if the user is a subadmin, send json error msg if not
116
-	 * @deprecated Use annotation based ACLs from the AppFramework instead
117
-	 * @suppress PhanDeprecatedFunction
118
-	 */
119
-	public static function checkSubAdminUser() {
120
-		$userObject = \OC::$server->getUserSession()->getUser();
121
-		$isSubAdmin = false;
122
-		if($userObject !== null) {
123
-			$isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
124
-		}
114
+    /**
115
+     * Check if the user is a subadmin, send json error msg if not
116
+     * @deprecated Use annotation based ACLs from the AppFramework instead
117
+     * @suppress PhanDeprecatedFunction
118
+     */
119
+    public static function checkSubAdminUser() {
120
+        $userObject = \OC::$server->getUserSession()->getUser();
121
+        $isSubAdmin = false;
122
+        if($userObject !== null) {
123
+            $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
124
+        }
125 125
 
126
-		if(!$isSubAdmin) {
127
-			$l = \OC::$server->getL10N('lib');
128
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
129
-			exit();
130
-		}
131
-	}
126
+        if(!$isSubAdmin) {
127
+            $l = \OC::$server->getL10N('lib');
128
+            self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
129
+            exit();
130
+        }
131
+    }
132 132
 
133
-	/**
134
-	 * Send json error msg
135
-	 * @deprecated Use a AppFramework JSONResponse instead
136
-	 * @suppress PhanDeprecatedFunction
137
-	 */
138
-	public static function error($data = array()) {
139
-		$data['status'] = 'error';
140
-		self::setContentTypeHeader();
141
-		echo self::encode($data);
142
-	}
133
+    /**
134
+     * Send json error msg
135
+     * @deprecated Use a AppFramework JSONResponse instead
136
+     * @suppress PhanDeprecatedFunction
137
+     */
138
+    public static function error($data = array()) {
139
+        $data['status'] = 'error';
140
+        self::setContentTypeHeader();
141
+        echo self::encode($data);
142
+    }
143 143
 
144
-	/**
145
-	 * Send json success msg
146
-	 * @deprecated Use a AppFramework JSONResponse instead
147
-	 * @suppress PhanDeprecatedFunction
148
-	 */
149
-	public static function success($data = array()) {
150
-		$data['status'] = 'success';
151
-		self::setContentTypeHeader();
152
-		echo self::encode($data);
153
-	}
144
+    /**
145
+     * Send json success msg
146
+     * @deprecated Use a AppFramework JSONResponse instead
147
+     * @suppress PhanDeprecatedFunction
148
+     */
149
+    public static function success($data = array()) {
150
+        $data['status'] = 'success';
151
+        self::setContentTypeHeader();
152
+        echo self::encode($data);
153
+    }
154 154
 
155
-	/**
156
-	 * Convert OC_L10N_String to string, for use in json encodings
157
-	 */
158
-	protected static function to_string(&$value) {
159
-		if ($value instanceof \OC\L10N\L10NString) {
160
-			$value = (string)$value;
161
-		}
162
-	}
155
+    /**
156
+     * Convert OC_L10N_String to string, for use in json encodings
157
+     */
158
+    protected static function to_string(&$value) {
159
+        if ($value instanceof \OC\L10N\L10NString) {
160
+            $value = (string)$value;
161
+        }
162
+    }
163 163
 
164
-	/**
165
-	 * Encode JSON
166
-	 * @deprecated Use a AppFramework JSONResponse instead
167
-	 */
168
-	public static function encode($data) {
169
-		if (is_array($data)) {
170
-			array_walk_recursive($data, array('OC_JSON', 'to_string'));
171
-		}
172
-		return json_encode($data, JSON_HEX_TAG);
173
-	}
164
+    /**
165
+     * Encode JSON
166
+     * @deprecated Use a AppFramework JSONResponse instead
167
+     */
168
+    public static function encode($data) {
169
+        if (is_array($data)) {
170
+            array_walk_recursive($data, array('OC_JSON', 'to_string'));
171
+        }
172
+        return json_encode($data, JSON_HEX_TAG);
173
+    }
174 174
 }
Please login to merge, or discard this patch.
lib/public/JSON.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -41,136 +41,136 @@
 block discarded – undo
41 41
  * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
42 42
  */
43 43
 class JSON {
44
-	/**
45
-	 * Check if the user is logged in, send json error msg if not.
46
-	 *
47
-	 * This method checks if a user is logged in. If not, a json error
48
-	 * response will be return and the method will exit from execution
49
-	 * of the script.
50
-	 * The returned json will be in the format:
51
-	 *
52
-	 *     {"status":"error","data":{"message":"Authentication error."}}
53
-	 *
54
-	 * Add this call to the start of all ajax method files that requires
55
-	 * an authenticated user.
56
-	 * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead
57
-	 *
58
-	 * @suppress PhanDeprecatedFunction
59
-	 */
60
-	public static function checkLoggedIn() {
61
-		\OC_JSON::checkLoggedIn();
62
-	}
44
+    /**
45
+     * Check if the user is logged in, send json error msg if not.
46
+     *
47
+     * This method checks if a user is logged in. If not, a json error
48
+     * response will be return and the method will exit from execution
49
+     * of the script.
50
+     * The returned json will be in the format:
51
+     *
52
+     *     {"status":"error","data":{"message":"Authentication error."}}
53
+     *
54
+     * Add this call to the start of all ajax method files that requires
55
+     * an authenticated user.
56
+     * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead
57
+     *
58
+     * @suppress PhanDeprecatedFunction
59
+     */
60
+    public static function checkLoggedIn() {
61
+        \OC_JSON::checkLoggedIn();
62
+    }
63 63
 
64
-	/**
65
-	 * Check an ajax get/post call if the request token is valid.
66
-	 *
67
-	 * This method checks for a valid variable 'requesttoken' in $_GET,
68
-	 * $_POST and $_SERVER. If a valid token is not found, a json error
69
-	 * response will be return and the method will exit from execution
70
-	 * of the script.
71
-	 * The returned json will be in the format:
72
-	 *
73
-	 *     {"status":"error","data":{"message":"Token expired. Please reload page."}}
74
-	 *
75
-	 * Add this call to the start of all ajax method files that creates,
76
-	 * updates or deletes anything.
77
-	 * In cases where you e.g. use an ajax call to load a dialog containing
78
-	 * a submittable form, you will need to add the requesttoken first as a
79
-	 * parameter to the ajax call, then assign it to the template and finally
80
-	 * add a hidden input field also named 'requesttoken' containing the value.
81
-	 * @deprecated 8.1.0 Use annotation based CSRF checks from the AppFramework instead
82
-	 *
83
-	 * @suppress PhanDeprecatedFunction
84
-	 */
85
-	public static function callCheck() {
86
-		\OC_JSON::callCheck();
87
-	}
64
+    /**
65
+     * Check an ajax get/post call if the request token is valid.
66
+     *
67
+     * This method checks for a valid variable 'requesttoken' in $_GET,
68
+     * $_POST and $_SERVER. If a valid token is not found, a json error
69
+     * response will be return and the method will exit from execution
70
+     * of the script.
71
+     * The returned json will be in the format:
72
+     *
73
+     *     {"status":"error","data":{"message":"Token expired. Please reload page."}}
74
+     *
75
+     * Add this call to the start of all ajax method files that creates,
76
+     * updates or deletes anything.
77
+     * In cases where you e.g. use an ajax call to load a dialog containing
78
+     * a submittable form, you will need to add the requesttoken first as a
79
+     * parameter to the ajax call, then assign it to the template and finally
80
+     * add a hidden input field also named 'requesttoken' containing the value.
81
+     * @deprecated 8.1.0 Use annotation based CSRF checks from the AppFramework instead
82
+     *
83
+     * @suppress PhanDeprecatedFunction
84
+     */
85
+    public static function callCheck() {
86
+        \OC_JSON::callCheck();
87
+    }
88 88
 
89
-	/**
90
-	 * Send json success msg
91
-	 *
92
-	 * Return a json success message with optional extra data.
93
-	 * @see \OCP\JSON::error()		for the format to use.
94
-	 *
95
-	 * @param array $data The data to use
96
-	 * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
97
-	 * @suppress PhanDeprecatedFunction
98
-	 */
99
-	public static function success( $data = array() ) {
100
-		\OC_JSON::success($data);
101
-	}
89
+    /**
90
+     * Send json success msg
91
+     *
92
+     * Return a json success message with optional extra data.
93
+     * @see \OCP\JSON::error()		for the format to use.
94
+     *
95
+     * @param array $data The data to use
96
+     * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
97
+     * @suppress PhanDeprecatedFunction
98
+     */
99
+    public static function success( $data = array() ) {
100
+        \OC_JSON::success($data);
101
+    }
102 102
 
103
-	/**
104
-	 * Send json error msg
105
-	 *
106
-	 * Return a json error message with optional extra data for
107
-	 * error message or app specific data.
108
-	 *
109
-	 * Example use:
110
-	 *
111
-	 *     $id = [some value]
112
-	 *     OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id)));
113
-	 *
114
-	 * Will return the json formatted string:
115
-	 *
116
-	 *     {"status":"error","data":{"message":"An error happened", "id":[some value]}}
117
-	 *
118
-	 * @param array $data The data to use
119
-	 * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
120
-	 * @suppress PhanDeprecatedFunction
121
-	 */
122
-	public static function error( $data = array() ) {
123
-		\OC_JSON::error($data);
124
-	}
103
+    /**
104
+     * Send json error msg
105
+     *
106
+     * Return a json error message with optional extra data for
107
+     * error message or app specific data.
108
+     *
109
+     * Example use:
110
+     *
111
+     *     $id = [some value]
112
+     *     OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id)));
113
+     *
114
+     * Will return the json formatted string:
115
+     *
116
+     *     {"status":"error","data":{"message":"An error happened", "id":[some value]}}
117
+     *
118
+     * @param array $data The data to use
119
+     * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
120
+     * @suppress PhanDeprecatedFunction
121
+     */
122
+    public static function error( $data = array() ) {
123
+        \OC_JSON::error($data);
124
+    }
125 125
 
126
-	/**
127
-	 * Set Content-Type header to jsonrequest
128
-	 * @param string $type The content type header
129
-	 * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
130
-	 * @suppress PhanDeprecatedFunction
131
-	 */
132
-	public static function setContentTypeHeader( $type='application/json' ) {
133
-		\OC_JSON::setContentTypeHeader($type);
134
-	}
126
+    /**
127
+     * Set Content-Type header to jsonrequest
128
+     * @param string $type The content type header
129
+     * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
130
+     * @suppress PhanDeprecatedFunction
131
+     */
132
+    public static function setContentTypeHeader( $type='application/json' ) {
133
+        \OC_JSON::setContentTypeHeader($type);
134
+    }
135 135
 
136
-	/**
137
-	 * Check if the App is enabled and send JSON error message instead
138
-	 *
139
-	 * This method checks if a specific app is enabled. If not, a json error
140
-	 * response will be return and the method will exit from execution
141
-	 * of the script.
142
-	 * The returned json will be in the format:
143
-	 *
144
-	 *     {"status":"error","data":{"message":"Application is not enabled."}}
145
-	 *
146
-	 * Add this call to the start of all ajax method files that requires
147
-	 * a specific app to be enabled.
148
-	 *
149
-	 * @param string $app The app to check
150
-	 * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled.
151
-	 * @suppress PhanDeprecatedFunction
152
-	 */
153
-	public static function checkAppEnabled( $app ) {
154
-		\OC_JSON::checkAppEnabled($app);
155
-	}
136
+    /**
137
+     * Check if the App is enabled and send JSON error message instead
138
+     *
139
+     * This method checks if a specific app is enabled. If not, a json error
140
+     * response will be return and the method will exit from execution
141
+     * of the script.
142
+     * The returned json will be in the format:
143
+     *
144
+     *     {"status":"error","data":{"message":"Application is not enabled."}}
145
+     *
146
+     * Add this call to the start of all ajax method files that requires
147
+     * a specific app to be enabled.
148
+     *
149
+     * @param string $app The app to check
150
+     * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled.
151
+     * @suppress PhanDeprecatedFunction
152
+     */
153
+    public static function checkAppEnabled( $app ) {
154
+        \OC_JSON::checkAppEnabled($app);
155
+    }
156 156
 
157
-	/**
158
-	 * Check if the user is a admin, send json error msg if not
159
-	 *
160
-	 * This method checks if the current user has admin rights. If not, a json error
161
-	 * response will be return and the method will exit from execution
162
-	 * of the script.
163
-	 * The returned json will be in the format:
164
-	 *
165
-	 *     {"status":"error","data":{"message":"Authentication error."}}
166
-	 *
167
-	 * Add this call to the start of all ajax method files that requires
168
-	 * administrative rights.
169
-	 *
170
-	 * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead
171
-	 * @suppress PhanDeprecatedFunction
172
-	 */
173
-	public static function checkAdminUser() {
174
-		\OC_JSON::checkAdminUser();
175
-	}
157
+    /**
158
+     * Check if the user is a admin, send json error msg if not
159
+     *
160
+     * This method checks if the current user has admin rights. If not, a json error
161
+     * response will be return and the method will exit from execution
162
+     * of the script.
163
+     * The returned json will be in the format:
164
+     *
165
+     *     {"status":"error","data":{"message":"Authentication error."}}
166
+     *
167
+     * Add this call to the start of all ajax method files that requires
168
+     * administrative rights.
169
+     *
170
+     * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead
171
+     * @suppress PhanDeprecatedFunction
172
+     */
173
+    public static function checkAdminUser() {
174
+        \OC_JSON::checkAdminUser();
175
+    }
176 176
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
97 97
 	 * @suppress PhanDeprecatedFunction
98 98
 	 */
99
-	public static function success( $data = array() ) {
99
+	public static function success($data = array()) {
100 100
 		\OC_JSON::success($data);
101 101
 	}
102 102
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
120 120
 	 * @suppress PhanDeprecatedFunction
121 121
 	 */
122
-	public static function error( $data = array() ) {
122
+	public static function error($data = array()) {
123 123
 		\OC_JSON::error($data);
124 124
 	}
125 125
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @deprecated 8.1.0 Use a AppFramework JSONResponse instead
130 130
 	 * @suppress PhanDeprecatedFunction
131 131
 	 */
132
-	public static function setContentTypeHeader( $type='application/json' ) {
132
+	public static function setContentTypeHeader($type = 'application/json') {
133 133
 		\OC_JSON::setContentTypeHeader($type);
134 134
 	}
135 135
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled.
151 151
 	 * @suppress PhanDeprecatedFunction
152 152
 	 */
153
-	public static function checkAppEnabled( $app ) {
153
+	public static function checkAppEnabled($app) {
154 154
 		\OC_JSON::checkAppEnabled($app);
155 155
 	}
156 156
 
Please login to merge, or discard this patch.
lib/private/legacy/eventsource.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -33,99 +33,99 @@
 block discarded – undo
33 33
  * use server side events with caution, to many open requests can hang the server
34 34
  */
35 35
 class OC_EventSource implements \OCP\IEventSource {
36
-	/**
37
-	 * @var bool
38
-	 */
39
-	private $fallback;
36
+    /**
37
+     * @var bool
38
+     */
39
+    private $fallback;
40 40
 
41
-	/**
42
-	 * @var int
43
-	 */
44
-	private $fallBackId = 0;
41
+    /**
42
+     * @var int
43
+     */
44
+    private $fallBackId = 0;
45 45
 
46
-	/**
47
-	 * @var bool
48
-	 */
49
-	private $started = false;
46
+    /**
47
+     * @var bool
48
+     */
49
+    private $started = false;
50 50
 
51
-	protected function init() {
52
-		if ($this->started) {
53
-			return;
54
-		}
55
-		$this->started = true;
51
+    protected function init() {
52
+        if ($this->started) {
53
+            return;
54
+        }
55
+        $this->started = true;
56 56
 
57
-		// prevent php output buffering, caching and nginx buffering
58
-		OC_Util::obEnd();
59
-		header('Cache-Control: no-cache');
60
-		header('X-Accel-Buffering: no');
61
-		$this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
62
-		if ($this->fallback) {
63
-			$this->fallBackId = (int)$_GET['fallback_id'];
64
-			/**
65
-			 * FIXME: The default content-security-policy of ownCloud forbids inline
66
-			 * JavaScript for security reasons. IE starting on Windows 10 will
67
-			 * however also obey the CSP which will break the event source fallback.
68
-			 *
69
-			 * As a workaround thus we set a custom policy which allows the execution
70
-			 * of inline JavaScript.
71
-			 *
72
-			 * @link https://github.com/owncloud/core/issues/14286
73
-			 */
74
-			header("Content-Security-Policy: default-src 'none'; script-src 'unsafe-inline'");
75
-			header("Content-Type: text/html");
76
-			echo str_repeat('<span></span>' . PHP_EOL, 10); //dummy data to keep IE happy
77
-		} else {
78
-			header("Content-Type: text/event-stream");
79
-		}
80
-		if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
81
-			header('Location: '.\OC::$WEBROOT);
82
-			exit();
83
-		}
84
-		if (!\OC::$server->getRequest()->passesCSRFCheck()) {
85
-			$this->send('error', 'Possible CSRF attack. Connection will be closed.');
86
-			$this->close();
87
-			exit();
88
-		}
89
-		flush();
90
-	}
57
+        // prevent php output buffering, caching and nginx buffering
58
+        OC_Util::obEnd();
59
+        header('Cache-Control: no-cache');
60
+        header('X-Accel-Buffering: no');
61
+        $this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
62
+        if ($this->fallback) {
63
+            $this->fallBackId = (int)$_GET['fallback_id'];
64
+            /**
65
+             * FIXME: The default content-security-policy of ownCloud forbids inline
66
+             * JavaScript for security reasons. IE starting on Windows 10 will
67
+             * however also obey the CSP which will break the event source fallback.
68
+             *
69
+             * As a workaround thus we set a custom policy which allows the execution
70
+             * of inline JavaScript.
71
+             *
72
+             * @link https://github.com/owncloud/core/issues/14286
73
+             */
74
+            header("Content-Security-Policy: default-src 'none'; script-src 'unsafe-inline'");
75
+            header("Content-Type: text/html");
76
+            echo str_repeat('<span></span>' . PHP_EOL, 10); //dummy data to keep IE happy
77
+        } else {
78
+            header("Content-Type: text/event-stream");
79
+        }
80
+        if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
81
+            header('Location: '.\OC::$WEBROOT);
82
+            exit();
83
+        }
84
+        if (!\OC::$server->getRequest()->passesCSRFCheck()) {
85
+            $this->send('error', 'Possible CSRF attack. Connection will be closed.');
86
+            $this->close();
87
+            exit();
88
+        }
89
+        flush();
90
+    }
91 91
 
92
-	/**
93
-	 * send a message to the client
94
-	 *
95
-	 * @param string $type
96
-	 * @param mixed $data
97
-	 *
98
-	 * @throws \BadMethodCallException
99
-	 * if only one parameter is given, a typeless message will be send with that parameter as data
100
-	 * @suppress PhanDeprecatedFunction
101
-	 */
102
-	public function send($type, $data = null) {
103
-		if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) {
104
-			throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
105
-		}
106
-		$this->init();
107
-		if (is_null($data)) {
108
-			$data = $type;
109
-			$type = null;
110
-		}
111
-		if ($this->fallback) {
112
-			$response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
113
-				. $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
114
-			echo $response;
115
-		} else {
116
-			if ($type) {
117
-				echo 'event: ' . $type . PHP_EOL;
118
-			}
119
-			echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
120
-		}
121
-		echo PHP_EOL;
122
-		flush();
123
-	}
92
+    /**
93
+     * send a message to the client
94
+     *
95
+     * @param string $type
96
+     * @param mixed $data
97
+     *
98
+     * @throws \BadMethodCallException
99
+     * if only one parameter is given, a typeless message will be send with that parameter as data
100
+     * @suppress PhanDeprecatedFunction
101
+     */
102
+    public function send($type, $data = null) {
103
+        if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) {
104
+            throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
105
+        }
106
+        $this->init();
107
+        if (is_null($data)) {
108
+            $data = $type;
109
+            $type = null;
110
+        }
111
+        if ($this->fallback) {
112
+            $response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
113
+                . $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
114
+            echo $response;
115
+        } else {
116
+            if ($type) {
117
+                echo 'event: ' . $type . PHP_EOL;
118
+            }
119
+            echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
120
+        }
121
+        echo PHP_EOL;
122
+        flush();
123
+    }
124 124
 
125
-	/**
126
-	 * close the connection of the event source
127
-	 */
128
-	public function close() {
129
-		$this->send('__internal__', 'close'); //server side closing can be an issue, let the client do it
130
-	}
125
+    /**
126
+     * close the connection of the event source
127
+     */
128
+    public function close() {
129
+        $this->send('__internal__', 'close'); //server side closing can be an issue, let the client do it
130
+    }
131 131
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		header('X-Accel-Buffering: no');
61 61
 		$this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
62 62
 		if ($this->fallback) {
63
-			$this->fallBackId = (int)$_GET['fallback_id'];
63
+			$this->fallBackId = (int) $_GET['fallback_id'];
64 64
 			/**
65 65
 			 * FIXME: The default content-security-policy of ownCloud forbids inline
66 66
 			 * JavaScript for security reasons. IE starting on Windows 10 will
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 			 */
74 74
 			header("Content-Security-Policy: default-src 'none'; script-src 'unsafe-inline'");
75 75
 			header("Content-Type: text/html");
76
-			echo str_repeat('<span></span>' . PHP_EOL, 10); //dummy data to keep IE happy
76
+			echo str_repeat('<span></span>'.PHP_EOL, 10); //dummy data to keep IE happy
77 77
 		} else {
78 78
 			header("Content-Type: text/event-stream");
79 79
 		}
80
-		if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
80
+		if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
81 81
 			header('Location: '.\OC::$WEBROOT);
82 82
 			exit();
83 83
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function send($type, $data = null) {
103 103
 		if ($data and !preg_match('/^[A-Za-z0-9_]+$/', $type)) {
104
-			throw new BadMethodCallException('Type needs to be alphanumeric ('. $type .')');
104
+			throw new BadMethodCallException('Type needs to be alphanumeric ('.$type.')');
105 105
 		}
106 106
 		$this->init();
107 107
 		if (is_null($data)) {
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 		if ($this->fallback) {
112 112
 			$response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
113
-				. $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
113
+				. $this->fallBackId.',"'.$type.'",'.OC_JSON::encode($data).')</script>'.PHP_EOL;
114 114
 			echo $response;
115 115
 		} else {
116 116
 			if ($type) {
117
-				echo 'event: ' . $type . PHP_EOL;
117
+				echo 'event: '.$type.PHP_EOL;
118 118
 			}
119
-			echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
119
+			echo 'data: '.OC_JSON::encode($data).PHP_EOL;
120 120
 		}
121 121
 		echo PHP_EOL;
122 122
 		flush();
Please login to merge, or discard this patch.