@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | if (!is_array($files)) { |
118 | - $filename = $dir . '/' . $files; |
|
118 | + $filename = $dir.'/'.$files; |
|
119 | 119 | if (!$view->is_dir($filename)) { |
120 | 120 | self::getSingleFile($view, $dir, $files, is_null($params) ? array() : $params); |
121 | 121 | return; |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | $name = $basename; |
131 | 131 | } |
132 | 132 | |
133 | - $filename = $dir . '/' . $name; |
|
133 | + $filename = $dir.'/'.$name; |
|
134 | 134 | } else { |
135 | - $filename = $dir . '/' . $files; |
|
135 | + $filename = $dir.'/'.$files; |
|
136 | 136 | $getType = self::ZIP_DIR; |
137 | 137 | // downloading root ? |
138 | 138 | if ($files !== '') { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ignore_user_abort(true); |
152 | 152 | if ($getType === self::ZIP_FILES) { |
153 | 153 | foreach ($files as $file) { |
154 | - $file = $dir . '/' . $file; |
|
154 | + $file = $dir.'/'.$file; |
|
155 | 155 | if (\OC\Files\Filesystem::is_file($file)) { |
156 | 156 | $fileSize = \OC\Files\Filesystem::filesize($file); |
157 | 157 | $fileTime = \OC\Files\Filesystem::filemtime($file); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | } |
165 | 165 | } elseif ($getType === self::ZIP_DIR) { |
166 | - $file = $dir . '/' . $files; |
|
166 | + $file = $dir.'/'.$files; |
|
167 | 167 | $streamer->addDirRecursive($file); |
168 | 168 | } |
169 | 169 | $streamer->finalize(); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return array $rangeArray ('from'=>int,'to'=>int), ... |
196 | 196 | */ |
197 | 197 | private static function parseHttpRangeHeader($rangeHeaderPos, $fileSize) { |
198 | - $rArray=explode(',', $rangeHeaderPos); |
|
198 | + $rArray = explode(',', $rangeHeaderPos); |
|
199 | 199 | $minOffset = 0; |
200 | 200 | $ind = 0; |
201 | 201 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | if ($ranges[0] < $minOffset) { // case: bytes=500-700,601-999 |
208 | 208 | $ranges[0] = $minOffset; |
209 | 209 | } |
210 | - if ($ind > 0 && $rangeArray[$ind-1]['to']+1 == $ranges[0]) { // case: bytes=500-600,601-999 |
|
210 | + if ($ind > 0 && $rangeArray[$ind - 1]['to'] + 1 == $ranges[0]) { // case: bytes=500-600,601-999 |
|
211 | 211 | $ind--; |
212 | 212 | $ranges[0] = $rangeArray[$ind]['from']; |
213 | 213 | } |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | if (is_numeric($ranges[0]) && is_numeric($ranges[1]) && $ranges[0] < $fileSize && $ranges[0] <= $ranges[1]) { |
217 | 217 | // case: x-x |
218 | 218 | if ($ranges[1] >= $fileSize) { |
219 | - $ranges[1] = $fileSize-1; |
|
219 | + $ranges[1] = $fileSize - 1; |
|
220 | 220 | } |
221 | - $rangeArray[$ind++] = array( 'from' => $ranges[0], 'to' => $ranges[1], 'size' => $fileSize ); |
|
221 | + $rangeArray[$ind++] = array('from' => $ranges[0], 'to' => $ranges[1], 'size' => $fileSize); |
|
222 | 222 | $minOffset = $ranges[1] + 1; |
223 | 223 | if ($minOffset >= $fileSize) { |
224 | 224 | break; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | elseif (is_numeric($ranges[0]) && $ranges[0] < $fileSize) { |
228 | 228 | // case: x- |
229 | - $rangeArray[$ind++] = array( 'from' => $ranges[0], 'to' => $fileSize-1, 'size' => $fileSize ); |
|
229 | + $rangeArray[$ind++] = array('from' => $ranges[0], 'to' => $fileSize - 1, 'size' => $fileSize); |
|
230 | 230 | break; |
231 | 231 | } |
232 | 232 | elseif (is_numeric($ranges[1])) { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | if ($ranges[1] > $fileSize) { |
235 | 235 | $ranges[1] = $fileSize; |
236 | 236 | } |
237 | - $rangeArray[$ind++] = array( 'from' => $fileSize-$ranges[1], 'to' => $fileSize-1, 'size' => $fileSize ); |
|
237 | + $rangeArray[$ind++] = array('from' => $fileSize - $ranges[1], 'to' => $fileSize - 1, 'size' => $fileSize); |
|
238 | 238 | break; |
239 | 239 | } |
240 | 240 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param array $params ; 'head' boolean to only send header of the request ; 'range' http range header |
249 | 249 | */ |
250 | 250 | private static function getSingleFile($view, $dir, $name, $params) { |
251 | - $filename = $dir . '/' . $name; |
|
251 | + $filename = $dir.'/'.$name; |
|
252 | 252 | OC_Util::obEnd(); |
253 | 253 | $view->lockFile($filename, ILockingProvider::LOCK_SHARED); |
254 | 254 | |
@@ -314,17 +314,17 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public static function lockFiles($view, $dir, $files) { |
316 | 316 | if (!is_array($files)) { |
317 | - $file = $dir . '/' . $files; |
|
317 | + $file = $dir.'/'.$files; |
|
318 | 318 | $files = [$file]; |
319 | 319 | } |
320 | 320 | foreach ($files as $file) { |
321 | - $file = $dir . '/' . $file; |
|
321 | + $file = $dir.'/'.$file; |
|
322 | 322 | $view->lockFile($file, ILockingProvider::LOCK_SHARED); |
323 | 323 | if ($view->is_dir($file)) { |
324 | 324 | $contents = $view->getDirectoryContent($file); |
325 | 325 | $contents = array_map(function($fileInfo) use ($file) { |
326 | 326 | /** @var \OCP\Files\FileInfo $fileInfo */ |
327 | - return $file . '/' . $fileInfo->getName(); |
|
327 | + return $file.'/'.$fileInfo->getName(); |
|
328 | 328 | }, $contents); |
329 | 329 | self::lockFiles($view, $dir, $contents); |
330 | 330 | } |
@@ -353,8 +353,8 @@ discard block |
||
353 | 353 | |
354 | 354 | // default locations if not overridden by $files |
355 | 355 | $files = array_merge([ |
356 | - '.htaccess' => OC::$SERVERROOT . '/.htaccess', |
|
357 | - '.user.ini' => OC::$SERVERROOT . '/.user.ini' |
|
356 | + '.htaccess' => OC::$SERVERROOT.'/.htaccess', |
|
357 | + '.user.ini' => OC::$SERVERROOT.'/.user.ini' |
|
358 | 358 | ], $files); |
359 | 359 | |
360 | 360 | $updateFiles = [ |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $handle = @fopen($filename, 'r+'); |
376 | 376 | if (!$handle) { |
377 | 377 | \OCP\Util::writeLog('files', |
378 | - 'Can\'t write upload limit to ' . $filename . '. Please check the file permissions', |
|
378 | + 'Can\'t write upload limit to '.$filename.'. Please check the file permissions', |
|
379 | 379 | \OCP\Util::WARN); |
380 | 380 | $success = false; |
381 | 381 | continue; // try to update as many files as possible |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $content = $newContent; |
396 | 396 | } |
397 | 397 | if ($hasReplaced === 0) { |
398 | - $content .= "\n" . $setting; |
|
398 | + $content .= "\n".$setting; |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | } |
427 | 427 | if ($getType === self::ZIP_FILES) { |
428 | 428 | foreach ($files as $file) { |
429 | - $file = $dir . '/' . $file; |
|
429 | + $file = $dir.'/'.$file; |
|
430 | 430 | $view->unlockFile($file, ILockingProvider::LOCK_SHARED); |
431 | 431 | } |
432 | 432 | } |
433 | 433 | if ($getType === self::ZIP_DIR) { |
434 | - $file = $dir . '/' . $files; |
|
434 | + $file = $dir.'/'.$files; |
|
435 | 435 | $view->unlockFile($file, ILockingProvider::LOCK_SHARED); |
436 | 436 | } |
437 | 437 | } |
@@ -56,13 +56,13 @@ |
||
56 | 56 | $translations = $this->l10n->getTranslations(); |
57 | 57 | |
58 | 58 | $text = $this->text; |
59 | - if(array_key_exists($this->text, $translations)) { |
|
60 | - if(is_array($translations[$this->text])) { |
|
59 | + if (array_key_exists($this->text, $translations)) { |
|
60 | + if (is_array($translations[$this->text])) { |
|
61 | 61 | $fn = $this->l10n->getPluralFormFunction(); |
62 | 62 | $id = $fn($this->count); |
63 | 63 | $text = $translations[$this->text][$id]; |
64 | 64 | } |
65 | - else{ |
|
65 | + else { |
|
66 | 66 | $text = $translations[$this->text]; |
67 | 67 | } |
68 | 68 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | public function isComplete() { |
86 | 86 | $prefix = $this->getPrefix(); |
87 | 87 | $cache = $this->getCache(); |
88 | - $chunkcount = (int)$this->info['chunkcount']; |
|
88 | + $chunkcount = (int) $this->info['chunkcount']; |
|
89 | 89 | |
90 | - for($i=($chunkcount-1); $i >= 0; $i--) { |
|
90 | + for ($i = ($chunkcount - 1); $i >= 0; $i--) { |
|
91 | 91 | if (!$cache->hasKey($prefix.$i)) { |
92 | 92 | return false; |
93 | 93 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | public function cleanup() { |
144 | 144 | $cache = $this->getCache(); |
145 | 145 | $prefix = $this->getPrefix(); |
146 | - for($i=0; $i < $this->info['chunkcount']; $i++) { |
|
146 | + for ($i = 0; $i < $this->info['chunkcount']; $i++) { |
|
147 | 147 | $cache->remove($prefix.$i); |
148 | 148 | } |
149 | 149 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * "admin". |
70 | 70 | * @param bool $registerCall = true |
71 | 71 | */ |
72 | - public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
72 | + public function __construct($app, $name, $renderAs = "", $registerCall = true) { |
|
73 | 73 | // Read the selected theme from the config file |
74 | 74 | self::initTemplateEngine($renderAs); |
75 | 75 | |
@@ -95,30 +95,30 @@ discard block |
||
95 | 95 | * @param string $renderAs |
96 | 96 | */ |
97 | 97 | public static function initTemplateEngine($renderAs) { |
98 | - if (self::$initTemplateEngineFirstRun){ |
|
98 | + if (self::$initTemplateEngineFirstRun) { |
|
99 | 99 | |
100 | 100 | //apps that started before the template initialization can load their own scripts/styles |
101 | 101 | //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
102 | 102 | //meaning the last script/style in this list will be loaded first |
103 | - if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
104 | - if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
105 | - OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
103 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
104 | + if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { |
|
105 | + OC_Util::addScript('backgroundjobs', null, true); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - OC_Util::addStyle("tooltip",null,true); |
|
110 | - OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
111 | - OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true); |
|
112 | - OC_Util::addStyle("mobile",null,true); |
|
113 | - OC_Util::addStyle("multiselect",null,true); |
|
114 | - OC_Util::addStyle("fixes",null,true); |
|
115 | - OC_Util::addStyle("global",null,true); |
|
116 | - OC_Util::addStyle("apps",null,true); |
|
117 | - OC_Util::addStyle("fonts",null,true); |
|
118 | - OC_Util::addStyle("icons",null,true); |
|
119 | - OC_Util::addStyle("header",null,true); |
|
109 | + OC_Util::addStyle("tooltip", null, true); |
|
110 | + OC_Util::addStyle('jquery-ui-fixes', null, true); |
|
111 | + OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui', null, true); |
|
112 | + OC_Util::addStyle("mobile", null, true); |
|
113 | + OC_Util::addStyle("multiselect", null, true); |
|
114 | + OC_Util::addStyle("fixes", null, true); |
|
115 | + OC_Util::addStyle("global", null, true); |
|
116 | + OC_Util::addStyle("apps", null, true); |
|
117 | + OC_Util::addStyle("fonts", null, true); |
|
118 | + OC_Util::addStyle("icons", null, true); |
|
119 | + OC_Util::addStyle("header", null, true); |
|
120 | 120 | OC_Util::addStyle("inputs"); |
121 | - OC_Util::addStyle("styles",null,true); |
|
121 | + OC_Util::addStyle("styles", null, true); |
|
122 | 122 | |
123 | 123 | // avatars |
124 | 124 | \OC_Util::addScript('jquery.avatar', null, true); |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | // Add the stuff we need always |
154 | 154 | // following logic will import all vendor libraries that are |
155 | 155 | // specified in core/js/core.json |
156 | - $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); |
|
157 | - if($fileContent !== false) { |
|
156 | + $fileContent = file_get_contents(OC::$SERVERROOT.'/core/js/core.json'); |
|
157 | + if ($fileContent !== false) { |
|
158 | 158 | $coreDependencies = json_decode($fileContent, true); |
159 | - foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
159 | + foreach (array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
160 | 160 | // remove trailing ".js" as addVendorScript will append it |
161 | 161 | OC_Util::addVendorScript( |
162 | - substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true); |
|
162 | + substr($vendorLibrary, 0, strlen($vendorLibrary) - 3), null, true); |
|
163 | 163 | } |
164 | 164 | } else { |
165 | 165 | throw new \Exception('Cannot read core/js/core.json'); |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | */ |
191 | 191 | protected function findTemplate($theme, $app, $name) { |
192 | 192 | // Check if it is a app template or not. |
193 | - if( $app !== '' ) { |
|
193 | + if ($app !== '') { |
|
194 | 194 | $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
195 | 195 | } else { |
196 | 196 | $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
197 | 197 | } |
198 | - $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
198 | + $locator = new \OC\Template\TemplateFileLocator($dirs); |
|
199 | 199 | $template = $locator->find($name); |
200 | 200 | $path = $locator->getPath(); |
201 | 201 | return array($path, $template); |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param string $text the text content for the element. If $text is null then the |
209 | 209 | * element will be written as empty element. So use "" to get a closing tag. |
210 | 210 | */ |
211 | - public function addHeader($tag, $attributes, $text=null) { |
|
212 | - $this->headers[]= array( |
|
211 | + public function addHeader($tag, $attributes, $text = null) { |
|
212 | + $this->headers[] = array( |
|
213 | 213 | 'tag' => $tag, |
214 | 214 | 'attributes' => $attributes, |
215 | 215 | 'text' => $text |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | public function fetchPage($additionalParams = null) { |
227 | 227 | $data = parent::fetchPage($additionalParams); |
228 | 228 | |
229 | - if( $this->renderAs ) { |
|
229 | + if ($this->renderAs) { |
|
230 | 230 | $page = new TemplateLayout($this->renderAs, $this->app); |
231 | 231 | |
232 | 232 | // Add custom headers |
233 | 233 | $headers = ''; |
234 | - foreach(OC_Util::$headers as $header) { |
|
234 | + foreach (OC_Util::$headers as $header) { |
|
235 | 235 | $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
236 | - foreach($header['attributes'] as $name=>$value) { |
|
236 | + foreach ($header['attributes'] as $name=>$value) { |
|
237 | 237 | $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
238 | 238 | } |
239 | 239 | if ($header['text'] !== null) { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * Includes another template. use <?php echo $this->inc('template'); ?> to |
263 | 263 | * do this. |
264 | 264 | */ |
265 | - public function inc( $file, $additionalParams = null ) { |
|
265 | + public function inc($file, $additionalParams = null) { |
|
266 | 266 | return $this->load($this->path.$file.'.php', $additionalParams); |
267 | 267 | } |
268 | 268 | |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | * @param array $parameters Parameters for the template |
274 | 274 | * @return boolean|null |
275 | 275 | */ |
276 | - public static function printUserPage( $application, $name, $parameters = array() ) { |
|
277 | - $content = new OC_Template( $application, $name, "user" ); |
|
278 | - foreach( $parameters as $key => $value ) { |
|
279 | - $content->assign( $key, $value ); |
|
276 | + public static function printUserPage($application, $name, $parameters = array()) { |
|
277 | + $content = new OC_Template($application, $name, "user"); |
|
278 | + foreach ($parameters as $key => $value) { |
|
279 | + $content->assign($key, $value); |
|
280 | 280 | } |
281 | 281 | print $content->printPage(); |
282 | 282 | } |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param array $parameters Parameters for the template |
289 | 289 | * @return bool |
290 | 290 | */ |
291 | - public static function printAdminPage( $application, $name, $parameters = array() ) { |
|
292 | - $content = new OC_Template( $application, $name, "admin" ); |
|
293 | - foreach( $parameters as $key => $value ) { |
|
294 | - $content->assign( $key, $value ); |
|
291 | + public static function printAdminPage($application, $name, $parameters = array()) { |
|
292 | + $content = new OC_Template($application, $name, "admin"); |
|
293 | + foreach ($parameters as $key => $value) { |
|
294 | + $content->assign($key, $value); |
|
295 | 295 | } |
296 | 296 | return $content->printPage(); |
297 | 297 | } |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | * @param array|string $parameters Parameters for the template |
304 | 304 | * @return bool |
305 | 305 | */ |
306 | - public static function printGuestPage( $application, $name, $parameters = array() ) { |
|
307 | - $content = new OC_Template( $application, $name, "guest" ); |
|
308 | - foreach( $parameters as $key => $value ) { |
|
309 | - $content->assign( $key, $value ); |
|
306 | + public static function printGuestPage($application, $name, $parameters = array()) { |
|
307 | + $content = new OC_Template($application, $name, "guest"); |
|
308 | + foreach ($parameters as $key => $value) { |
|
309 | + $content->assign($key, $value); |
|
310 | 310 | } |
311 | 311 | return $content->printPage(); |
312 | 312 | } |
@@ -316,23 +316,23 @@ discard block |
||
316 | 316 | * @param string $error_msg The error message to show |
317 | 317 | * @param string $hint An optional hint message - needs to be properly escaped |
318 | 318 | */ |
319 | - public static function printErrorPage( $error_msg, $hint = '' ) { |
|
319 | + public static function printErrorPage($error_msg, $hint = '') { |
|
320 | 320 | if ($error_msg === $hint) { |
321 | 321 | // If the hint is the same as the message there is no need to display it twice. |
322 | 322 | $hint = ''; |
323 | 323 | } |
324 | 324 | |
325 | 325 | try { |
326 | - $content = new \OC_Template( '', 'error', 'error', false ); |
|
326 | + $content = new \OC_Template('', 'error', 'error', false); |
|
327 | 327 | $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
328 | - $content->assign( 'errors', $errors ); |
|
328 | + $content->assign('errors', $errors); |
|
329 | 329 | $content->printPage(); |
330 | 330 | } catch (\Exception $e) { |
331 | 331 | $logger = \OC::$server->getLogger(); |
332 | 332 | $logger->error("$error_msg $hint", ['app' => 'core']); |
333 | 333 | $logger->logException($e, ['app' => 'core']); |
334 | 334 | |
335 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
335 | + header(self::getHttpProtocol().' 500 Internal Server Error'); |
|
336 | 336 | header('Content-Type: text/plain; charset=utf-8'); |
337 | 337 | print("$error_msg $hint"); |
338 | 338 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $logger->logException($exception, ['app' => 'core']); |
366 | 366 | $logger->logException($e, ['app' => 'core']); |
367 | 367 | |
368 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
368 | + header(self::getHttpProtocol().' 500 Internal Server Error'); |
|
369 | 369 | header('Content-Type: text/plain; charset=utf-8'); |
370 | 370 | print("Internal Server Error\n\n"); |
371 | 371 | print("The server encountered an internal error and was unable to complete your request.\n"); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | 'HTTP/1.1', |
392 | 392 | 'HTTP/2', |
393 | 393 | ]; |
394 | - if(in_array($claimedProtocol, $validProtocols, true)) { |
|
394 | + if (in_array($claimedProtocol, $validProtocols, true)) { |
|
395 | 395 | return $claimedProtocol; |
396 | 396 | } |
397 | 397 | return 'HTTP/1.1'; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $requirements = array()) { |
93 | 93 | $name = strtolower($method).$url; |
94 | 94 | $name = str_replace(array('/', '{', '}'), '_', $name); |
95 | - if(!isset(self::$actions[$name])) { |
|
95 | + if (!isset(self::$actions[$name])) { |
|
96 | 96 | $oldCollection = OC::$server->getRouter()->getCurrentCollection(); |
97 | 97 | OC::$server->getRouter()->useCollection('ocs'); |
98 | 98 | OC::$server->getRouter()->create($name, $url) |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | $method = $request->getMethod(); |
116 | 116 | |
117 | 117 | // Prepare the request variables |
118 | - if($method === 'PUT') { |
|
118 | + if ($method === 'PUT') { |
|
119 | 119 | $parameters['_put'] = $request->getParams(); |
120 | - } else if($method === 'DELETE') { |
|
120 | + } else if ($method === 'DELETE') { |
|
121 | 121 | $parameters['_delete'] = $request->getParams(); |
122 | 122 | } |
123 | 123 | $name = $parameters['_route']; |
124 | 124 | // Foreach registered action |
125 | 125 | $responses = array(); |
126 | - foreach(self::$actions[$name] as $action) { |
|
126 | + foreach (self::$actions[$name] as $action) { |
|
127 | 127 | // Check authentication and availability |
128 | - if(!self::isAuthorised($action)) { |
|
128 | + if (!self::isAuthorised($action)) { |
|
129 | 129 | $responses[] = array( |
130 | 130 | 'app' => $action['app'], |
131 | 131 | 'response' => new OC_OCS_Result(null, API::RESPOND_UNAUTHORISED, 'Unauthorised'), |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ); |
134 | 134 | continue; |
135 | 135 | } |
136 | - if(!is_callable($action['action'])) { |
|
136 | + if (!is_callable($action['action'])) { |
|
137 | 137 | $responses[] = array( |
138 | 138 | 'app' => $action['app'], |
139 | 139 | 'response' => new OC_OCS_Result(null, API::RESPOND_NOT_FOUND, 'Api method not found'), |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | 'failed' => array(), |
174 | 174 | ); |
175 | 175 | |
176 | - foreach($responses as $response) { |
|
177 | - if($response['shipped'] || ($response['app'] === 'core')) { |
|
178 | - if($response['response']->succeeded()) { |
|
176 | + foreach ($responses as $response) { |
|
177 | + if ($response['shipped'] || ($response['app'] === 'core')) { |
|
178 | + if ($response['response']->succeeded()) { |
|
179 | 179 | $shipped['succeeded'][$response['app']] = $response; |
180 | 180 | } else { |
181 | 181 | $shipped['failed'][$response['app']] = $response; |
182 | 182 | } |
183 | 183 | } else { |
184 | - if($response['response']->succeeded()) { |
|
184 | + if ($response['response']->succeeded()) { |
|
185 | 185 | $thirdparty['succeeded'][$response['app']] = $response; |
186 | 186 | } else { |
187 | 187 | $thirdparty['failed'][$response['app']] = $response; |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | // Remove any error responses if there is one shipped response that succeeded |
193 | - if(!empty($shipped['failed'])) { |
|
193 | + if (!empty($shipped['failed'])) { |
|
194 | 194 | // Which shipped response do we use if they all failed? |
195 | 195 | // They may have failed for different reasons (different status codes) |
196 | 196 | // Which response code should we return? |
197 | 197 | // Maybe any that are not \OCP\API::RESPOND_SERVER_ERROR |
198 | 198 | // Merge failed responses if more than one |
199 | 199 | $data = array(); |
200 | - foreach($shipped['failed'] as $failure) { |
|
200 | + foreach ($shipped['failed'] as $failure) { |
|
201 | 201 | $data = array_merge_recursive($data, $failure['response']->getData()); |
202 | 202 | } |
203 | 203 | $picked = reset($shipped['failed']); |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | $headers = $picked['response']->getHeaders(); |
207 | 207 | $response = new OC_OCS_Result($data, $code, $meta['message'], $headers); |
208 | 208 | return $response; |
209 | - } elseif(!empty($shipped['succeeded'])) { |
|
209 | + } elseif (!empty($shipped['succeeded'])) { |
|
210 | 210 | $responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']); |
211 | - } elseif(!empty($thirdparty['failed'])) { |
|
211 | + } elseif (!empty($thirdparty['failed'])) { |
|
212 | 212 | // Merge failed responses if more than one |
213 | 213 | $data = array(); |
214 | - foreach($thirdparty['failed'] as $failure) { |
|
214 | + foreach ($thirdparty['failed'] as $failure) { |
|
215 | 215 | $data = array_merge_recursive($data, $failure['response']->getData()); |
216 | 216 | } |
217 | 217 | $picked = reset($thirdparty['failed']); |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | $codes = []; |
229 | 229 | $header = []; |
230 | 230 | |
231 | - foreach($responses as $response) { |
|
232 | - if($response['shipped']) { |
|
231 | + foreach ($responses as $response) { |
|
232 | + if ($response['shipped']) { |
|
233 | 233 | $data = array_merge_recursive($response['response']->getData(), $data); |
234 | 234 | } else { |
235 | 235 | $data = array_merge_recursive($data, $response['response']->getData()); |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | // Use any non 100 status codes |
243 | 243 | $statusCode = 100; |
244 | 244 | $statusMessage = null; |
245 | - foreach($codes as $code) { |
|
246 | - if($code['code'] != 100) { |
|
245 | + foreach ($codes as $code) { |
|
246 | + if ($code['code'] != 100) { |
|
247 | 247 | $statusCode = $code['code']; |
248 | 248 | $statusMessage = $code['meta']['message']; |
249 | 249 | break; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | private static function isAuthorised($action) { |
262 | 262 | $level = $action['authlevel']; |
263 | - switch($level) { |
|
263 | + switch ($level) { |
|
264 | 264 | case API::GUEST_AUTH: |
265 | 265 | // Anyone can access |
266 | 266 | return true; |
@@ -270,16 +270,16 @@ discard block |
||
270 | 270 | case API::SUBADMIN_AUTH: |
271 | 271 | // Check for subadmin |
272 | 272 | $user = self::loginUser(); |
273 | - if(!$user) { |
|
273 | + if (!$user) { |
|
274 | 274 | return false; |
275 | 275 | } else { |
276 | 276 | $userObject = \OC::$server->getUserSession()->getUser(); |
277 | - if($userObject === null) { |
|
277 | + if ($userObject === null) { |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
281 | 281 | $admin = OC_User::isAdminUser($user); |
282 | - if($isSubAdmin || $admin) { |
|
282 | + if ($isSubAdmin || $admin) { |
|
283 | 283 | return true; |
284 | 284 | } else { |
285 | 285 | return false; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | case API::ADMIN_AUTH: |
289 | 289 | // Check for admin |
290 | 290 | $user = self::loginUser(); |
291 | - if(!$user) { |
|
291 | + if (!$user) { |
|
292 | 292 | return false; |
293 | 293 | } else { |
294 | 294 | return OC_User::isAdminUser($user); |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @return string|false (username, or false on failure) |
305 | 305 | */ |
306 | 306 | private static function loginUser() { |
307 | - if(self::$isLoggedIn === true) { |
|
307 | + if (self::$isLoggedIn === true) { |
|
308 | 308 | return \OC_User::getUser(); |
309 | 309 | } |
310 | 310 | |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | * @param OC_OCS_Result $result |
359 | 359 | * @param string $format the format xml|json |
360 | 360 | */ |
361 | - public static function respond($result, $format='xml') { |
|
361 | + public static function respond($result, $format = 'xml') { |
|
362 | 362 | $request = \OC::$server->getRequest(); |
363 | 363 | |
364 | 364 | // Send 401 headers if unauthorised |
365 | - if($result->getStatusCode() === API::RESPOND_UNAUTHORISED) { |
|
365 | + if ($result->getStatusCode() === API::RESPOND_UNAUTHORISED) { |
|
366 | 366 | // If request comes from JS return dummy auth request |
367 | - if($request->getHeader('X-Requested-With') === 'XMLHttpRequest') { |
|
367 | + if ($request->getHeader('X-Requested-With') === 'XMLHttpRequest') { |
|
368 | 368 | header('WWW-Authenticate: DummyBasic realm="Authorisation Required"'); |
369 | 369 | } else { |
370 | 370 | header('WWW-Authenticate: Basic realm="Authorisation Required"'); |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | header('HTTP/1.0 401 Unauthorized'); |
373 | 373 | } |
374 | 374 | |
375 | - foreach($result->getHeaders() as $name => $value) { |
|
376 | - header($name . ': ' . $value); |
|
375 | + foreach ($result->getHeaders() as $name => $value) { |
|
376 | + header($name.': '.$value); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | $meta = $result->getMeta(); |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | * @param XMLWriter $writer |
396 | 396 | */ |
397 | 397 | private static function toXML($array, $writer) { |
398 | - foreach($array as $k => $v) { |
|
398 | + foreach ($array as $k => $v) { |
|
399 | 399 | if ($k[0] === '@') { |
400 | 400 | $writer->writeAttribute(substr($k, 1), $v); |
401 | 401 | continue; |
402 | 402 | } else if (is_numeric($k)) { |
403 | 403 | $k = 'element'; |
404 | 404 | } |
405 | - if(is_array($v)) { |
|
405 | + if (is_array($v)) { |
|
406 | 406 | $writer->startElement($k); |
407 | 407 | self::toXML($v, $writer); |
408 | 408 | $writer->endElement(); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | case 'database': |
95 | 95 | case 'mysql': |
96 | 96 | case 'sqlite': |
97 | - \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', \OCP\Util::DEBUG); |
|
97 | + \OCP\Util::writeLog('core', 'Adding user backend '.$backend.'.', \OCP\Util::DEBUG); |
|
98 | 98 | self::$_usedBackends[$backend] = new \OC\User\Database(); |
99 | 99 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
100 | 100 | break; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
104 | 104 | break; |
105 | 105 | default: |
106 | - \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG); |
|
107 | - $className = 'OC_USER_' . strtoupper($backend); |
|
106 | + \OCP\Util::writeLog('core', 'Adding default user backend '.$backend.'.', \OCP\Util::DEBUG); |
|
107 | + $className = 'OC_USER_'.strtoupper($backend); |
|
108 | 108 | self::$_usedBackends[$backend] = new $className(); |
109 | 109 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
110 | 110 | break; |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | self::useBackend($backend); |
148 | 148 | self::$_setupedBackends[] = $i; |
149 | 149 | } else { |
150 | - \OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', \OCP\Util::DEBUG); |
|
150 | + \OCP\Util::writeLog('core', 'User backend '.$class.' already initialized.', \OCP\Util::DEBUG); |
|
151 | 151 | } |
152 | 152 | } else { |
153 | - \OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', \OCP\Util::ERROR); |
|
153 | + \OCP\Util::writeLog('core', 'User backend '.$class.' not found.', \OCP\Util::ERROR); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | if (self::getUser() !== $uid) { |
189 | 189 | self::setUserId($uid); |
190 | 190 | $setUidAsDisplayName = true; |
191 | - if($backend instanceof \OCP\UserInterface |
|
191 | + if ($backend instanceof \OCP\UserInterface |
|
192 | 192 | && $backend->implementsActions(OC_User_Backend::GET_DISPLAYNAME)) { |
193 | 193 | |
194 | 194 | $backendDisplayName = $backend->getDisplayName($uid); |
195 | - if(is_string($backendDisplayName) && trim($backendDisplayName) !== '') { |
|
195 | + if (is_string($backendDisplayName) && trim($backendDisplayName) !== '') { |
|
196 | 196 | $setUidAsDisplayName = false; |
197 | 197 | } |
198 | 198 | } |
199 | - if($setUidAsDisplayName) { |
|
199 | + if ($setUidAsDisplayName) { |
|
200 | 200 | self::setDisplayName($uid); |
201 | 201 | } |
202 | 202 | self::getUserSession()->setLoginName($uid); |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | if ($user) { |
491 | 491 | return $user->getHome(); |
492 | 492 | } else { |
493 | - return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; |
|
493 | + return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT.'/data').'/'.$uid; |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * SQL query via Doctrine prepare(), needs to be execute()'d! |
55 | 55 | */ |
56 | - static public function prepare( $query , $limit = null, $offset = null, $isManipulation = null) { |
|
56 | + static public function prepare($query, $limit = null, $offset = null, $isManipulation = null) { |
|
57 | 57 | $connection = \OC::$server->getDatabaseConnection(); |
58 | 58 | |
59 | 59 | if ($isManipulation === null) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | // return the result |
65 | 65 | try { |
66 | - $result =$connection->prepare($query, $limit, $offset); |
|
66 | + $result = $connection->prepare($query, $limit, $offset); |
|
67 | 67 | } catch (\Doctrine\DBAL\DBALException $e) { |
68 | 68 | throw new \OC\DatabaseException($e->getMessage(), $query); |
69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param string $sql |
80 | 80 | * @return bool |
81 | 81 | */ |
82 | - static public function isManipulation( $sql ) { |
|
82 | + static public function isManipulation($sql) { |
|
83 | 83 | $selectOccurrence = stripos($sql, 'SELECT'); |
84 | 84 | if ($selectOccurrence !== false && $selectOccurrence < 10) { |
85 | 85 | return false; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return OC_DB_StatementWrapper |
109 | 109 | * @throws \OC\DatabaseException |
110 | 110 | */ |
111 | - static public function executeAudited( $stmt, array $parameters = null) { |
|
111 | + static public function executeAudited($stmt, array $parameters = null) { |
|
112 | 112 | if (is_string($stmt)) { |
113 | 113 | // convert to an array with 'sql' |
114 | 114 | if (stripos($stmt, 'LIMIT') !== false) { //OFFSET requires LIMIT, so we only need to check for LIMIT |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | } |
122 | 122 | if (is_array($stmt)) { |
123 | 123 | // convert to prepared statement |
124 | - if ( ! array_key_exists('sql', $stmt) ) { |
|
124 | + if (!array_key_exists('sql', $stmt)) { |
|
125 | 125 | $message = 'statement array must at least contain key \'sql\''; |
126 | 126 | throw new \OC\DatabaseException($message); |
127 | 127 | } |
128 | - if ( ! array_key_exists('limit', $stmt) ) { |
|
128 | + if (!array_key_exists('limit', $stmt)) { |
|
129 | 129 | $stmt['limit'] = null; |
130 | 130 | } |
131 | - if ( ! array_key_exists('limit', $stmt) ) { |
|
131 | + if (!array_key_exists('limit', $stmt)) { |
|
132 | 132 | $stmt['offset'] = null; |
133 | 133 | } |
134 | 134 | $stmt = self::prepare($stmt['sql'], $stmt['limit'], $stmt['offset']); |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | self::raiseExceptionOnError($result, 'Could not execute statement'); |
140 | 140 | } else { |
141 | 141 | if (is_object($stmt)) { |
142 | - $message = 'Expected a prepared statement or array got ' . get_class($stmt); |
|
142 | + $message = 'Expected a prepared statement or array got '.get_class($stmt); |
|
143 | 143 | } else { |
144 | - $message = 'Expected a prepared statement or array got ' . gettype($stmt); |
|
144 | + $message = 'Expected a prepared statement or array got '.gettype($stmt); |
|
145 | 145 | } |
146 | 146 | throw new \OC\DatabaseException($message); |
147 | 147 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * |
169 | 169 | * TODO: write more documentation |
170 | 170 | */ |
171 | - public static function createDbFromStructure( $file ) { |
|
171 | + public static function createDbFromStructure($file) { |
|
172 | 172 | $schemaManager = self::getMDB2SchemaManager(); |
173 | 173 | $result = $schemaManager->createDbFromStructure($file); |
174 | 174 | return $result; |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | * @throws \OC\DatabaseException |
209 | 209 | */ |
210 | 210 | public static function raiseExceptionOnError($result, $message = null) { |
211 | - if($result === false) { |
|
211 | + if ($result === false) { |
|
212 | 212 | if ($message === null) { |
213 | 213 | $message = self::getErrorMessage(); |
214 | 214 | } else { |
215 | - $message .= ', Root cause:' . self::getErrorMessage(); |
|
215 | + $message .= ', Root cause:'.self::getErrorMessage(); |
|
216 | 216 | } |
217 | 217 | throw new \OC\DatabaseException($message, \OC::$server->getDatabaseConnection()->errorCode()); |
218 | 218 | } |
@@ -31,27 +31,27 @@ |
||
31 | 31 | * error code for functions not provided by the user backend |
32 | 32 | * @deprecated Use \OC_User_Backend::NOT_IMPLEMENTED instead |
33 | 33 | */ |
34 | -define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); |
|
34 | +define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * actions that user backends can define |
38 | 38 | */ |
39 | 39 | /** @deprecated Use \OC_User_Backend::CREATE_USER instead */ |
40 | -define('OC_USER_BACKEND_CREATE_USER', 1 << 0); |
|
40 | +define('OC_USER_BACKEND_CREATE_USER', 1 << 0); |
|
41 | 41 | /** @deprecated Use \OC_User_Backend::SET_PASSWORD instead */ |
42 | -define('OC_USER_BACKEND_SET_PASSWORD', 1 << 4); |
|
42 | +define('OC_USER_BACKEND_SET_PASSWORD', 1 << 4); |
|
43 | 43 | /** @deprecated Use \OC_User_Backend::CHECK_PASSWORD instead */ |
44 | -define('OC_USER_BACKEND_CHECK_PASSWORD', 1 << 8); |
|
44 | +define('OC_USER_BACKEND_CHECK_PASSWORD', 1 << 8); |
|
45 | 45 | /** @deprecated Use \OC_User_Backend::GET_HOME instead */ |
46 | -define('OC_USER_BACKEND_GET_HOME', 1 << 12); |
|
46 | +define('OC_USER_BACKEND_GET_HOME', 1 << 12); |
|
47 | 47 | /** @deprecated Use \OC_User_Backend::GET_DISPLAYNAME instead */ |
48 | -define('OC_USER_BACKEND_GET_DISPLAYNAME', 1 << 16); |
|
48 | +define('OC_USER_BACKEND_GET_DISPLAYNAME', 1 << 16); |
|
49 | 49 | /** @deprecated Use \OC_User_Backend::SET_DISPLAYNAME instead */ |
50 | -define('OC_USER_BACKEND_SET_DISPLAYNAME', 1 << 20); |
|
50 | +define('OC_USER_BACKEND_SET_DISPLAYNAME', 1 << 20); |
|
51 | 51 | /** @deprecated Use \OC_User_Backend::PROVIDE_AVATAR instead */ |
52 | -define('OC_USER_BACKEND_PROVIDE_AVATAR', 1 << 24); |
|
52 | +define('OC_USER_BACKEND_PROVIDE_AVATAR', 1 << 24); |
|
53 | 53 | /** @deprecated Use \OC_User_Backend::COUNT_USERS instead */ |
54 | -define('OC_USER_BACKEND_COUNT_USERS', 1 << 28); |
|
54 | +define('OC_USER_BACKEND_COUNT_USERS', 1 << 28); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Abstract base class for user management. Provides methods for querying backend |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $this->defaultLogoClaim = ''; |
66 | 66 | $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */ |
67 | 67 | |
68 | - $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
68 | + $themePath = OC::$SERVERROOT.'/themes/'.OC_Util::getTheme().'/defaults.php'; |
|
69 | 69 | if (file_exists($themePath)) { |
70 | 70 | // prevent defaults.php from printing output |
71 | 71 | ob_start(); |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | if ($this->themeExist('getShortFooter')) { |
240 | 240 | $footer = $this->theme->getShortFooter(); |
241 | 241 | } else { |
242 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
243 | - ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
244 | - ' – ' . $this->getSlogan(); |
|
242 | + $footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'. |
|
243 | + ' rel="noreferrer">'.$this->getEntity().'</a>'. |
|
244 | + ' – '.$this->getSlogan(); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | return $footer; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | if ($this->themeExist('buildDocLinkToKey')) { |
269 | 269 | return $this->theme->buildDocLinkToKey($key); |
270 | 270 | } |
271 | - return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
271 | + return $this->getDocBaseUrl().'/server/'.$this->defaultDocVersion.'/go.php?to='.$key; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |