@@ -48,7 +48,7 @@ |
||
48 | 48 | try { |
49 | 49 | session_start(); |
50 | 50 | } catch (\Exception $e) { |
51 | - setcookie(session_name(), null, -1, \OC::$WEBROOT ? : '/'); |
|
51 | + setcookie(session_name(), null, -1, \OC::$WEBROOT ?: '/'); |
|
52 | 52 | } |
53 | 53 | restore_error_handler(); |
54 | 54 | if (!isset($_SESSION)) { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * because the database connection was created with an uninitialized config |
88 | 88 | */ |
89 | 89 | private function fixDIInit() { |
90 | - if($this->connection === null) { |
|
90 | + if ($this->connection === null) { |
|
91 | 91 | $this->connection = \OC::$server->getDatabaseConnection(); |
92 | 92 | } |
93 | 93 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | // TODO - FIXME |
285 | 285 | $this->fixDIInit(); |
286 | 286 | |
287 | - $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
287 | + $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
288 | 288 | 'WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?'; |
289 | 289 | $this->connection->executeUpdate($sql, array($userId, $appName, $key)); |
290 | 290 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | // TODO - FIXME |
303 | 303 | $this->fixDIInit(); |
304 | 304 | |
305 | - $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
305 | + $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
306 | 306 | 'WHERE `userid` = ?'; |
307 | 307 | $this->connection->executeUpdate($sql, array($userId)); |
308 | 308 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | // TODO - FIXME |
319 | 319 | $this->fixDIInit(); |
320 | 320 | |
321 | - $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
321 | + $sql = 'DELETE FROM `*PREFIX*preferences` '. |
|
322 | 322 | 'WHERE `appid` = ?'; |
323 | 323 | $this->connection->executeUpdate($sql, array($appName)); |
324 | 324 | |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | array_unshift($queryParams, $key); |
384 | 384 | array_unshift($queryParams, $appName); |
385 | 385 | |
386 | - $placeholders = (sizeof($chunk) == 50) ? $placeholders50 : implode(',', array_fill(0, sizeof($chunk), '?')); |
|
386 | + $placeholders = (sizeof($chunk) == 50) ? $placeholders50 : implode(',', array_fill(0, sizeof($chunk), '?')); |
|
387 | 387 | |
388 | - $query = 'SELECT `userid`, `configvalue` ' . |
|
389 | - 'FROM `*PREFIX*preferences` ' . |
|
390 | - 'WHERE `appid` = ? AND `configkey` = ? ' . |
|
391 | - 'AND `userid` IN (' . $placeholders . ')'; |
|
388 | + $query = 'SELECT `userid`, `configvalue` '. |
|
389 | + 'FROM `*PREFIX*preferences` '. |
|
390 | + 'WHERE `appid` = ? AND `configkey` = ? '. |
|
391 | + 'AND `userid` IN ('.$placeholders.')'; |
|
392 | 392 | $result = $this->connection->executeQuery($query, $queryParams); |
393 | 393 | |
394 | 394 | while ($row = $result->fetch()) { |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | // TODO - FIXME |
412 | 412 | $this->fixDIInit(); |
413 | 413 | |
414 | - $sql = 'SELECT `userid` FROM `*PREFIX*preferences` ' . |
|
414 | + $sql = 'SELECT `userid` FROM `*PREFIX*preferences` '. |
|
415 | 415 | 'WHERE `appid` = ? AND `configkey` = ? '; |
416 | 416 | |
417 | - if($this->getSystemValue('dbtype', 'sqlite') === 'oci') { |
|
417 | + if ($this->getSystemValue('dbtype', 'sqlite') === 'oci') { |
|
418 | 418 | //oracle hack: need to explicitly cast CLOB to CHAR for comparison |
419 | 419 | $sql .= 'AND to_char(`configvalue`) = ?'; |
420 | 420 | } else { |
@@ -57,43 +57,43 @@ discard block |
||
57 | 57 | * @param string $renderAs |
58 | 58 | * @param string $appId application id |
59 | 59 | */ |
60 | - public function __construct( $renderAs, $appId = '' ) { |
|
60 | + public function __construct($renderAs, $appId = '') { |
|
61 | 61 | |
62 | 62 | // yes - should be injected .... |
63 | 63 | $this->config = \OC::$server->getConfig(); |
64 | 64 | |
65 | 65 | // Decide which page we show |
66 | - if($renderAs == 'user') { |
|
67 | - parent::__construct( 'core', 'layout.user' ); |
|
68 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
66 | + if ($renderAs == 'user') { |
|
67 | + parent::__construct('core', 'layout.user'); |
|
68 | + if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { |
|
69 | 69 | $this->assign('bodyid', 'body-settings'); |
70 | - }else{ |
|
70 | + } else { |
|
71 | 71 | $this->assign('bodyid', 'body-user'); |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Code integrity notification |
75 | 75 | $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
76 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
76 | + if (\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
77 | 77 | \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Add navigation entry |
81 | - $this->assign( 'application', ''); |
|
82 | - $this->assign( 'appid', $appId ); |
|
81 | + $this->assign('application', ''); |
|
82 | + $this->assign('appid', $appId); |
|
83 | 83 | $navigation = \OC_App::getNavigation(); |
84 | - $this->assign( 'navigation', $navigation); |
|
84 | + $this->assign('navigation', $navigation); |
|
85 | 85 | $settingsNavigation = \OC_App::getSettingsNavigation(); |
86 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
87 | - foreach($navigation as $entry) { |
|
86 | + $this->assign('settingsnavigation', $settingsNavigation); |
|
87 | + foreach ($navigation as $entry) { |
|
88 | 88 | if ($entry['active']) { |
89 | - $this->assign( 'application', $entry['name'] ); |
|
89 | + $this->assign('application', $entry['name']); |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - foreach($settingsNavigation as $entry) { |
|
94 | + foreach ($settingsNavigation as $entry) { |
|
95 | 95 | if ($entry['active']) { |
96 | - $this->assign( 'application', $entry['name'] ); |
|
96 | + $this->assign('application', $entry['name']); |
|
97 | 97 | break; |
98 | 98 | } |
99 | 99 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | // Send the language to our layouts |
128 | 128 | $this->assign('language', \OC_L10N::findLanguage()); |
129 | 129 | |
130 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
130 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
131 | 131 | if (empty(self::$versionHash)) { |
132 | 132 | $v = \OC_App::getAppVersions(); |
133 | 133 | $v['core'] = implode('.', \OCP\Util::getVersion()); |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | |
140 | 140 | $useAssetPipeline = self::isAssetPipelineEnabled(); |
141 | 141 | if ($useAssetPipeline) { |
142 | - $this->append( 'jsfiles', \OC::$server->getURLGenerator()->linkToRoute('js_config', ['v' => self::$versionHash])); |
|
142 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('js_config', ['v' => self::$versionHash])); |
|
143 | 143 | $this->generateAssets(); |
144 | 144 | } else { |
145 | 145 | // Add the js files |
146 | 146 | $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
147 | 147 | $this->assign('jsfiles', array()); |
148 | 148 | if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
149 | - $this->append( 'jsfiles', \OC::$server->getURLGenerator()->linkToRoute('js_config', ['v' => self::$versionHash])); |
|
149 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('js_config', ['v' => self::$versionHash])); |
|
150 | 150 | } |
151 | - foreach($jsFiles as $info) { |
|
151 | + foreach ($jsFiles as $info) { |
|
152 | 152 | $web = $info[1]; |
153 | 153 | $file = $info[2]; |
154 | - $this->append( 'jsfiles', $web.'/'.$file . '?v=' . self::$versionHash); |
|
154 | + $this->append('jsfiles', $web.'/'.$file.'?v='.self::$versionHash); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // Add the css files |
158 | 158 | $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
159 | 159 | $this->assign('cssfiles', array()); |
160 | - foreach($cssFiles as $info) { |
|
160 | + foreach ($cssFiles as $info) { |
|
161 | 161 | $web = $info[1]; |
162 | 162 | $file = $info[2]; |
163 | 163 | |
164 | - $this->append( 'cssfiles', $web.'/'.$file . '?v=' . self::$versionHash); |
|
164 | + $this->append('cssfiles', $web.'/'.$file.'?v='.self::$versionHash); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | $locator = new \OC\Template\CSSResourceLocator( |
178 | 178 | \OC::$server->getLogger(), |
179 | 179 | $theme, |
180 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
181 | - array( \OC::$THIRDPARTYROOT => \OC::$THIRDPARTYWEBROOT )); |
|
180 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
181 | + array(\OC::$THIRDPARTYROOT => \OC::$THIRDPARTYWEBROOT)); |
|
182 | 182 | $locator->find($styles); |
183 | 183 | return $locator->getResources(); |
184 | 184 | } |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | $locator = new \OC\Template\JSResourceLocator( |
195 | 195 | \OC::$server->getLogger(), |
196 | 196 | $theme, |
197 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
198 | - array( \OC::$THIRDPARTYROOT => \OC::$THIRDPARTYWEBROOT )); |
|
197 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
198 | + array(\OC::$THIRDPARTYROOT => \OC::$THIRDPARTYWEBROOT)); |
|
199 | 199 | $locator->find($scripts); |
200 | 200 | return $locator->getResources(); |
201 | 201 | } |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | $jsHash = self::hashFileNames($jsFiles); |
207 | 207 | |
208 | 208 | if (!file_exists("$assetDir/assets/$jsHash.js")) { |
209 | - $jsFiles = array_map(function ($item) { |
|
209 | + $jsFiles = array_map(function($item) { |
|
210 | 210 | $root = $item[0]; |
211 | 211 | $file = $item[2]; |
212 | 212 | // no need to minifiy minified files |
213 | 213 | if (substr($file, -strlen('.min.js')) === '.min.js') { |
214 | - return new FileAsset($root . '/' . $file, array( |
|
214 | + return new FileAsset($root.'/'.$file, array( |
|
215 | 215 | new SeparatorFilter(';') |
216 | 216 | ), $root, $file); |
217 | 217 | } |
218 | - return new FileAsset($root . '/' . $file, array( |
|
218 | + return new FileAsset($root.'/'.$file, array( |
|
219 | 219 | new JSqueezeFilter(), |
220 | 220 | new SeparatorFilter(';') |
221 | 221 | ), $root, $file); |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | $cssHash = self::hashFileNames($cssFiles); |
232 | 232 | |
233 | 233 | if (!file_exists("$assetDir/assets/$cssHash.css")) { |
234 | - $cssFiles = array_map(function ($item) { |
|
234 | + $cssFiles = array_map(function($item) { |
|
235 | 235 | $root = $item[0]; |
236 | 236 | $file = $item[2]; |
237 | - $assetPath = $root . '/' . $file; |
|
238 | - $sourceRoot = \OC::$SERVERROOT; |
|
237 | + $assetPath = $root.'/'.$file; |
|
238 | + $sourceRoot = \OC::$SERVERROOT; |
|
239 | 239 | $sourcePath = substr($assetPath, strlen(\OC::$SERVERROOT)); |
240 | 240 | return new FileAsset( |
241 | 241 | $assetPath, |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public static function convertToRelativePath($filePath) { |
269 | 269 | $relativePath = explode(\OC::$SERVERROOT, $filePath); |
270 | - if(count($relativePath) !== 2) { |
|
270 | + if (count($relativePath) !== 2) { |
|
271 | 271 | throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
272 | 272 | } |
273 | 273 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | */ |
281 | 281 | |
282 | 282 | private static function hashFileNames($files) { |
283 | - foreach($files as $i => $file) { |
|
283 | + foreach ($files as $i => $file) { |
|
284 | 284 | try { |
285 | 285 | $files[$i] = self::convertToRelativePath($file[0]).'/'.$file[2]; |
286 | 286 | } catch (\Exception $e) { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | static public function enableCaching($cache_time = null) { |
49 | 49 | if (is_numeric($cache_time)) { |
50 | - header('Pragma: public');// enable caching in IE |
|
50 | + header('Pragma: public'); // enable caching in IE |
|
51 | 51 | if ($cache_time > 0) { |
52 | 52 | self::setExpiresHeader('PT'.$cache_time.'S'); |
53 | 53 | header('Cache-Control: max-age='.$cache_time.', must-revalidate'); |
@@ -78,29 +78,29 @@ discard block |
||
78 | 78 | */ |
79 | 79 | static public function setStatus($status) { |
80 | 80 | $protocol = \OC::$server->getRequest()->getHttpProtocol(); |
81 | - switch($status) { |
|
81 | + switch ($status) { |
|
82 | 82 | case self::STATUS_NOT_MODIFIED: |
83 | - $status = $status . ' Not Modified'; |
|
83 | + $status = $status.' Not Modified'; |
|
84 | 84 | break; |
85 | 85 | case self::STATUS_TEMPORARY_REDIRECT: |
86 | 86 | if ($protocol == 'HTTP/1.1') { |
87 | - $status = $status . ' Temporary Redirect'; |
|
87 | + $status = $status.' Temporary Redirect'; |
|
88 | 88 | break; |
89 | 89 | } else { |
90 | 90 | $status = self::STATUS_FOUND; |
91 | 91 | // fallthrough |
92 | 92 | } |
93 | 93 | case self::STATUS_FOUND; |
94 | - $status = $status . ' Found'; |
|
94 | + $status = $status.' Found'; |
|
95 | 95 | break; |
96 | 96 | case self::STATUS_NOT_FOUND; |
97 | - $status = $status . ' Not Found'; |
|
97 | + $status = $status.' Not Found'; |
|
98 | 98 | break; |
99 | 99 | case self::STATUS_INTERNAL_SERVER_ERROR; |
100 | - $status = $status . ' Internal Server Error'; |
|
100 | + $status = $status.' Internal Server Error'; |
|
101 | 101 | break; |
102 | 102 | case self::STATUS_SERVICE_UNAVAILABLE; |
103 | - $status = $status . ' Service Unavailable'; |
|
103 | + $status = $status.' Service Unavailable'; |
|
104 | 104 | break; |
105 | 105 | } |
106 | 106 | header($protocol.' '.$status); |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | * @param string $filename file name |
181 | 181 | * @param string $type disposition type, either 'attachment' or 'inline' |
182 | 182 | */ |
183 | - static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { |
|
183 | + static public function setContentDispositionHeader($filename, $type = 'attachment') { |
|
184 | 184 | if (\OC::$server->getRequest()->isUserAgent( |
185 | 185 | [ |
186 | 186 | \OC\AppFramework\Http\Request::USER_AGENT_IE, |
187 | 187 | \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME, |
188 | 188 | \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX, |
189 | 189 | ])) { |
190 | - header( 'Content-Disposition: ' . rawurlencode($type) . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
190 | + header('Content-Disposition: '.rawurlencode($type).'; filename="'.rawurlencode($filename).'"'); |
|
191 | 191 | } else { |
192 | - header( 'Content-Disposition: ' . rawurlencode($type) . '; filename*=UTF-8\'\'' . rawurlencode( $filename ) |
|
193 | - . '; filename="' . rawurlencode( $filename ) . '"' ); |
|
192 | + header('Content-Disposition: '.rawurlencode($type).'; filename*=UTF-8\'\''.rawurlencode($filename) |
|
193 | + . '; filename="'.rawurlencode($filename).'"'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | . 'font-src \'self\' data:; ' |
255 | 255 | . 'media-src *; ' |
256 | 256 | . 'connect-src *'; |
257 | - header('Content-Security-Policy:' . $policy); |
|
257 | + header('Content-Security-Policy:'.$policy); |
|
258 | 258 | |
259 | 259 | // Send fallback headers for installations that don't have the possibility to send |
260 | 260 | // custom headers on the webserver side |
261 | - if(getenv('modHeadersAvailable') !== 'true') { |
|
261 | + if (getenv('modHeadersAvailable') !== 'true') { |
|
262 | 262 | header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters |
263 | 263 | header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE |
264 | 264 | header('X-Frame-Options: Sameorigin'); // Disallow iFraming from other domains |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | * @param SystemConfig $config the system config object |
66 | 66 | * @param null $normalizer |
67 | 67 | */ |
68 | - public function __construct($logger=null, SystemConfig $config=null, $normalizer = null) { |
|
68 | + public function __construct($logger = null, SystemConfig $config = null, $normalizer = null) { |
|
69 | 69 | // FIXME: Add this for backwards compatibility, should be fixed at some point probably |
70 | - if($config === null) { |
|
70 | + if ($config === null) { |
|
71 | 71 | $config = \OC::$server->getSystemConfig(); |
72 | 72 | } |
73 | 73 | |
74 | 74 | $this->config = $config; |
75 | 75 | |
76 | 76 | // FIXME: Add this for backwards compatibility, should be fixed at some point probably |
77 | - if($logger === null) { |
|
77 | + if ($logger === null) { |
|
78 | 78 | $this->logger = 'OC_Log_'.ucfirst($this->config->getValue('log_type', 'owncloud')); |
79 | 79 | call_user_func(array($this->logger, 'init')); |
80 | 80 | } else { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * check log condition based on the context of each log message |
210 | 210 | * once this is met -> change the required log level to debug |
211 | 211 | */ |
212 | - if(!empty($logCondition) |
|
212 | + if (!empty($logCondition) |
|
213 | 213 | && isset($logCondition['apps']) |
214 | 214 | && in_array($app, $logCondition['apps'], true)) { |
215 | 215 | $minLevel = Util::DEBUG; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | // interpolate $message as defined in PSR-3 |
222 | 222 | $replace = array(); |
223 | 223 | foreach ($context as $key => $val) { |
224 | - $replace['{' . $key . '}'] = $val; |
|
224 | + $replace['{'.$key.'}'] = $val; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // interpolate replacement values into the message and return |
@@ -231,27 +231,27 @@ discard block |
||
231 | 231 | * check for a special log condition - this enables an increased log on |
232 | 232 | * a per request/user base |
233 | 233 | */ |
234 | - if($this->logConditionSatisfied === null) { |
|
234 | + if ($this->logConditionSatisfied === null) { |
|
235 | 235 | // default to false to just process this once per request |
236 | 236 | $this->logConditionSatisfied = false; |
237 | - if(!empty($logCondition)) { |
|
237 | + if (!empty($logCondition)) { |
|
238 | 238 | |
239 | 239 | // check for secret token in the request |
240 | - if(isset($logCondition['shared_secret'])) { |
|
240 | + if (isset($logCondition['shared_secret'])) { |
|
241 | 241 | $request = \OC::$server->getRequest(); |
242 | 242 | |
243 | 243 | // if token is found in the request change set the log condition to satisfied |
244 | - if($request && hash_equals($logCondition['shared_secret'], $request->getParam('log_secret'))) { |
|
244 | + if ($request && hash_equals($logCondition['shared_secret'], $request->getParam('log_secret'))) { |
|
245 | 245 | $this->logConditionSatisfied = true; |
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | 249 | // check for user |
250 | - if(isset($logCondition['users'])) { |
|
250 | + if (isset($logCondition['users'])) { |
|
251 | 251 | $user = \OC::$server->getUserSession()->getUser(); |
252 | 252 | |
253 | 253 | // if the user matches set the log condition to satisfied |
254 | - if($user !== null && in_array($user->getUID(), $logCondition['users'], true)) { |
|
254 | + if ($user !== null && in_array($user->getUID(), $logCondition['users'], true)) { |
|
255 | 255 | $this->logConditionSatisfied = true; |
256 | 256 | } |
257 | 257 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | // if log condition is satisfied change the required log level to DEBUG |
262 | - if($this->logConditionSatisfied) { |
|
262 | + if ($this->logConditionSatisfied) { |
|
263 | 263 | $minLevel = Util::DEBUG; |
264 | 264 | } |
265 | 265 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | ); |
289 | 289 | $exception['Trace'] = preg_replace('!(login|checkPassword|updatePrivateKeyPassword|validateUserPass)\(.*\)!', '$1(*** username and password replaced ***)', $exception['Trace']); |
290 | 290 | $msg = isset($context['message']) ? $context['message'] : 'Exception'; |
291 | - $msg .= ': ' . json_encode($exception); |
|
291 | + $msg .= ': '.json_encode($exception); |
|
292 | 292 | $this->error($msg, $context); |
293 | 293 | } |
294 | 294 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @throws \UnexpectedValueException |
102 | 102 | */ |
103 | 103 | protected function prepareCommentForDatabaseWrite(IComment $comment) { |
104 | - if( !$comment->getActorType() |
|
104 | + if (!$comment->getActorType() |
|
105 | 105 | || !$comment->getActorId() |
106 | 106 | || !$comment->getObjectType() |
107 | 107 | || !$comment->getObjectId() |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | throw new \UnexpectedValueException('Actor, Object and Verb information must be provided for saving'); |
111 | 111 | } |
112 | 112 | |
113 | - if($comment->getId() === '') { |
|
113 | + if ($comment->getId() === '') { |
|
114 | 114 | $comment->setChildrenCount(0); |
115 | 115 | $comment->setLatestChildDateTime(new \DateTime('0000-00-00 00:00:00', new \DateTimeZone('UTC'))); |
116 | 116 | $comment->setLatestChildDateTime(null); |
117 | 117 | } |
118 | 118 | |
119 | - if(is_null($comment->getCreationDateTime())) { |
|
119 | + if (is_null($comment->getCreationDateTime())) { |
|
120 | 120 | $comment->setCreationDateTime(new \DateTime()); |
121 | 121 | } |
122 | 122 | |
123 | - if($comment->getParentId() !== '0') { |
|
123 | + if ($comment->getParentId() !== '0') { |
|
124 | 124 | $comment->setTopmostParentId($this->determineTopmostParentId($comment->getParentId())); |
125 | 125 | } else { |
126 | 126 | $comment->setTopmostParentId('0'); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function determineTopmostParentId($id) { |
142 | 142 | $comment = $this->get($id); |
143 | - if($comment->getParentId() === '0') { |
|
143 | + if ($comment->getParentId() === '0') { |
|
144 | 144 | return $comment->getId(); |
145 | 145 | } else { |
146 | 146 | return $this->determineTopmostParentId($comment->getId()); |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | * @throws \InvalidArgumentException |
183 | 183 | */ |
184 | 184 | protected function checkRoleParameters($role, $type, $id) { |
185 | - if( |
|
185 | + if ( |
|
186 | 186 | !is_string($type) || empty($type) |
187 | 187 | || !is_string($id) || empty($id) |
188 | 188 | ) { |
189 | - throw new \InvalidArgumentException($role . ' parameters must be string and not empty'); |
|
189 | + throw new \InvalidArgumentException($role.' parameters must be string and not empty'); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function cache(IComment $comment) { |
199 | 199 | $id = $comment->getId(); |
200 | - if(empty($id)) { |
|
200 | + if (empty($id)) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | $this->commentsCache[strval($id)] = $comment; |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @since 9.0.0 |
226 | 226 | */ |
227 | 227 | public function get($id) { |
228 | - if(intval($id) === 0) { |
|
228 | + if (intval($id) === 0) { |
|
229 | 229 | throw new \InvalidArgumentException('IDs must be translatable to a number in this implementation.'); |
230 | 230 | } |
231 | 231 | |
232 | - if(isset($this->commentsCache[$id])) { |
|
232 | + if (isset($this->commentsCache[$id])) { |
|
233 | 233 | return $this->commentsCache[$id]; |
234 | 234 | } |
235 | 235 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | $data = $resultStatement->fetch(); |
244 | 244 | $resultStatement->closeCursor(); |
245 | - if(!$data) { |
|
245 | + if (!$data) { |
|
246 | 246 | throw new NotFoundException(); |
247 | 247 | } |
248 | 248 | |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | ->orderBy('creation_timestamp', 'DESC') |
293 | 293 | ->setParameter('id', $id); |
294 | 294 | |
295 | - if($limit > 0) { |
|
295 | + if ($limit > 0) { |
|
296 | 296 | $query->setMaxResults($limit); |
297 | 297 | } |
298 | - if($offset > 0) { |
|
298 | + if ($offset > 0) { |
|
299 | 299 | $query->setFirstResult($offset); |
300 | 300 | } |
301 | 301 | |
302 | 302 | $resultStatement = $query->execute(); |
303 | - while($data = $resultStatement->fetch()) { |
|
303 | + while ($data = $resultStatement->fetch()) { |
|
304 | 304 | $comment = new Comment($this->normalizeDatabaseData($data)); |
305 | 305 | $this->cache($comment); |
306 | 306 | $tree['replies'][] = [ |
@@ -346,20 +346,20 @@ discard block |
||
346 | 346 | ->setParameter('type', $objectType) |
347 | 347 | ->setParameter('id', $objectId); |
348 | 348 | |
349 | - if($limit > 0) { |
|
349 | + if ($limit > 0) { |
|
350 | 350 | $query->setMaxResults($limit); |
351 | 351 | } |
352 | - if($offset > 0) { |
|
352 | + if ($offset > 0) { |
|
353 | 353 | $query->setFirstResult($offset); |
354 | 354 | } |
355 | - if(!is_null($notOlderThan)) { |
|
355 | + if (!is_null($notOlderThan)) { |
|
356 | 356 | $query |
357 | 357 | ->andWhere($qb->expr()->gt('creation_timestamp', $qb->createParameter('notOlderThan'))) |
358 | 358 | ->setParameter('notOlderThan', $notOlderThan, 'datetime'); |
359 | 359 | } |
360 | 360 | |
361 | 361 | $resultStatement = $query->execute(); |
362 | - while($data = $resultStatement->fetch()) { |
|
362 | + while ($data = $resultStatement->fetch()) { |
|
363 | 363 | $comment = new Comment($this->normalizeDatabaseData($data)); |
364 | 364 | $this->cache($comment); |
365 | 365 | $comments[] = $comment; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | ->setParameter('type', $objectType) |
387 | 387 | ->setParameter('id', $objectId); |
388 | 388 | |
389 | - if(!is_null($notOlderThan)) { |
|
389 | + if (!is_null($notOlderThan)) { |
|
390 | 390 | $query |
391 | 391 | ->andWhere($qb->expr()->gt('creation_timestamp', $qb->createParameter('notOlderThan'))) |
392 | 392 | ->setParameter('notOlderThan', $notOlderThan, 'datetime'); |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * @since 9.0.0 |
431 | 431 | */ |
432 | 432 | public function delete($id) { |
433 | - if(!is_string($id)) { |
|
433 | + if (!is_string($id)) { |
|
434 | 434 | throw new \InvalidArgumentException('Parameter must be string'); |
435 | 435 | } |
436 | 436 | |
@@ -481,13 +481,13 @@ discard block |
||
481 | 481 | * @since 9.0.0 |
482 | 482 | */ |
483 | 483 | public function save(IComment $comment) { |
484 | - if($this->prepareCommentForDatabaseWrite($comment)->getId() === '') { |
|
484 | + if ($this->prepareCommentForDatabaseWrite($comment)->getId() === '') { |
|
485 | 485 | $result = $this->insert($comment); |
486 | 486 | } else { |
487 | 487 | $result = $this->update($comment); |
488 | 488 | } |
489 | 489 | |
490 | - if($result && !!$comment->getParentId()) { |
|
490 | + if ($result && !!$comment->getParentId()) { |
|
491 | 491 | $this->updateChildrenInformation( |
492 | 492 | $comment->getParentId(), |
493 | 493 | $comment->getCreationDateTime() |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | * @param IComment $comment |
505 | 505 | * @return bool |
506 | 506 | */ |
507 | - protected function insert(IComment &$comment) { |
|
507 | + protected function insert(IComment & $comment) { |
|
508 | 508 | $qb = $this->dbConn->getQueryBuilder(); |
509 | 509 | $affectedRows = $qb |
510 | 510 | ->insert('comments') |
@@ -546,22 +546,22 @@ discard block |
||
546 | 546 | $qb = $this->dbConn->getQueryBuilder(); |
547 | 547 | $affectedRows = $qb |
548 | 548 | ->update('comments') |
549 | - ->set('parent_id', $qb->createNamedParameter($comment->getParentId())) |
|
550 | - ->set('topmost_parent_id', $qb->createNamedParameter($comment->getTopmostParentId())) |
|
551 | - ->set('children_count', $qb->createNamedParameter($comment->getChildrenCount())) |
|
552 | - ->set('actor_type', $qb->createNamedParameter($comment->getActorType())) |
|
553 | - ->set('actor_id', $qb->createNamedParameter($comment->getActorId())) |
|
554 | - ->set('message', $qb->createNamedParameter($comment->getMessage())) |
|
555 | - ->set('verb', $qb->createNamedParameter($comment->getVerb())) |
|
556 | - ->set('creation_timestamp', $qb->createNamedParameter($comment->getCreationDateTime(), 'datetime')) |
|
557 | - ->set('latest_child_timestamp', $qb->createNamedParameter($comment->getLatestChildDateTime(), 'datetime')) |
|
558 | - ->set('object_type', $qb->createNamedParameter($comment->getObjectType())) |
|
559 | - ->set('object_id', $qb->createNamedParameter($comment->getObjectId())) |
|
549 | + ->set('parent_id', $qb->createNamedParameter($comment->getParentId())) |
|
550 | + ->set('topmost_parent_id', $qb->createNamedParameter($comment->getTopmostParentId())) |
|
551 | + ->set('children_count', $qb->createNamedParameter($comment->getChildrenCount())) |
|
552 | + ->set('actor_type', $qb->createNamedParameter($comment->getActorType())) |
|
553 | + ->set('actor_id', $qb->createNamedParameter($comment->getActorId())) |
|
554 | + ->set('message', $qb->createNamedParameter($comment->getMessage())) |
|
555 | + ->set('verb', $qb->createNamedParameter($comment->getVerb())) |
|
556 | + ->set('creation_timestamp', $qb->createNamedParameter($comment->getCreationDateTime(), 'datetime')) |
|
557 | + ->set('latest_child_timestamp', $qb->createNamedParameter($comment->getLatestChildDateTime(), 'datetime')) |
|
558 | + ->set('object_type', $qb->createNamedParameter($comment->getObjectType())) |
|
559 | + ->set('object_id', $qb->createNamedParameter($comment->getObjectId())) |
|
560 | 560 | ->where($qb->expr()->eq('id', $qb->createParameter('id'))) |
561 | 561 | ->setParameter('id', $comment->getId()) |
562 | 562 | ->execute(); |
563 | 563 | |
564 | - if($affectedRows === 0) { |
|
564 | + if ($affectedRows === 0) { |
|
565 | 565 | throw new NotFoundException('Comment to update does ceased to exist'); |
566 | 566 | } |
567 | 567 | |
@@ -588,8 +588,8 @@ discard block |
||
588 | 588 | $qb = $this->dbConn->getQueryBuilder(); |
589 | 589 | $affectedRows = $qb |
590 | 590 | ->update('comments') |
591 | - ->set('actor_type', $qb->createNamedParameter(ICommentsManager::DELETED_USER)) |
|
592 | - ->set('actor_id', $qb->createNamedParameter(ICommentsManager::DELETED_USER)) |
|
591 | + ->set('actor_type', $qb->createNamedParameter(ICommentsManager::DELETED_USER)) |
|
592 | + ->set('actor_id', $qb->createNamedParameter(ICommentsManager::DELETED_USER)) |
|
593 | 593 | ->where($qb->expr()->eq('actor_type', $qb->createParameter('type'))) |
594 | 594 | ->andWhere($qb->expr()->eq('actor_id', $qb->createParameter('id'))) |
595 | 595 | ->setParameter('type', $actorType) |
@@ -672,10 +672,10 @@ discard block |
||
672 | 672 | // Strategy: try to update, if this does not return affected rows, do an insert. |
673 | 673 | $affectedRows = $qb |
674 | 674 | ->update('comments_read_markers') |
675 | - ->set('user_id', $values['user_id']) |
|
675 | + ->set('user_id', $values['user_id']) |
|
676 | 676 | ->set('marker_datetime', $values['marker_datetime']) |
677 | - ->set('object_type', $values['object_type']) |
|
678 | - ->set('object_id', $values['object_id']) |
|
677 | + ->set('object_type', $values['object_type']) |
|
678 | + ->set('object_id', $values['object_id']) |
|
679 | 679 | ->where($qb->expr()->eq('user_id', $qb->createParameter('user_id'))) |
680 | 680 | ->andWhere($qb->expr()->eq('object_type', $qb->createParameter('object_type'))) |
681 | 681 | ->andWhere($qb->expr()->eq('object_id', $qb->createParameter('object_id'))) |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | |
719 | 719 | $data = $resultStatement->fetch(); |
720 | 720 | $resultStatement->closeCursor(); |
721 | - if(!$data || is_null($data['marker_datetime'])) { |
|
721 | + if (!$data || is_null($data['marker_datetime'])) { |
|
722 | 722 | return null; |
723 | 723 | } |
724 | 724 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * the comments database scheme |
52 | 52 | */ |
53 | 53 | public function __construct(array $data = null) { |
54 | - if(is_array($data)) { |
|
54 | + if (is_array($data)) { |
|
55 | 55 | $this->fromArray($data); |
56 | 56 | } |
57 | 57 | } |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | * @since 9.0.0 |
85 | 85 | */ |
86 | 86 | public function setId($id) { |
87 | - if(!is_string($id)) { |
|
87 | + if (!is_string($id)) { |
|
88 | 88 | throw new \InvalidArgumentException('String expected.'); |
89 | 89 | } |
90 | 90 | |
91 | 91 | $id = trim($id); |
92 | - if($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) { |
|
92 | + if ($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) { |
|
93 | 93 | $this->data['id'] = $id; |
94 | 94 | return $this; |
95 | 95 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @since 9.0.0 |
116 | 116 | */ |
117 | 117 | public function setParentId($parentId) { |
118 | - if(!is_string($parentId)) { |
|
118 | + if (!is_string($parentId)) { |
|
119 | 119 | throw new \InvalidArgumentException('String expected.'); |
120 | 120 | } |
121 | 121 | $this->data['parentId'] = trim($parentId); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @since 9.0.0 |
142 | 142 | */ |
143 | 143 | public function setTopmostParentId($id) { |
144 | - if(!is_string($id)) { |
|
144 | + if (!is_string($id)) { |
|
145 | 145 | throw new \InvalidArgumentException('String expected.'); |
146 | 146 | } |
147 | 147 | $this->data['topmostParentId'] = trim($id); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @since 9.0.0 |
167 | 167 | */ |
168 | 168 | public function setChildrenCount($count) { |
169 | - if(!is_int($count)) { |
|
169 | + if (!is_int($count)) { |
|
170 | 170 | throw new \InvalidArgumentException('Integer expected.'); |
171 | 171 | } |
172 | 172 | $this->data['childrenCount'] = $count; |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | * @since 9.0.0 |
193 | 193 | */ |
194 | 194 | public function setMessage($message) { |
195 | - if(!is_string($message)) { |
|
195 | + if (!is_string($message)) { |
|
196 | 196 | throw new \InvalidArgumentException('String expected.'); |
197 | 197 | } |
198 | 198 | $message = trim($message); |
199 | - if(mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) { |
|
200 | - throw new MessageTooLongException('Comment message must not exceed ' . IComment::MAX_MESSAGE_LENGTH . ' characters'); |
|
199 | + if (mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) { |
|
200 | + throw new MessageTooLongException('Comment message must not exceed '.IComment::MAX_MESSAGE_LENGTH.' characters'); |
|
201 | 201 | } |
202 | 202 | $this->data['message'] = $message; |
203 | 203 | return $this; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @since 9.0.0 |
222 | 222 | */ |
223 | 223 | public function setVerb($verb) { |
224 | - if(!is_string($verb) || !trim($verb)) { |
|
224 | + if (!is_string($verb) || !trim($verb)) { |
|
225 | 225 | throw new \InvalidArgumentException('Non-empty String expected.'); |
226 | 226 | } |
227 | 227 | $this->data['verb'] = trim($verb); |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | * @since 9.0.0 |
258 | 258 | */ |
259 | 259 | public function setActor($actorType, $actorId) { |
260 | - if( |
|
260 | + if ( |
|
261 | 261 | !is_string($actorType) || !trim($actorType) |
262 | - || !is_string($actorId) || !trim($actorId) |
|
262 | + || !is_string($actorId) || !trim($actorId) |
|
263 | 263 | ) { |
264 | 264 | throw new \InvalidArgumentException('String expected.'); |
265 | 265 | } |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | * @since 9.0.0 |
344 | 344 | */ |
345 | 345 | public function setObject($objectType, $objectId) { |
346 | - if( |
|
346 | + if ( |
|
347 | 347 | !is_string($objectType) || !trim($objectType) |
348 | - || !is_string($objectId) || !trim($objectId) |
|
348 | + || !is_string($objectId) || !trim($objectId) |
|
349 | 349 | ) { |
350 | 350 | throw new \InvalidArgumentException('String expected.'); |
351 | 351 | } |
@@ -362,20 +362,20 @@ discard block |
||
362 | 362 | * @return IComment |
363 | 363 | */ |
364 | 364 | protected function fromArray($data) { |
365 | - foreach(array_keys($data) as $key) { |
|
365 | + foreach (array_keys($data) as $key) { |
|
366 | 366 | // translate DB keys to internal setter names |
367 | - $setter = 'set' . implode('', array_map('ucfirst', explode('_', $key))); |
|
367 | + $setter = 'set'.implode('', array_map('ucfirst', explode('_', $key))); |
|
368 | 368 | $setter = str_replace('Timestamp', 'DateTime', $setter); |
369 | 369 | |
370 | - if(method_exists($this, $setter)) { |
|
370 | + if (method_exists($this, $setter)) { |
|
371 | 371 | $this->$setter($data[$key]); |
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | - foreach(['actor', 'object'] as $role) { |
|
376 | - if(isset($data[$role . '_type']) && isset($data[$role . '_id'])) { |
|
377 | - $setter = 'set' . ucfirst($role); |
|
378 | - $this->$setter($data[$role . '_type'], $data[$role . '_id']); |
|
375 | + foreach (['actor', 'object'] as $role) { |
|
376 | + if (isset($data[$role.'_type']) && isset($data[$role.'_id'])) { |
|
377 | + $setter = 'set'.ucfirst($role); |
|
378 | + $this->$setter($data[$role.'_type'], $data[$role.'_id']); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | ->execute(); |
120 | 120 | |
121 | 121 | $groups = []; |
122 | - while($row = $result->fetch()) { |
|
122 | + while ($row = $result->fetch()) { |
|
123 | 123 | $group = $this->groupManager->get($row['gid']); |
124 | - if(!is_null($group)) { |
|
124 | + if (!is_null($group)) { |
|
125 | 125 | $groups[] = $group; |
126 | 126 | } |
127 | 127 | } |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | ->execute(); |
145 | 145 | |
146 | 146 | $users = []; |
147 | - while($row = $result->fetch()) { |
|
147 | + while ($row = $result->fetch()) { |
|
148 | 148 | $user = $this->userManager->get($row['uid']); |
149 | - if(!is_null($user)) { |
|
149 | + if (!is_null($user)) { |
|
150 | 150 | $users[] = $user; |
151 | 151 | } |
152 | 152 | } |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | ->execute(); |
168 | 168 | |
169 | 169 | $subadmins = []; |
170 | - while($row = $result->fetch()) { |
|
170 | + while ($row = $result->fetch()) { |
|
171 | 171 | $user = $this->userManager->get($row['uid']); |
172 | 172 | $group = $this->groupManager->get($row['gid']); |
173 | - if(!is_null($user) && !is_null($group)) { |
|
173 | + if (!is_null($user) && !is_null($group)) { |
|
174 | 174 | $subadmins[] = [ |
175 | 175 | 'user' => $user, |
176 | 176 | 'group' => $group |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID()))) |
201 | 201 | ->execute(); |
202 | 202 | |
203 | - $fetch = $result->fetch(); |
|
203 | + $fetch = $result->fetch(); |
|
204 | 204 | $result->closeCursor(); |
205 | 205 | $result = !empty($fetch) ? true : false; |
206 | 206 | |
@@ -241,15 +241,15 @@ discard block |
||
241 | 241 | * @return bool |
242 | 242 | */ |
243 | 243 | public function isUserAccessible($subadmin, $user) { |
244 | - if(!$this->isSubAdmin($subadmin)) { |
|
244 | + if (!$this->isSubAdmin($subadmin)) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | - if($this->groupManager->isAdmin($user->getUID())) { |
|
247 | + if ($this->groupManager->isAdmin($user->getUID())) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | $accessibleGroups = $this->getSubAdminsGroups($subadmin); |
251 | - foreach($accessibleGroups as $accessibleGroup) { |
|
252 | - if($accessibleGroup->inGroup($user)) { |
|
251 | + foreach ($accessibleGroups as $accessibleGroup) { |
|
252 | + if ($accessibleGroup->inGroup($user)) { |
|
253 | 253 | return true; |
254 | 254 | } |
255 | 255 | } |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | * Class OC_JSON |
34 | 34 | * @deprecated Use a AppFramework JSONResponse instead |
35 | 35 | */ |
36 | -class OC_JSON{ |
|
36 | +class OC_JSON { |
|
37 | 37 | static protected $send_content_type_header = false; |
38 | 38 | /** |
39 | 39 | * set Content-Type header to jsonrequest |
40 | 40 | * @deprecated Use a AppFramework JSONResponse instead |
41 | 41 | */ |
42 | - public static function setContentTypeHeader($type='application/json') { |
|
42 | + public static function setContentTypeHeader($type = 'application/json') { |
|
43 | 43 | if (!self::$send_content_type_header) { |
44 | 44 | // We send json data |
45 | - header( 'Content-Type: '.$type . '; charset=utf-8'); |
|
45 | + header('Content-Type: '.$type.'; charset=utf-8'); |
|
46 | 46 | self::$send_content_type_header = true; |
47 | 47 | } |
48 | 48 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled. |
54 | 54 | */ |
55 | 55 | public static function checkAppEnabled($app) { |
56 | - if( !OC_App::isEnabled($app)) { |
|
56 | + if (!OC_App::isEnabled($app)) { |
|
57 | 57 | $l = \OC::$server->getL10N('lib'); |
58 | - self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ))); |
|
58 | + self::error(array('data' => array('message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled'))); |
|
59 | 59 | exit(); |
60 | 60 | } |
61 | 61 | } |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | * @deprecated Use annotation based ACLs from the AppFramework instead |
66 | 66 | */ |
67 | 67 | public static function checkLoggedIn() { |
68 | - if( !OC_User::isLoggedIn()) { |
|
68 | + if (!OC_User::isLoggedIn()) { |
|
69 | 69 | $l = \OC::$server->getL10N('lib'); |
70 | 70 | http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED); |
71 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
71 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
72 | 72 | exit(); |
73 | 73 | } |
74 | 74 | } |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * @deprecated Use annotation based CSRF checks from the AppFramework instead |
79 | 79 | */ |
80 | 80 | public static function callCheck() { |
81 | - if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
81 | + if (!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
82 | 82 | header('Location: '.\OC::$WEBROOT); |
83 | 83 | exit(); |
84 | 84 | } |
85 | 85 | |
86 | - if( !(\OC::$server->getRequest()->passesCSRFCheck())) { |
|
86 | + if (!(\OC::$server->getRequest()->passesCSRFCheck())) { |
|
87 | 87 | $l = \OC::$server->getL10N('lib'); |
88 | - self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ))); |
|
88 | + self::error(array('data' => array('message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired'))); |
|
89 | 89 | exit(); |
90 | 90 | } |
91 | 91 | } |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @deprecated Use annotation based ACLs from the AppFramework instead |
96 | 96 | */ |
97 | 97 | public static function checkAdminUser() { |
98 | - if( !OC_User::isAdminUser(OC_User::getUser())) { |
|
98 | + if (!OC_User::isAdminUser(OC_User::getUser())) { |
|
99 | 99 | $l = \OC::$server->getL10N('lib'); |
100 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
100 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
101 | 101 | exit(); |
102 | 102 | } |
103 | 103 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | public static function checkUserExists($user) { |
111 | 111 | if (!OCP\User::userExists($user)) { |
112 | 112 | $l = \OC::$server->getL10N('lib'); |
113 | - OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' ))); |
|
113 | + OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user'))); |
|
114 | 114 | exit; |
115 | 115 | } |
116 | 116 | } |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | public static function checkSubAdminUser() { |
124 | 124 | $userObject = \OC::$server->getUserSession()->getUser(); |
125 | 125 | $isSubAdmin = false; |
126 | - if($userObject !== null) { |
|
126 | + if ($userObject !== null) { |
|
127 | 127 | $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
128 | 128 | } |
129 | 129 | |
130 | - if(!$isSubAdmin) { |
|
130 | + if (!$isSubAdmin) { |
|
131 | 131 | $l = \OC::$server->getL10N('lib'); |
132 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
132 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
133 | 133 | exit(); |
134 | 134 | } |
135 | 135 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected static function to_string(&$value) { |
159 | 159 | if ($value instanceof OC_L10N_String) { |
160 | - $value = (string)$value; |
|
160 | + $value = (string) $value; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * Encode and print $data in json format |
166 | 166 | * @deprecated Use a AppFramework JSONResponse instead |
167 | 167 | */ |
168 | - public static function encodedPrint($data, $setContentType=true) { |
|
169 | - if($setContentType) { |
|
168 | + public static function encodedPrint($data, $setContentType = true) { |
|
169 | + if ($setContentType) { |
|
170 | 170 | self::setContentTypeHeader(); |
171 | 171 | } |
172 | 172 | echo self::encode($data); |