Completed
Push — master ( 11e182...8521e7 )
by Lukas
15:27
created
lib/private/legacy/json.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
  * Class OC_JSON
35 35
  * @deprecated Use a AppFramework JSONResponse instead
36 36
  */
37
-class OC_JSON{
37
+class OC_JSON {
38 38
 	static protected $send_content_type_header = false;
39 39
 	/**
40 40
 	 * set Content-Type header to jsonrequest
41 41
 	 * @deprecated Use a AppFramework JSONResponse instead
42 42
 	 */
43
-	public static function setContentTypeHeader($type='application/json') {
43
+	public static function setContentTypeHeader($type = 'application/json') {
44 44
 		if (!self::$send_content_type_header) {
45 45
 			// We send json data
46
-			header( 'Content-Type: '.$type . '; charset=utf-8');
46
+			header('Content-Type: '.$type.'; charset=utf-8');
47 47
 			self::$send_content_type_header = true;
48 48
 		}
49 49
 	}
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled.
55 55
 	 */
56 56
 	public static function checkAppEnabled($app) {
57
-		if( !OC_App::isEnabled($app)) {
57
+		if (!OC_App::isEnabled($app)) {
58 58
 			$l = \OC::$server->getL10N('lib');
59
-			self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' )));
59
+			self::error(array('data' => array('message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled')));
60 60
 			exit();
61 61
 		}
62 62
 	}
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public static function checkLoggedIn() {
69 69
 		$twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
70
-		if( !\OC::$server->getUserSession()->isLoggedIn()
70
+		if (!\OC::$server->getUserSession()->isLoggedIn()
71 71
 			|| $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
72 72
 			$l = \OC::$server->getL10N('lib');
73 73
 			http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
74
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
74
+			self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
75 75
 			exit();
76 76
 		}
77 77
 	}
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 	 * @deprecated Use annotation based CSRF checks from the AppFramework instead
82 82
 	 */
83 83
 	public static function callCheck() {
84
-		if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
84
+		if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
85 85
 			header('Location: '.\OC::$WEBROOT);
86 86
 			exit();
87 87
 		}
88 88
 
89
-		if( !(\OC::$server->getRequest()->passesCSRFCheck())) {
89
+		if (!(\OC::$server->getRequest()->passesCSRFCheck())) {
90 90
 			$l = \OC::$server->getL10N('lib');
91
-			self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' )));
91
+			self::error(array('data' => array('message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired')));
92 92
 			exit();
93 93
 		}
94 94
 	}
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 	 * @deprecated Use annotation based ACLs from the AppFramework instead
99 99
 	 */
100 100
 	public static function checkAdminUser() {
101
-		if( !OC_User::isAdminUser(OC_User::getUser())) {
101
+		if (!OC_User::isAdminUser(OC_User::getUser())) {
102 102
 			$l = \OC::$server->getL10N('lib');
103
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
103
+			self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
104 104
 			exit();
105 105
 		}
106 106
 	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	public static function checkUserExists($user) {
114 114
 		if (!OCP\User::userExists($user)) {
115 115
 			$l = \OC::$server->getL10N('lib');
116
-			OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' )));
116
+			OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user')));
117 117
 			exit;
118 118
 		}
119 119
 	}
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 	public static function checkSubAdminUser() {
127 127
 		$userObject = \OC::$server->getUserSession()->getUser();
128 128
 		$isSubAdmin = false;
129
-		if($userObject !== null) {
129
+		if ($userObject !== null) {
130 130
 			$isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
131 131
 		}
132 132
 
133
-		if(!$isSubAdmin) {
133
+		if (!$isSubAdmin) {
134 134
 			$l = \OC::$server->getL10N('lib');
135
-			self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' )));
135
+			self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
136 136
 			exit();
137 137
 		}
138 138
 	}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	protected static function to_string(&$value) {
162 162
 		if ($value instanceof \OC\L10N\L10NString) {
163
-			$value = (string)$value;
163
+			$value = (string) $value;
164 164
 		}
165 165
 	}
166 166
 
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * Encode and print $data in json format
169 169
 	 * @deprecated Use a AppFramework JSONResponse instead
170 170
 	 */
171
-	public static function encodedPrint($data, $setContentType=true) {
172
-		if($setContentType) {
171
+	public static function encodedPrint($data, $setContentType = true) {
172
+		if ($setContentType) {
173 173
 			self::setContentTypeHeader();
174 174
 		}
175 175
 		echo self::encode($data);
Please login to merge, or discard this patch.