@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $this->recoveryKeyId = $this->config->getAppValue('encryption', |
129 | 129 | 'recoveryKeyId'); |
130 | 130 | if (empty($this->recoveryKeyId)) { |
131 | - $this->recoveryKeyId = 'recoveryKey_' . substr(md5(time()), 0, 8); |
|
131 | + $this->recoveryKeyId = 'recoveryKey_'.substr(md5(time()), 0, 8); |
|
132 | 132 | $this->config->setAppValue('encryption', |
133 | 133 | 'recoveryKeyId', |
134 | 134 | $this->recoveryKeyId); |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | $this->publicShareKeyId = $this->config->getAppValue('encryption', |
138 | 138 | 'publicShareKeyId'); |
139 | 139 | if (empty($this->publicShareKeyId)) { |
140 | - $this->publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8); |
|
140 | + $this->publicShareKeyId = 'pubShare_'.substr(md5(time()), 0, 8); |
|
141 | 141 | $this->config->setAppValue('encryption', 'publicShareKeyId', $this->publicShareKeyId); |
142 | 142 | } |
143 | 143 | |
144 | 144 | $this->masterKeyId = $this->config->getAppValue('encryption', |
145 | 145 | 'masterKeyId'); |
146 | 146 | if (empty($this->masterKeyId)) { |
147 | - $this->masterKeyId = 'master_' . substr(md5(time()), 0, 8); |
|
147 | + $this->masterKeyId = 'master_'.substr(md5(time()), 0, 8); |
|
148 | 148 | $this->config->setAppValue('encryption', 'masterKeyId', $this->masterKeyId); |
149 | 149 | } |
150 | 150 | |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | |
163 | 163 | // Save public key |
164 | 164 | $this->keyStorage->setSystemUserKey( |
165 | - $this->publicShareKeyId . '.publicKey', $keyPair['publicKey'], |
|
165 | + $this->publicShareKeyId.'.publicKey', $keyPair['publicKey'], |
|
166 | 166 | Encryption::ID); |
167 | 167 | |
168 | 168 | // Encrypt private key empty passphrase |
169 | 169 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], ''); |
170 | 170 | $header = $this->crypt->generateHeader(); |
171 | - $this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey); |
|
171 | + $this->setSystemPrivateKey($this->publicShareKeyId, $header.$encryptedKey); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | |
188 | 188 | // Save public key |
189 | 189 | $this->keyStorage->setSystemUserKey( |
190 | - $this->masterKeyId . '.publicKey', $keyPair['publicKey'], |
|
190 | + $this->masterKeyId.'.publicKey', $keyPair['publicKey'], |
|
191 | 191 | Encryption::ID); |
192 | 192 | |
193 | 193 | // Encrypt private key with system password |
194 | 194 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $this->getMasterKeyPassword(), $this->masterKeyId); |
195 | 195 | $header = $this->crypt->generateHeader(); |
196 | - $this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey); |
|
196 | + $this->setSystemPrivateKey($this->masterKeyId, $header.$encryptedKey); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if (!$this->session->isPrivateKeySet()) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return string |
221 | 221 | */ |
222 | 222 | public function getRecoveryKey() { |
223 | - return $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.publicKey', Encryption::ID); |
|
223 | + return $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.publicKey', Encryption::ID); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return bool |
238 | 238 | */ |
239 | 239 | public function checkRecoveryPassword($password) { |
240 | - $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.privateKey', Encryption::ID); |
|
240 | + $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.privateKey', Encryption::ID); |
|
241 | 241 | $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $password); |
242 | 242 | |
243 | 243 | if ($decryptedRecoveryKey) { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $header = $this->crypt->generateHeader(); |
262 | 262 | |
263 | 263 | if ($encryptedKey) { |
264 | - $this->setPrivateKey($uid, $header . $encryptedKey); |
|
264 | + $this->setPrivateKey($uid, $header.$encryptedKey); |
|
265 | 265 | return true; |
266 | 266 | } |
267 | 267 | return false; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $header = $this->crypt->generateHeader(); |
284 | 284 | |
285 | 285 | if ($encryptedKey) { |
286 | - $this->setSystemPrivateKey($this->getRecoveryKeyId(), $header . $encryptedKey); |
|
286 | + $this->setSystemPrivateKey($this->getRecoveryKeyId(), $header.$encryptedKey); |
|
287 | 287 | return true; |
288 | 288 | } |
289 | 289 | return false; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @return boolean |
344 | 344 | */ |
345 | 345 | public function setShareKey($path, $uid, $key) { |
346 | - $keyId = $uid . '.' . $this->shareKeyId; |
|
346 | + $keyId = $uid.'.'.$this->shareKeyId; |
|
347 | 347 | return $this->keyStorage->setFileKey($path, $keyId, $key, Encryption::ID); |
348 | 348 | } |
349 | 349 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $this->session->setStatus(Session::INIT_EXECUTED); |
360 | 360 | |
361 | 361 | try { |
362 | - if($this->util->isMasterKeyEnabled()) { |
|
362 | + if ($this->util->isMasterKeyEnabled()) { |
|
363 | 363 | $uid = $this->getMasterKeyId(); |
364 | 364 | $passPhrase = $this->getMasterKeyPassword(); |
365 | 365 | $privateKey = $this->getSystemPrivateKey($uid); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | return false; |
374 | 374 | } catch (\Exception $e) { |
375 | 375 | $this->log->logException($e, [ |
376 | - 'message' => 'Could not decrypt the private key from user "' . $uid . '"" during login. Assume password change on the user back-end.', |
|
376 | + 'message' => 'Could not decrypt the private key from user "'.$uid.'"" during login. Assume password change on the user back-end.', |
|
377 | 377 | 'level' => ILogger::WARN, |
378 | 378 | 'app' => 'encryption', |
379 | 379 | ]); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | // use public share key for public links |
435 | 435 | $uid = $this->getPublicShareKeyId(); |
436 | 436 | $shareKey = $this->getShareKey($path, $uid); |
437 | - $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey', Encryption::ID); |
|
437 | + $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.privateKey', Encryption::ID); |
|
438 | 438 | $privateKey = $this->crypt->decryptPrivateKey($privateKey); |
439 | 439 | } else { |
440 | 440 | $shareKey = $this->getShareKey($path, $uid); |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function getVersion($path, View $view) { |
461 | 461 | $fileInfo = $view->getFileInfo($path); |
462 | - if($fileInfo === false) { |
|
462 | + if ($fileInfo === false) { |
|
463 | 463 | return 0; |
464 | 464 | } |
465 | 465 | return $fileInfo->getEncryptedVersion(); |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | * @param View $view |
474 | 474 | */ |
475 | 475 | public function setVersion($path, $version, View $view) { |
476 | - $fileInfo= $view->getFileInfo($path); |
|
476 | + $fileInfo = $view->getFileInfo($path); |
|
477 | 477 | |
478 | - if($fileInfo !== false) { |
|
478 | + if ($fileInfo !== false) { |
|
479 | 479 | $cache = $fileInfo->getStorage()->getCache(); |
480 | 480 | $cache->update($fileInfo->getId(), ['encrypted' => $version, 'encryptedVersion' => $version]); |
481 | 481 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | public function deleteShareKey($path, $keyId) { |
505 | 505 | return $this->keyStorage->deleteFileKey( |
506 | 506 | $path, |
507 | - $keyId . '.' . $this->shareKeyId, |
|
507 | + $keyId.'.'.$this->shareKeyId, |
|
508 | 508 | Encryption::ID); |
509 | 509 | } |
510 | 510 | |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @return mixed |
516 | 516 | */ |
517 | 517 | public function getShareKey($path, $uid) { |
518 | - $keyId = $uid . '.' . $this->shareKeyId; |
|
518 | + $keyId = $uid.'.'.$this->shareKeyId; |
|
519 | 519 | return $this->keyStorage->getFileKey($path, $keyId, Encryption::ID); |
520 | 520 | } |
521 | 521 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @return string |
578 | 578 | */ |
579 | 579 | public function getPublicShareKey() { |
580 | - return $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.publicKey', Encryption::ID); |
|
580 | + return $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.publicKey', Encryption::ID); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | * @return string returns openssl key |
648 | 648 | */ |
649 | 649 | public function getSystemPrivateKey($keyId) { |
650 | - return $this->keyStorage->getSystemUserKey($keyId . '.' . $this->privateKeyId, Encryption::ID); |
|
650 | + return $this->keyStorage->getSystemUserKey($keyId.'.'.$this->privateKeyId, Encryption::ID); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function setSystemPrivateKey($keyId, $key) { |
659 | 659 | return $this->keyStorage->setSystemUserKey( |
660 | - $keyId . '.' . $this->privateKeyId, |
|
660 | + $keyId.'.'.$this->privateKeyId, |
|
661 | 661 | $key, |
662 | 662 | Encryption::ID); |
663 | 663 | } |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | */ |
698 | 698 | public function getMasterKeyPassword() { |
699 | 699 | $password = $this->config->getSystemValue('secret'); |
700 | - if (empty($password)){ |
|
700 | + if (empty($password)) { |
|
701 | 701 | throw new \Exception('Can not get secret from Nextcloud instance'); |
702 | 702 | } |
703 | 703 | |
@@ -719,6 +719,6 @@ discard block |
||
719 | 719 | * @return string |
720 | 720 | */ |
721 | 721 | public function getPublicMasterKey() { |
722 | - return $this->keyStorage->getSystemUserKey($this->masterKeyId . '.publicKey', Encryption::ID); |
|
722 | + return $this->keyStorage->getSystemUserKey($this->masterKeyId.'.publicKey', Encryption::ID); |
|
723 | 723 | } |
724 | 724 | } |
@@ -101,24 +101,24 @@ discard block |
||
101 | 101 | * Remove "apps/" from inclusion path for smooth migration to multi app dir |
102 | 102 | */ |
103 | 103 | if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) { |
104 | - \OCP\Util::writeLog('core', 'include path for class "' . $class . '" starts with "apps/"', ILogger::DEBUG); |
|
104 | + \OCP\Util::writeLog('core', 'include path for class "'.$class.'" starts with "apps/"', ILogger::DEBUG); |
|
105 | 105 | $paths[] = str_replace('apps/', '', \OC::$CLASSPATH[$class]); |
106 | 106 | } |
107 | 107 | } elseif (strpos($class, 'OC_') === 0) { |
108 | - $paths[] = \OC::$SERVERROOT . '/lib/private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php'); |
|
108 | + $paths[] = \OC::$SERVERROOT.'/lib/private/legacy/'.strtolower(str_replace('_', '/', substr($class, 3)).'.php'); |
|
109 | 109 | } elseif (strpos($class, 'OCA\\') === 0) { |
110 | 110 | list(, $app, $rest) = explode('\\', $class, 3); |
111 | 111 | $app = strtolower($app); |
112 | 112 | $appPath = \OC_App::getAppPath($app); |
113 | 113 | if ($appPath && stream_resolve_include_path($appPath)) { |
114 | - $paths[] = $appPath . '/' . strtolower(str_replace('\\', '/', $rest) . '.php'); |
|
114 | + $paths[] = $appPath.'/'.strtolower(str_replace('\\', '/', $rest).'.php'); |
|
115 | 115 | // If not found in the root of the app directory, insert '/lib' after app id and try again. |
116 | - $paths[] = $appPath . '/lib/' . strtolower(str_replace('\\', '/', $rest) . '.php'); |
|
116 | + $paths[] = $appPath.'/lib/'.strtolower(str_replace('\\', '/', $rest).'.php'); |
|
117 | 117 | } |
118 | 118 | } elseif ($class === 'Test\\TestCase') { |
119 | 119 | // This File is considered public API, so we make sure that the class |
120 | 120 | // can still be loaded, although the PSR-4 paths have not been loaded. |
121 | - $paths[] = \OC::$SERVERROOT . '/tests/lib/TestCase.php'; |
|
121 | + $paths[] = \OC::$SERVERROOT.'/tests/lib/TestCase.php'; |
|
122 | 122 | } |
123 | 123 | return $paths; |
124 | 124 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | protected function isValidPath(string $fullPath): bool { |
132 | 132 | foreach ($this->validRoots as $root => $true) { |
133 | - if (substr($fullPath, 0, strlen($root) + 1) === $root . '/') { |
|
133 | + if (substr($fullPath, 0, strlen($root) + 1) === $root.'/') { |
|
134 | 134 | return true; |
135 | 135 | } |
136 | 136 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $pathsToRequire = $this->memoryCache->get($class); |
151 | 151 | } |
152 | 152 | |
153 | - if(class_exists($class, false)) { |
|
153 | + if (class_exists($class, false)) { |
|
154 | 154 | return false; |
155 | 155 | } |
156 | 156 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | try { |
66 | 66 | return new \DateTimeZone($timeZone); |
67 | 67 | } catch (\Exception $e) { |
68 | - \OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", ILogger::DEBUG); |
|
68 | + \OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "'.$timeZone."'", ILogger::DEBUG); |
|
69 | 69 | return new \DateTimeZone($this->getDefaultTimeZone()); |
70 | 70 | } |
71 | 71 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | // so a positive offset means negative timeZone |
87 | 87 | // and the other way around. |
88 | 88 | if ($offset > 0) { |
89 | - $timeZone = 'Etc/GMT-' . $offset; |
|
89 | + $timeZone = 'Etc/GMT-'.$offset; |
|
90 | 90 | } else { |
91 | - $timeZone = 'Etc/GMT+' . abs($offset); |
|
91 | + $timeZone = 'Etc/GMT+'.abs($offset); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | return new \DateTimeZone($timeZone); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | // No timezone found, fallback to UTC |
113 | - \OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", ILogger::DEBUG); |
|
113 | + \OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "'.$offset."'", ILogger::DEBUG); |
|
114 | 114 | return new \DateTimeZone($this->getDefaultTimeZone()); |
115 | 115 | } |
116 | 116 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | $this->tags = $this->mapper->loadTags($this->owners, $this->type); |
137 | 137 | |
138 | - if(count($defaultTags) > 0 && count($this->tags) === 0) { |
|
138 | + if (count($defaultTags) > 0 && count($this->tags) === 0) { |
|
139 | 139 | $this->addMultiple($defaultTags, true); |
140 | 140 | } |
141 | 141 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @return array |
177 | 177 | */ |
178 | 178 | public function getTags() { |
179 | - if(!count($this->tags)) { |
|
179 | + if (!count($this->tags)) { |
|
180 | 180 | return array(); |
181 | 181 | } |
182 | 182 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | }); |
186 | 186 | $tagMap = array(); |
187 | 187 | |
188 | - foreach($this->tags as $tag) { |
|
189 | - if($tag->getName() !== self::TAG_FAVORITE) { |
|
188 | + foreach ($this->tags as $tag) { |
|
189 | + if ($tag->getName() !== self::TAG_FAVORITE) { |
|
190 | 190 | $tagMap[] = $this->tagMap($tag); |
191 | 191 | } |
192 | 192 | } |
@@ -224,25 +224,25 @@ discard block |
||
224 | 224 | $chunks = array_chunk($objIds, 900, false); |
225 | 225 | foreach ($chunks as $chunk) { |
226 | 226 | $result = $conn->executeQuery( |
227 | - 'SELECT `category`, `categoryid`, `objid` ' . |
|
228 | - 'FROM `' . self::RELATION_TABLE . '` r, `' . self::TAG_TABLE . '` ' . |
|
227 | + 'SELECT `category`, `categoryid`, `objid` '. |
|
228 | + 'FROM `'.self::RELATION_TABLE.'` r, `'.self::TAG_TABLE.'` '. |
|
229 | 229 | 'WHERE `categoryid` = `id` AND `uid` = ? AND r.`type` = ? AND `objid` IN (?)', |
230 | 230 | array($this->user, $this->type, $chunk), |
231 | 231 | array(null, null, IQueryBuilder::PARAM_INT_ARRAY) |
232 | 232 | ); |
233 | 233 | while ($row = $result->fetch()) { |
234 | - $objId = (int)$row['objid']; |
|
234 | + $objId = (int) $row['objid']; |
|
235 | 235 | if (!isset($entries[$objId])) { |
236 | 236 | $entries[$objId] = array(); |
237 | 237 | } |
238 | 238 | $entries[$objId][] = $row['category']; |
239 | 239 | } |
240 | 240 | if ($result === null) { |
241 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
241 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | } |
245 | - } catch(\Exception $e) { |
|
245 | + } catch (\Exception $e) { |
|
246 | 246 | \OC::$server->getLogger()->logException($e, [ |
247 | 247 | 'message' => __METHOD__, |
248 | 248 | 'level' => ILogger::ERROR, |
@@ -266,18 +266,18 @@ discard block |
||
266 | 266 | public function getIdsForTag($tag) { |
267 | 267 | $result = null; |
268 | 268 | $tagId = false; |
269 | - if(is_numeric($tag)) { |
|
269 | + if (is_numeric($tag)) { |
|
270 | 270 | $tagId = $tag; |
271 | - } elseif(is_string($tag)) { |
|
271 | + } elseif (is_string($tag)) { |
|
272 | 272 | $tag = trim($tag); |
273 | - if($tag === '') { |
|
273 | + if ($tag === '') { |
|
274 | 274 | \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG); |
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | $tagId = $this->getTagId($tag); |
278 | 278 | } |
279 | 279 | |
280 | - if($tagId === false) { |
|
280 | + if ($tagId === false) { |
|
281 | 281 | $l10n = \OC::$server->getL10N('core'); |
282 | 282 | throw new \Exception( |
283 | 283 | $l10n->t('Could not find category "%s"', [$tag]) |
@@ -285,17 +285,17 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | $ids = array(); |
288 | - $sql = 'SELECT `objid` FROM `' . self::RELATION_TABLE |
|
288 | + $sql = 'SELECT `objid` FROM `'.self::RELATION_TABLE |
|
289 | 289 | . '` WHERE `categoryid` = ?'; |
290 | 290 | |
291 | 291 | try { |
292 | 292 | $stmt = \OC_DB::prepare($sql); |
293 | 293 | $result = $stmt->execute(array($tagId)); |
294 | 294 | if ($result === null) { |
295 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
295 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
296 | 296 | return false; |
297 | 297 | } |
298 | - } catch(\Exception $e) { |
|
298 | + } catch (\Exception $e) { |
|
299 | 299 | \OC::$server->getLogger()->logException($e, [ |
300 | 300 | 'message' => __METHOD__, |
301 | 301 | 'level' => ILogger::ERROR, |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | return false; |
305 | 305 | } |
306 | 306 | |
307 | - if(!is_null($result)) { |
|
308 | - while( $row = $result->fetchRow()) { |
|
309 | - $id = (int)$row['objid']; |
|
307 | + if (!is_null($result)) { |
|
308 | + while ($row = $result->fetchRow()) { |
|
309 | + $id = (int) $row['objid']; |
|
310 | 310 | |
311 | 311 | if ($this->includeShared) { |
312 | 312 | // We have to check if we are really allowed to access the |
@@ -360,19 +360,19 @@ discard block |
||
360 | 360 | public function add($name) { |
361 | 361 | $name = trim($name); |
362 | 362 | |
363 | - if($name === '') { |
|
363 | + if ($name === '') { |
|
364 | 364 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); |
365 | 365 | return false; |
366 | 366 | } |
367 | - if($this->userHasTag($name, $this->user)) { |
|
368 | - \OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', ILogger::DEBUG); |
|
367 | + if ($this->userHasTag($name, $this->user)) { |
|
368 | + \OCP\Util::writeLog('core', __METHOD__.', name: '.$name.' exists already', ILogger::DEBUG); |
|
369 | 369 | return false; |
370 | 370 | } |
371 | 371 | try { |
372 | 372 | $tag = new Tag($this->user, $this->type, $name); |
373 | 373 | $tag = $this->mapper->insert($tag); |
374 | 374 | $this->tags[] = $tag; |
375 | - } catch(\Exception $e) { |
|
375 | + } catch (\Exception $e) { |
|
376 | 376 | \OC::$server->getLogger()->logException($e, [ |
377 | 377 | 'message' => __METHOD__, |
378 | 378 | 'level' => ILogger::ERROR, |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | ]); |
381 | 381 | return false; |
382 | 382 | } |
383 | - \OCP\Util::writeLog('core', __METHOD__.', id: ' . $tag->getId(), ILogger::DEBUG); |
|
383 | + \OCP\Util::writeLog('core', __METHOD__.', id: '.$tag->getId(), ILogger::DEBUG); |
|
384 | 384 | return $tag->getId(); |
385 | 385 | } |
386 | 386 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $from = trim($from); |
396 | 396 | $to = trim($to); |
397 | 397 | |
398 | - if($to === '' || $from === '') { |
|
398 | + if ($to === '' || $from === '') { |
|
399 | 399 | \OCP\Util::writeLog('core', __METHOD__.', Cannot use empty tag names', ILogger::DEBUG); |
400 | 400 | return false; |
401 | 401 | } |
@@ -405,21 +405,21 @@ discard block |
||
405 | 405 | } else { |
406 | 406 | $key = $this->getTagByName($from); |
407 | 407 | } |
408 | - if($key === false) { |
|
409 | - \OCP\Util::writeLog('core', __METHOD__.', tag: ' . $from. ' does not exist', ILogger::DEBUG); |
|
408 | + if ($key === false) { |
|
409 | + \OCP\Util::writeLog('core', __METHOD__.', tag: '.$from.' does not exist', ILogger::DEBUG); |
|
410 | 410 | return false; |
411 | 411 | } |
412 | 412 | $tag = $this->tags[$key]; |
413 | 413 | |
414 | - if($this->userHasTag($to, $tag->getOwner())) { |
|
415 | - \OCP\Util::writeLog('core', __METHOD__.', A tag named ' . $to. ' already exists for user ' . $tag->getOwner() . '.', ILogger::DEBUG); |
|
414 | + if ($this->userHasTag($to, $tag->getOwner())) { |
|
415 | + \OCP\Util::writeLog('core', __METHOD__.', A tag named '.$to.' already exists for user '.$tag->getOwner().'.', ILogger::DEBUG); |
|
416 | 416 | return false; |
417 | 417 | } |
418 | 418 | |
419 | 419 | try { |
420 | 420 | $tag->setName($to); |
421 | 421 | $this->tags[$key] = $this->mapper->update($tag); |
422 | - } catch(\Exception $e) { |
|
422 | + } catch (\Exception $e) { |
|
423 | 423 | \OC::$server->getLogger()->logException($e, [ |
424 | 424 | 'message' => __METHOD__, |
425 | 425 | 'level' => ILogger::ERROR, |
@@ -439,25 +439,25 @@ discard block |
||
439 | 439 | * @param int|null $id int Optional object id to add to this|these tag(s) |
440 | 440 | * @return bool Returns false on error. |
441 | 441 | */ |
442 | - public function addMultiple($names, $sync=false, $id = null) { |
|
443 | - if(!is_array($names)) { |
|
442 | + public function addMultiple($names, $sync = false, $id = null) { |
|
443 | + if (!is_array($names)) { |
|
444 | 444 | $names = array($names); |
445 | 445 | } |
446 | 446 | $names = array_map('trim', $names); |
447 | 447 | array_filter($names); |
448 | 448 | |
449 | 449 | $newones = array(); |
450 | - foreach($names as $name) { |
|
451 | - if(!$this->hasTag($name) && $name !== '') { |
|
450 | + foreach ($names as $name) { |
|
451 | + if (!$this->hasTag($name) && $name !== '') { |
|
452 | 452 | $newones[] = new Tag($this->user, $this->type, $name); |
453 | 453 | } |
454 | - if(!is_null($id) ) { |
|
454 | + if (!is_null($id)) { |
|
455 | 455 | // Insert $objectid, $categoryid pairs if not exist. |
456 | 456 | self::$relations[] = array('objid' => $id, 'tag' => $name); |
457 | 457 | } |
458 | 458 | } |
459 | 459 | $this->tags = array_merge($this->tags, $newones); |
460 | - if($sync === true) { |
|
460 | + if ($sync === true) { |
|
461 | 461 | $this->save(); |
462 | 462 | } |
463 | 463 | |
@@ -468,13 +468,13 @@ discard block |
||
468 | 468 | * Save the list of tags and their object relations |
469 | 469 | */ |
470 | 470 | protected function save() { |
471 | - if(is_array($this->tags)) { |
|
472 | - foreach($this->tags as $tag) { |
|
471 | + if (is_array($this->tags)) { |
|
472 | + foreach ($this->tags as $tag) { |
|
473 | 473 | try { |
474 | 474 | if (!$this->mapper->tagExists($tag)) { |
475 | 475 | $this->mapper->insert($tag); |
476 | 476 | } |
477 | - } catch(\Exception $e) { |
|
477 | + } catch (\Exception $e) { |
|
478 | 478 | \OC::$server->getLogger()->logException($e, [ |
479 | 479 | 'message' => __METHOD__, |
480 | 480 | 'level' => ILogger::ERROR, |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | |
486 | 486 | // reload tags to get the proper ids. |
487 | 487 | $this->tags = $this->mapper->loadTags($this->owners, $this->type); |
488 | - \OCP\Util::writeLog('core', __METHOD__.', tags: ' . print_r($this->tags, true), |
|
488 | + \OCP\Util::writeLog('core', __METHOD__.', tags: '.print_r($this->tags, true), |
|
489 | 489 | ILogger::DEBUG); |
490 | 490 | // Loop through temporarily cached objectid/tagname pairs |
491 | 491 | // and save relations. |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | // For some reason this is needed or array_search(i) will return 0..? |
494 | 494 | ksort($tags); |
495 | 495 | $dbConnection = \OC::$server->getDatabaseConnection(); |
496 | - foreach(self::$relations as $relation) { |
|
496 | + foreach (self::$relations as $relation) { |
|
497 | 497 | $tagId = $this->getTagId($relation['tag']); |
498 | - \OCP\Util::writeLog('core', __METHOD__ . 'catid, ' . $relation['tag'] . ' ' . $tagId, ILogger::DEBUG); |
|
499 | - if($tagId) { |
|
498 | + \OCP\Util::writeLog('core', __METHOD__.'catid, '.$relation['tag'].' '.$tagId, ILogger::DEBUG); |
|
499 | + if ($tagId) { |
|
500 | 500 | try { |
501 | 501 | $dbConnection->insertIfNotExist(self::RELATION_TABLE, |
502 | 502 | array( |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 'categoryid' => $tagId, |
505 | 505 | 'type' => $this->type, |
506 | 506 | )); |
507 | - } catch(\Exception $e) { |
|
507 | + } catch (\Exception $e) { |
|
508 | 508 | \OC::$server->getLogger()->logException($e, [ |
509 | 509 | 'message' => __METHOD__, |
510 | 510 | 'level' => ILogger::ERROR, |
@@ -531,13 +531,13 @@ discard block |
||
531 | 531 | // Find all objectid/tagId pairs. |
532 | 532 | $result = null; |
533 | 533 | try { |
534 | - $stmt = \OC_DB::prepare('SELECT `id` FROM `' . self::TAG_TABLE . '` ' |
|
534 | + $stmt = \OC_DB::prepare('SELECT `id` FROM `'.self::TAG_TABLE.'` ' |
|
535 | 535 | . 'WHERE `uid` = ?'); |
536 | 536 | $result = $stmt->execute(array($arguments['uid'])); |
537 | 537 | if ($result === null) { |
538 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
538 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
539 | 539 | } |
540 | - } catch(\Exception $e) { |
|
540 | + } catch (\Exception $e) { |
|
541 | 541 | \OC::$server->getLogger()->logException($e, [ |
542 | 542 | 'message' => __METHOD__, |
543 | 543 | 'level' => ILogger::ERROR, |
@@ -545,14 +545,14 @@ discard block |
||
545 | 545 | ]); |
546 | 546 | } |
547 | 547 | |
548 | - if(!is_null($result)) { |
|
548 | + if (!is_null($result)) { |
|
549 | 549 | try { |
550 | - $stmt = \OC_DB::prepare('DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
550 | + $stmt = \OC_DB::prepare('DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
551 | 551 | . 'WHERE `categoryid` = ?'); |
552 | - while( $row = $result->fetchRow()) { |
|
552 | + while ($row = $result->fetchRow()) { |
|
553 | 553 | try { |
554 | 554 | $stmt->execute(array($row['id'])); |
555 | - } catch(\Exception $e) { |
|
555 | + } catch (\Exception $e) { |
|
556 | 556 | \OC::$server->getLogger()->logException($e, [ |
557 | 557 | 'message' => __METHOD__, |
558 | 558 | 'level' => ILogger::ERROR, |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | ]); |
561 | 561 | } |
562 | 562 | } |
563 | - } catch(\Exception $e) { |
|
563 | + } catch (\Exception $e) { |
|
564 | 564 | \OC::$server->getLogger()->logException($e, [ |
565 | 565 | 'message' => __METHOD__, |
566 | 566 | 'level' => ILogger::ERROR, |
@@ -569,13 +569,13 @@ discard block |
||
569 | 569 | } |
570 | 570 | } |
571 | 571 | try { |
572 | - $stmt = \OC_DB::prepare('DELETE FROM `' . self::TAG_TABLE . '` ' |
|
572 | + $stmt = \OC_DB::prepare('DELETE FROM `'.self::TAG_TABLE.'` ' |
|
573 | 573 | . 'WHERE `uid` = ?'); |
574 | 574 | $result = $stmt->execute(array($arguments['uid'])); |
575 | 575 | if ($result === null) { |
576 | - \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
576 | + \OCP\Util::writeLog('core', __METHOD__.', DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
577 | 577 | } |
578 | - } catch(\Exception $e) { |
|
578 | + } catch (\Exception $e) { |
|
579 | 579 | \OC::$server->getLogger()->logException($e, [ |
580 | 580 | 'message' => __METHOD__, |
581 | 581 | 'level' => ILogger::ERROR, |
@@ -591,23 +591,23 @@ discard block |
||
591 | 591 | * @return boolean Returns false on error. |
592 | 592 | */ |
593 | 593 | public function purgeObjects(array $ids) { |
594 | - if(count($ids) === 0) { |
|
594 | + if (count($ids) === 0) { |
|
595 | 595 | // job done ;) |
596 | 596 | return true; |
597 | 597 | } |
598 | 598 | $updates = $ids; |
599 | 599 | try { |
600 | - $query = 'DELETE FROM `' . self::RELATION_TABLE . '` '; |
|
601 | - $query .= 'WHERE `objid` IN (' . str_repeat('?,', count($ids)-1) . '?) '; |
|
600 | + $query = 'DELETE FROM `'.self::RELATION_TABLE.'` '; |
|
601 | + $query .= 'WHERE `objid` IN ('.str_repeat('?,', count($ids) - 1).'?) '; |
|
602 | 602 | $query .= 'AND `type`= ?'; |
603 | 603 | $updates[] = $this->type; |
604 | 604 | $stmt = \OC_DB::prepare($query); |
605 | 605 | $result = $stmt->execute($updates); |
606 | 606 | if ($result === null) { |
607 | - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
607 | + \OCP\Util::writeLog('core', __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR); |
|
608 | 608 | return false; |
609 | 609 | } |
610 | - } catch(\Exception $e) { |
|
610 | + } catch (\Exception $e) { |
|
611 | 611 | \OC::$server->getLogger()->logException($e, [ |
612 | 612 | 'message' => __METHOD__, |
613 | 613 | 'level' => ILogger::ERROR, |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | public function getFavorites() { |
627 | 627 | try { |
628 | 628 | return $this->getIdsForTag(self::TAG_FAVORITE); |
629 | - } catch(\Exception $e) { |
|
629 | + } catch (\Exception $e) { |
|
630 | 630 | \OC::$server->getLogger()->logException($e, [ |
631 | 631 | 'message' => __METHOD__, |
632 | 632 | 'level' => ILogger::ERROR, |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | * @return boolean |
644 | 644 | */ |
645 | 645 | public function addToFavorites($objid) { |
646 | - if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
646 | + if (!$this->userHasTag(self::TAG_FAVORITE, $this->user)) { |
|
647 | 647 | $this->add(self::TAG_FAVORITE); |
648 | 648 | } |
649 | 649 | return $this->tagAs($objid, self::TAG_FAVORITE); |
@@ -667,16 +667,16 @@ discard block |
||
667 | 667 | * @return boolean Returns false on error. |
668 | 668 | */ |
669 | 669 | public function tagAs($objid, $tag) { |
670 | - if(is_string($tag) && !is_numeric($tag)) { |
|
670 | + if (is_string($tag) && !is_numeric($tag)) { |
|
671 | 671 | $tag = trim($tag); |
672 | - if($tag === '') { |
|
672 | + if ($tag === '') { |
|
673 | 673 | \OCP\Util::writeLog('core', __METHOD__.', Cannot add an empty tag', ILogger::DEBUG); |
674 | 674 | return false; |
675 | 675 | } |
676 | - if(!$this->hasTag($tag)) { |
|
676 | + if (!$this->hasTag($tag)) { |
|
677 | 677 | $this->add($tag); |
678 | 678 | } |
679 | - $tagId = $this->getTagId($tag); |
|
679 | + $tagId = $this->getTagId($tag); |
|
680 | 680 | } else { |
681 | 681 | $tagId = $tag; |
682 | 682 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | 'categoryid' => $tagId, |
688 | 688 | 'type' => $this->type, |
689 | 689 | )); |
690 | - } catch(\Exception $e) { |
|
690 | + } catch (\Exception $e) { |
|
691 | 691 | \OC::$server->getLogger()->logException($e, [ |
692 | 692 | 'message' => __METHOD__, |
693 | 693 | 'level' => ILogger::ERROR, |
@@ -706,23 +706,23 @@ discard block |
||
706 | 706 | * @return boolean |
707 | 707 | */ |
708 | 708 | public function unTag($objid, $tag) { |
709 | - if(is_string($tag) && !is_numeric($tag)) { |
|
709 | + if (is_string($tag) && !is_numeric($tag)) { |
|
710 | 710 | $tag = trim($tag); |
711 | - if($tag === '') { |
|
711 | + if ($tag === '') { |
|
712 | 712 | \OCP\Util::writeLog('core', __METHOD__.', Tag name is empty', ILogger::DEBUG); |
713 | 713 | return false; |
714 | 714 | } |
715 | - $tagId = $this->getTagId($tag); |
|
715 | + $tagId = $this->getTagId($tag); |
|
716 | 716 | } else { |
717 | 717 | $tagId = $tag; |
718 | 718 | } |
719 | 719 | |
720 | 720 | try { |
721 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
721 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
722 | 722 | . 'WHERE `objid` = ? AND `categoryid` = ? AND `type` = ?'; |
723 | 723 | $stmt = \OC_DB::prepare($sql); |
724 | 724 | $stmt->execute(array($objid, $tagId, $this->type)); |
725 | - } catch(\Exception $e) { |
|
725 | + } catch (\Exception $e) { |
|
726 | 726 | \OC::$server->getLogger()->logException($e, [ |
727 | 727 | 'message' => __METHOD__, |
728 | 728 | 'level' => ILogger::ERROR, |
@@ -740,16 +740,16 @@ discard block |
||
740 | 740 | * @return bool Returns false on error |
741 | 741 | */ |
742 | 742 | public function delete($names) { |
743 | - if(!is_array($names)) { |
|
743 | + if (!is_array($names)) { |
|
744 | 744 | $names = array($names); |
745 | 745 | } |
746 | 746 | |
747 | 747 | $names = array_map('trim', $names); |
748 | 748 | array_filter($names); |
749 | 749 | |
750 | - \OCP\Util::writeLog('core', __METHOD__ . ', before: ' |
|
750 | + \OCP\Util::writeLog('core', __METHOD__.', before: ' |
|
751 | 751 | . print_r($this->tags, true), ILogger::DEBUG); |
752 | - foreach($names as $name) { |
|
752 | + foreach ($names as $name) { |
|
753 | 753 | $id = null; |
754 | 754 | |
755 | 755 | if (is_numeric($name)) { |
@@ -763,22 +763,22 @@ discard block |
||
763 | 763 | unset($this->tags[$key]); |
764 | 764 | $this->mapper->delete($tag); |
765 | 765 | } else { |
766 | - \OCP\Util::writeLog('core', __METHOD__ . 'Cannot delete tag ' . $name |
|
766 | + \OCP\Util::writeLog('core', __METHOD__.'Cannot delete tag '.$name |
|
767 | 767 | . ': not found.', ILogger::ERROR); |
768 | 768 | } |
769 | - if(!is_null($id) && $id !== false) { |
|
769 | + if (!is_null($id) && $id !== false) { |
|
770 | 770 | try { |
771 | - $sql = 'DELETE FROM `' . self::RELATION_TABLE . '` ' |
|
771 | + $sql = 'DELETE FROM `'.self::RELATION_TABLE.'` ' |
|
772 | 772 | . 'WHERE `categoryid` = ?'; |
773 | 773 | $stmt = \OC_DB::prepare($sql); |
774 | 774 | $result = $stmt->execute(array($id)); |
775 | 775 | if ($result === null) { |
776 | 776 | \OCP\Util::writeLog('core', |
777 | - __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), |
|
777 | + __METHOD__.'DB error: '.\OC::$server->getDatabaseConnection()->getError(), |
|
778 | 778 | ILogger::ERROR); |
779 | 779 | return false; |
780 | 780 | } |
781 | - } catch(\Exception $e) { |
|
781 | + } catch (\Exception $e) { |
|
782 | 782 | \OC::$server->getLogger()->logException($e, [ |
783 | 783 | 'message' => __METHOD__, |
784 | 784 | 'level' => ILogger::ERROR, |
@@ -792,8 +792,8 @@ discard block |
||
792 | 792 | } |
793 | 793 | |
794 | 794 | // case-insensitive array_search |
795 | - protected function array_searchi($needle, $haystack, $mem='getName') { |
|
796 | - if(!is_array($haystack)) { |
|
795 | + protected function array_searchi($needle, $haystack, $mem = 'getName') { |
|
796 | + if (!is_array($haystack)) { |
|
797 | 797 | return false; |
798 | 798 | } |
799 | 799 | return array_search(strtolower($needle), array_map( |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->createDatabase($connection); |
54 | 54 | |
55 | 55 | //fill the database if needed |
56 | - $query='select count(*) from information_schema.tables where table_schema=? AND table_name = ?'; |
|
56 | + $query = 'select count(*) from information_schema.tables where table_schema=? AND table_name = ?'; |
|
57 | 57 | $connection->executeQuery($query, [$this->dbName, $this->tablePrefix.'users']); |
58 | 58 | } |
59 | 59 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param \OC\DB\Connection $connection |
62 | 62 | */ |
63 | 63 | private function createDatabase($connection) { |
64 | - try{ |
|
64 | + try { |
|
65 | 65 | $name = $this->dbName; |
66 | 66 | $user = $this->dbUser; |
67 | 67 | //we can't use OC_DB functions here because we need to connect as the administrative user. |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | try { |
81 | 81 | //this query will fail if there aren't the right permissions, ignore the error |
82 | - $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; |
|
82 | + $query = "GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; |
|
83 | 83 | $connection->executeUpdate($query); |
84 | 84 | } catch (\Exception $ex) { |
85 | 85 | $this->logger->logException($ex, [ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @throws \OC\DatabaseSetupException |
96 | 96 | */ |
97 | 97 | private function createDBUser($connection) { |
98 | - try{ |
|
98 | + try { |
|
99 | 99 | $name = $this->dbUser; |
100 | 100 | $password = $this->dbPassword; |
101 | 101 | // we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one, |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; |
106 | 106 | $connection->executeUpdate($query); |
107 | 107 | } |
108 | - catch (\Exception $ex){ |
|
108 | + catch (\Exception $ex) { |
|
109 | 109 | $this->logger->logException($ex, [ |
110 | 110 | 'message' => 'Database user creation failed.', |
111 | 111 | 'level' => ILogger::ERROR, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | //we don't have a dbuser specified in config |
128 | 128 | if ($this->dbUser !== $oldUser) { |
129 | 129 | //add prefix to the admin username to prevent collisions |
130 | - $adminUser = substr('oc_' . $username, 0, 16); |
|
130 | + $adminUser = substr('oc_'.$username, 0, 16); |
|
131 | 131 | |
132 | 132 | $i = 1; |
133 | 133 | while (true) { |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | $this->dbUser = $adminUser; |
145 | 145 | |
146 | 146 | //create a random password so we don't need to store the admin password in the config file |
147 | - $this->dbPassword = $this->random->generate(30); |
|
147 | + $this->dbPassword = $this->random->generate(30); |
|
148 | 148 | |
149 | 149 | $this->createDBUser($connection); |
150 | 150 | |
151 | 151 | break; |
152 | 152 | } else { |
153 | 153 | //repeat with different username |
154 | - $length = strlen((string)$i); |
|
155 | - $adminUser = substr('oc_' . $username, 0, 16 - $length) . $i; |
|
154 | + $length = strlen((string) $i); |
|
155 | + $adminUser = substr('oc_'.$username, 0, 16 - $length).$i; |
|
156 | 156 | $i++; |
157 | 157 | } |
158 | 158 | } else { |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | $apps = self::getEnabledApps(); |
113 | 113 | |
114 | 114 | // Add each apps' folder as allowed class path |
115 | - foreach($apps as $app) { |
|
115 | + foreach ($apps as $app) { |
|
116 | 116 | $path = self::getAppPath($app); |
117 | - if($path !== false) { |
|
117 | + if ($path !== false) { |
|
118 | 118 | self::registerAutoloading($app, $path); |
119 | 119 | } |
120 | 120 | } |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | public static function loadApp(string $app) { |
141 | 141 | self::$loadedApps[] = $app; |
142 | 142 | $appPath = self::getAppPath($app); |
143 | - if($appPath === false) { |
|
143 | + if ($appPath === false) { |
|
144 | 144 | return; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // in case someone calls loadApp() directly |
148 | 148 | self::registerAutoloading($app, $appPath); |
149 | 149 | |
150 | - if (is_file($appPath . '/appinfo/app.php')) { |
|
151 | - \OC::$server->getEventLogger()->start('load_app_' . $app, 'Load app: ' . $app); |
|
150 | + if (is_file($appPath.'/appinfo/app.php')) { |
|
151 | + \OC::$server->getEventLogger()->start('load_app_'.$app, 'Load app: '.$app); |
|
152 | 152 | try { |
153 | 153 | self::requireAppFile($app); |
154 | 154 | } catch (Error $ex) { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | \OC::$server->getAppManager()->disableApp($app); |
159 | 159 | } |
160 | 160 | } |
161 | - \OC::$server->getEventLogger()->end('load_app_' . $app); |
|
161 | + \OC::$server->getEventLogger()->end('load_app_'.$app); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | $info = self::getAppInfo($app); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ? |
205 | 205 | [$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin']; |
206 | 206 | foreach ($plugins as $plugin) { |
207 | - if($plugin['@attributes']['type'] === 'collaborator-search') { |
|
207 | + if ($plugin['@attributes']['type'] === 'collaborator-search') { |
|
208 | 208 | $pluginInfo = [ |
209 | 209 | 'shareType' => $plugin['@attributes']['share-type'], |
210 | 210 | 'class' => $plugin['@value'], |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param string $path |
224 | 224 | */ |
225 | 225 | public static function registerAutoloading(string $app, string $path) { |
226 | - $key = $app . '-' . $path; |
|
227 | - if(isset(self::$alreadyRegistered[$key])) { |
|
226 | + $key = $app.'-'.$path; |
|
227 | + if (isset(self::$alreadyRegistered[$key])) { |
|
228 | 228 | return; |
229 | 229 | } |
230 | 230 | |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); |
235 | 235 | \OC::$server->registerNamespace($app, $appNamespace); |
236 | 236 | |
237 | - if (file_exists($path . '/composer/autoload.php')) { |
|
238 | - require_once $path . '/composer/autoload.php'; |
|
237 | + if (file_exists($path.'/composer/autoload.php')) { |
|
238 | + require_once $path.'/composer/autoload.php'; |
|
239 | 239 | } else { |
240 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); |
|
240 | + \OC::$composerAutoloader->addPsr4($appNamespace.'\\', $path.'/lib/', true); |
|
241 | 241 | // Register on legacy autoloader |
242 | 242 | \OC::$loader->addValidRoot($path); |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Register Test namespace only when testing |
246 | 246 | if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { |
247 | - \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); |
|
247 | + \OC::$composerAutoloader->addPsr4($appNamespace.'\\Tests\\', $path.'/tests/', true); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | private static function requireAppFile(string $app) { |
258 | 258 | // encapsulated here to avoid variable scope conflicts |
259 | - require_once $app . '/appinfo/app.php'; |
|
259 | + require_once $app.'/appinfo/app.php'; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | public static function setAppTypes(string $app) { |
302 | 302 | $appManager = \OC::$server->getAppManager(); |
303 | 303 | $appData = $appManager->getAppInfo($app); |
304 | - if(!is_array($appData)) { |
|
304 | + if (!is_array($appData)) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | } else { |
350 | 350 | $apps = $appManager->getEnabledAppsForUser($user); |
351 | 351 | } |
352 | - $apps = array_filter($apps, function ($app) { |
|
353 | - return $app !== 'files';//we add this manually |
|
352 | + $apps = array_filter($apps, function($app) { |
|
353 | + return $app !== 'files'; //we add this manually |
|
354 | 354 | }); |
355 | 355 | sort($apps); |
356 | 356 | array_unshift($apps, 'files'); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $installer = \OC::$server->query(Installer::class); |
389 | 389 | $isDownloaded = $installer->isDownloaded($appId); |
390 | 390 | |
391 | - if(!$isDownloaded) { |
|
391 | + if (!$isDownloaded) { |
|
392 | 392 | $installer->downloadApp($appId); |
393 | 393 | } |
394 | 394 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | public static function findAppInDirectories(string $appId) { |
441 | 441 | $sanitizedAppId = self::cleanAppId($appId); |
442 | - if($sanitizedAppId !== $appId) { |
|
442 | + if ($sanitizedAppId !== $appId) { |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | static $app_dir = []; |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | |
451 | 451 | $possibleApps = []; |
452 | 452 | foreach (OC::$APPSROOTS as $dir) { |
453 | - if (file_exists($dir['path'] . '/' . $appId)) { |
|
453 | + if (file_exists($dir['path'].'/'.$appId)) { |
|
454 | 454 | $possibleApps[] = $dir; |
455 | 455 | } |
456 | 456 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | } |
492 | 492 | |
493 | 493 | if (($dir = self::findAppInDirectories($appId)) != false) { |
494 | - return $dir['path'] . '/' . $appId; |
|
494 | + return $dir['path'].'/'.$appId; |
|
495 | 495 | } |
496 | 496 | return false; |
497 | 497 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public static function getAppWebPath(string $appId) { |
507 | 507 | if (($dir = self::findAppInDirectories($appId)) != false) { |
508 | - return OC::$WEBROOT . $dir['url'] . '/' . $appId; |
|
508 | + return OC::$WEBROOT.$dir['url'].'/'.$appId; |
|
509 | 509 | } |
510 | 510 | return false; |
511 | 511 | } |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * @return string |
530 | 530 | */ |
531 | 531 | public static function getAppVersionByPath(string $path): string { |
532 | - $infoFile = $path . '/appinfo/info.xml'; |
|
532 | + $infoFile = $path.'/appinfo/info.xml'; |
|
533 | 533 | $appData = \OC::$server->getAppManager()->getAppInfo($infoFile, true); |
534 | 534 | return isset($appData['version']) ? $appData['version'] : ''; |
535 | 535 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * @param string $page |
630 | 630 | */ |
631 | 631 | public static function registerAdmin(string $app, string $page) { |
632 | - self::$adminForms[] = $app . '/' . $page . '.php'; |
|
632 | + self::$adminForms[] = $app.'/'.$page.'.php'; |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | * @param string $page |
639 | 639 | */ |
640 | 640 | public static function registerPersonal(string $app, string $page) { |
641 | - self::$personalForms[] = $app . '/' . $page . '.php'; |
|
641 | + self::$personalForms[] = $app.'/'.$page.'.php'; |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | |
668 | 668 | foreach (OC::$APPSROOTS as $apps_dir) { |
669 | 669 | if (!is_readable($apps_dir['path'])) { |
670 | - \OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], ILogger::WARN); |
|
670 | + \OCP\Util::writeLog('core', 'unable to read app folder : '.$apps_dir['path'], ILogger::WARN); |
|
671 | 671 | continue; |
672 | 672 | } |
673 | 673 | $dh = opendir($apps_dir['path']); |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | if (is_resource($dh)) { |
676 | 676 | while (($file = readdir($dh)) !== false) { |
677 | 677 | |
678 | - if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) { |
|
678 | + if ($file[0] != '.' and is_dir($apps_dir['path'].'/'.$file) and is_file($apps_dir['path'].'/'.$file.'/appinfo/info.xml')) { |
|
679 | 679 | |
680 | 680 | $apps[] = $file; |
681 | 681 | } |
@@ -708,12 +708,12 @@ discard block |
||
708 | 708 | |
709 | 709 | $info = OC_App::getAppInfo($app, false, $langCode); |
710 | 710 | if (!is_array($info)) { |
711 | - \OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR); |
|
711 | + \OCP\Util::writeLog('core', 'Could not read app info file for app "'.$app.'"', ILogger::ERROR); |
|
712 | 712 | continue; |
713 | 713 | } |
714 | 714 | |
715 | 715 | if (!isset($info['name'])) { |
716 | - \OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', ILogger::ERROR); |
|
716 | + \OCP\Util::writeLog('core', 'App id "'.$app.'" has no name in appinfo', ILogger::ERROR); |
|
717 | 717 | continue; |
718 | 718 | } |
719 | 719 | |
@@ -740,13 +740,13 @@ discard block |
||
740 | 740 | } |
741 | 741 | |
742 | 742 | $appPath = self::getAppPath($app); |
743 | - if($appPath !== false) { |
|
744 | - $appIcon = $appPath . '/img/' . $app . '.svg'; |
|
743 | + if ($appPath !== false) { |
|
744 | + $appIcon = $appPath.'/img/'.$app.'.svg'; |
|
745 | 745 | if (file_exists($appIcon)) { |
746 | - $info['preview'] = $urlGenerator->imagePath($app, $app . '.svg'); |
|
746 | + $info['preview'] = $urlGenerator->imagePath($app, $app.'.svg'); |
|
747 | 747 | $info['previewAsIcon'] = true; |
748 | 748 | } else { |
749 | - $appIcon = $appPath . '/img/app.svg'; |
|
749 | + $appIcon = $appPath.'/img/app.svg'; |
|
750 | 750 | if (file_exists($appIcon)) { |
751 | 751 | $info['preview'] = $urlGenerator->imagePath($app, 'app.svg'); |
752 | 752 | $info['previewAsIcon'] = true; |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | public static function getAppVersions() { |
868 | 868 | static $versions; |
869 | 869 | |
870 | - if(!$versions) { |
|
870 | + if (!$versions) { |
|
871 | 871 | $appConfig = \OC::$server->getAppConfig(); |
872 | 872 | $versions = $appConfig->getValues(false, 'installed_version'); |
873 | 873 | } |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | */ |
883 | 883 | public static function updateApp(string $appId): bool { |
884 | 884 | $appPath = self::getAppPath($appId); |
885 | - if($appPath === false) { |
|
885 | + if ($appPath === false) { |
|
886 | 886 | return false; |
887 | 887 | } |
888 | 888 | self::registerAutoloading($appId, $appPath); |
@@ -890,8 +890,8 @@ discard block |
||
890 | 890 | $appData = self::getAppInfo($appId); |
891 | 891 | self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']); |
892 | 892 | |
893 | - if (file_exists($appPath . '/appinfo/database.xml')) { |
|
894 | - OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml'); |
|
893 | + if (file_exists($appPath.'/appinfo/database.xml')) { |
|
894 | + OC_DB::updateDbFromStructure($appPath.'/appinfo/database.xml'); |
|
895 | 895 | } else { |
896 | 896 | $ms = new MigrationService($appId, \OC::$server->getDatabaseConnection()); |
897 | 897 | $ms->migrate(); |
@@ -903,23 +903,23 @@ discard block |
||
903 | 903 | \OC::$server->getAppManager()->getAppVersion($appId, false); |
904 | 904 | |
905 | 905 | // run upgrade code |
906 | - if (file_exists($appPath . '/appinfo/update.php')) { |
|
906 | + if (file_exists($appPath.'/appinfo/update.php')) { |
|
907 | 907 | self::loadApp($appId); |
908 | - include $appPath . '/appinfo/update.php'; |
|
908 | + include $appPath.'/appinfo/update.php'; |
|
909 | 909 | } |
910 | 910 | self::setupBackgroundJobs($appData['background-jobs']); |
911 | 911 | |
912 | 912 | //set remote/public handlers |
913 | 913 | if (array_key_exists('ocsid', $appData)) { |
914 | 914 | \OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']); |
915 | - } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
915 | + } elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) { |
|
916 | 916 | \OC::$server->getConfig()->deleteAppValue($appId, 'ocsid'); |
917 | 917 | } |
918 | 918 | foreach ($appData['remote'] as $name => $path) { |
919 | - \OC::$server->getConfig()->setAppValue('core', 'remote_' . $name, $appId . '/' . $path); |
|
919 | + \OC::$server->getConfig()->setAppValue('core', 'remote_'.$name, $appId.'/'.$path); |
|
920 | 920 | } |
921 | 921 | foreach ($appData['public'] as $name => $path) { |
922 | - \OC::$server->getConfig()->setAppValue('core', 'public_' . $name, $appId . '/' . $path); |
|
922 | + \OC::$server->getConfig()->setAppValue('core', 'public_'.$name, $appId.'/'.$path); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | self::setAppTypes($appId); |
@@ -989,17 +989,17 @@ discard block |
||
989 | 989 | public static function getStorage(string $appId) { |
990 | 990 | if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check |
991 | 991 | if (\OC::$server->getUserSession()->isLoggedIn()) { |
992 | - $view = new \OC\Files\View('/' . OC_User::getUser()); |
|
992 | + $view = new \OC\Files\View('/'.OC_User::getUser()); |
|
993 | 993 | if (!$view->file_exists($appId)) { |
994 | 994 | $view->mkdir($appId); |
995 | 995 | } |
996 | - return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId); |
|
996 | + return new \OC\Files\View('/'.OC_User::getUser().'/'.$appId); |
|
997 | 997 | } else { |
998 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', ILogger::ERROR); |
|
998 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.', user not logged in', ILogger::ERROR); |
|
999 | 999 | return false; |
1000 | 1000 | } |
1001 | 1001 | } else { |
1002 | - \OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', ILogger::ERROR); |
|
1002 | + \OCP\Util::writeLog('core', 'Can\'t get app storage, app '.$appId.' not enabled', ILogger::ERROR); |
|
1003 | 1003 | return false; |
1004 | 1004 | } |
1005 | 1005 | } |
@@ -1036,9 +1036,9 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | if ($attributeLang === $similarLang) { |
1038 | 1038 | $similarLangFallback = $option['@value']; |
1039 | - } else if (strpos($attributeLang, $similarLang . '_') === 0) { |
|
1039 | + } else if (strpos($attributeLang, $similarLang.'_') === 0) { |
|
1040 | 1040 | if ($similarLangFallback === false) { |
1041 | - $similarLangFallback = $option['@value']; |
|
1041 | + $similarLangFallback = $option['@value']; |
|
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | } else { |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | $data['description'] = trim(self::findBestL10NOption($data['description'], $lang)); |
1074 | 1074 | } else if (isset($data['description']) && is_string($data['description'])) { |
1075 | 1075 | $data['description'] = trim($data['description']); |
1076 | - } else { |
|
1076 | + } else { |
|
1077 | 1077 | $data['description'] = ''; |
1078 | 1078 | } |
1079 | 1079 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | case 'database': |
92 | 92 | case 'mysql': |
93 | 93 | case 'sqlite': |
94 | - \OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', ILogger::DEBUG); |
|
94 | + \OCP\Util::writeLog('core', 'Adding user backend '.$backend.'.', ILogger::DEBUG); |
|
95 | 95 | self::$_usedBackends[$backend] = new \OC\User\Database(); |
96 | 96 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
97 | 97 | break; |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
101 | 101 | break; |
102 | 102 | default: |
103 | - \OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', ILogger::DEBUG); |
|
104 | - $className = 'OC_USER_' . strtoupper($backend); |
|
103 | + \OCP\Util::writeLog('core', 'Adding default user backend '.$backend.'.', ILogger::DEBUG); |
|
104 | + $className = 'OC_USER_'.strtoupper($backend); |
|
105 | 105 | self::$_usedBackends[$backend] = new $className(); |
106 | 106 | \OC::$server->getUserManager()->registerBackend(self::$_usedBackends[$backend]); |
107 | 107 | break; |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | self::useBackend($backend); |
146 | 146 | self::$_setupedBackends[] = $i; |
147 | 147 | } else { |
148 | - \OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', ILogger::DEBUG); |
|
148 | + \OCP\Util::writeLog('core', 'User backend '.$class.' already initialized.', ILogger::DEBUG); |
|
149 | 149 | } |
150 | 150 | } else { |
151 | - \OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', ILogger::ERROR); |
|
151 | + \OCP\Util::writeLog('core', 'User backend '.$class.' not found.', ILogger::ERROR); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | if ($user) { |
367 | 367 | return $user->getHome(); |
368 | 368 | } else { |
369 | - return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid; |
|
369 | + return \OC::$server->getSystemConfig()->getValue('datadirectory', OC::$SERVERROOT.'/data').'/'.$uid; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | private static function sendHeaders($filename, $name, array $rangeArray) { |
77 | 77 | OC_Response::setContentDispositionHeader($name, 'attachment'); |
78 | 78 | header('Content-Transfer-Encoding: binary', true); |
79 | - header('Pragma: public');// enable caching in IE |
|
79 | + header('Pragma: public'); // enable caching in IE |
|
80 | 80 | header('Expires: 0'); |
81 | 81 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
82 | 82 | $fileSize = \OC\Files\Filesystem::filesize($filename); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | if (!is_array($files)) { |
123 | - $filename = $dir . '/' . $files; |
|
123 | + $filename = $dir.'/'.$files; |
|
124 | 124 | if (!$view->is_dir($filename)) { |
125 | 125 | self::getSingleFile($view, $dir, $files, is_null($params) ? array() : $params); |
126 | 126 | return; |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | $name = $basename; |
136 | 136 | } |
137 | 137 | |
138 | - $filename = $dir . '/' . $name; |
|
138 | + $filename = $dir.'/'.$name; |
|
139 | 139 | } else { |
140 | - $filename = $dir . '/' . $files; |
|
140 | + $filename = $dir.'/'.$files; |
|
141 | 141 | $getType = self::ZIP_DIR; |
142 | 142 | // downloading root ? |
143 | 143 | if ($files !== '') { |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | $fileInfos = array(); |
153 | 153 | $fileSize = 0; |
154 | 154 | foreach ($files as $file) { |
155 | - $fileInfo = \OC\Files\Filesystem::getFileInfo($dir . '/' . $file); |
|
155 | + $fileInfo = \OC\Files\Filesystem::getFileInfo($dir.'/'.$file); |
|
156 | 156 | $fileSize += $fileInfo->getSize(); |
157 | 157 | $fileInfos[] = $fileInfo; |
158 | 158 | } |
159 | 159 | $numberOfFiles = self::getNumberOfFiles($fileInfos); |
160 | 160 | } elseif ($getType === self::ZIP_DIR) { |
161 | - $fileInfo = \OC\Files\Filesystem::getFileInfo($dir . '/' . $files); |
|
161 | + $fileInfo = \OC\Files\Filesystem::getFileInfo($dir.'/'.$files); |
|
162 | 162 | $fileSize = $fileInfo->getSize(); |
163 | 163 | $numberOfFiles = self::getNumberOfFiles(array($fileInfo)); |
164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | OC_Util::obEnd(); |
168 | 168 | |
169 | 169 | $streamer->sendHeaders($name); |
170 | - $executionTime = (int)OC::$server->getIniWrapper()->getNumeric('max_execution_time'); |
|
170 | + $executionTime = (int) OC::$server->getIniWrapper()->getNumeric('max_execution_time'); |
|
171 | 171 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
172 | 172 | @set_time_limit(0); |
173 | 173 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | if ($getType === self::ZIP_FILES) { |
177 | 177 | foreach ($files as $file) { |
178 | - $file = $dir . '/' . $file; |
|
178 | + $file = $dir.'/'.$file; |
|
179 | 179 | if (\OC\Files\Filesystem::is_file($file)) { |
180 | 180 | $fileSize = \OC\Files\Filesystem::filesize($file); |
181 | 181 | $fileTime = \OC\Files\Filesystem::filemtime($file); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | } |
189 | 189 | } elseif ($getType === self::ZIP_DIR) { |
190 | - $file = $dir . '/' . $files; |
|
190 | + $file = $dir.'/'.$files; |
|
191 | 191 | $streamer->addDirRecursive($file); |
192 | 192 | } |
193 | 193 | $streamer->finalize(); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @return array $rangeArray ('from'=>int,'to'=>int), ... |
220 | 220 | */ |
221 | 221 | private static function parseHttpRangeHeader($rangeHeaderPos, $fileSize) { |
222 | - $rArray=explode(',', $rangeHeaderPos); |
|
222 | + $rArray = explode(',', $rangeHeaderPos); |
|
223 | 223 | $minOffset = 0; |
224 | 224 | $ind = 0; |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | if ($ranges[0] < $minOffset) { // case: bytes=500-700,601-999 |
232 | 232 | $ranges[0] = $minOffset; |
233 | 233 | } |
234 | - if ($ind > 0 && $rangeArray[$ind-1]['to']+1 == $ranges[0]) { // case: bytes=500-600,601-999 |
|
234 | + if ($ind > 0 && $rangeArray[$ind - 1]['to'] + 1 == $ranges[0]) { // case: bytes=500-600,601-999 |
|
235 | 235 | $ind--; |
236 | 236 | $ranges[0] = $rangeArray[$ind]['from']; |
237 | 237 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | if (is_numeric($ranges[0]) && is_numeric($ranges[1]) && $ranges[0] < $fileSize && $ranges[0] <= $ranges[1]) { |
241 | 241 | // case: x-x |
242 | 242 | if ($ranges[1] >= $fileSize) { |
243 | - $ranges[1] = $fileSize-1; |
|
243 | + $ranges[1] = $fileSize - 1; |
|
244 | 244 | } |
245 | - $rangeArray[$ind++] = array( 'from' => $ranges[0], 'to' => $ranges[1], 'size' => $fileSize ); |
|
245 | + $rangeArray[$ind++] = array('from' => $ranges[0], 'to' => $ranges[1], 'size' => $fileSize); |
|
246 | 246 | $minOffset = $ranges[1] + 1; |
247 | 247 | if ($minOffset >= $fileSize) { |
248 | 248 | break; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | elseif (is_numeric($ranges[0]) && $ranges[0] < $fileSize) { |
252 | 252 | // case: x- |
253 | - $rangeArray[$ind++] = array( 'from' => $ranges[0], 'to' => $fileSize-1, 'size' => $fileSize ); |
|
253 | + $rangeArray[$ind++] = array('from' => $ranges[0], 'to' => $fileSize - 1, 'size' => $fileSize); |
|
254 | 254 | break; |
255 | 255 | } |
256 | 256 | elseif (is_numeric($ranges[1])) { |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | if ($ranges[1] > $fileSize) { |
259 | 259 | $ranges[1] = $fileSize; |
260 | 260 | } |
261 | - $rangeArray[$ind++] = array( 'from' => $fileSize-$ranges[1], 'to' => $fileSize-1, 'size' => $fileSize ); |
|
261 | + $rangeArray[$ind++] = array('from' => $fileSize - $ranges[1], 'to' => $fileSize - 1, 'size' => $fileSize); |
|
262 | 262 | break; |
263 | 263 | } |
264 | 264 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param array $params ; 'head' boolean to only send header of the request ; 'range' http range header |
273 | 273 | */ |
274 | 274 | private static function getSingleFile($view, $dir, $name, $params) { |
275 | - $filename = $dir . '/' . $name; |
|
275 | + $filename = $dir.'/'.$name; |
|
276 | 276 | OC_Util::obEnd(); |
277 | 277 | $view->lockFile($filename, ILockingProvider::LOCK_SHARED); |
278 | 278 | |
@@ -361,17 +361,17 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function lockFiles($view, $dir, $files) { |
363 | 363 | if (!is_array($files)) { |
364 | - $file = $dir . '/' . $files; |
|
364 | + $file = $dir.'/'.$files; |
|
365 | 365 | $files = [$file]; |
366 | 366 | } |
367 | 367 | foreach ($files as $file) { |
368 | - $file = $dir . '/' . $file; |
|
368 | + $file = $dir.'/'.$file; |
|
369 | 369 | $view->lockFile($file, ILockingProvider::LOCK_SHARED); |
370 | 370 | if ($view->is_dir($file)) { |
371 | 371 | $contents = $view->getDirectoryContent($file); |
372 | 372 | $contents = array_map(function($fileInfo) use ($file) { |
373 | 373 | /** @var \OCP\Files\FileInfo $fileInfo */ |
374 | - return $file . '/' . $fileInfo->getName(); |
|
374 | + return $file.'/'.$fileInfo->getName(); |
|
375 | 375 | }, $contents); |
376 | 376 | self::lockFiles($view, $dir, $contents); |
377 | 377 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public static function setUploadLimit($size, $files = []) { |
389 | 389 | //don't allow user to break his config |
390 | - $size = (int)$size; |
|
390 | + $size = (int) $size; |
|
391 | 391 | if ($size < self::UPLOAD_MIN_LIMIT_BYTES) { |
392 | 392 | return false; |
393 | 393 | } |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | |
401 | 401 | // default locations if not overridden by $files |
402 | 402 | $files = array_merge([ |
403 | - '.htaccess' => OC::$SERVERROOT . '/.htaccess', |
|
404 | - '.user.ini' => OC::$SERVERROOT . '/.user.ini' |
|
403 | + '.htaccess' => OC::$SERVERROOT.'/.htaccess', |
|
404 | + '.user.ini' => OC::$SERVERROOT.'/.user.ini' |
|
405 | 405 | ], $files); |
406 | 406 | |
407 | 407 | $updateFiles = [ |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $handle = @fopen($filename, 'r+'); |
423 | 423 | if (!$handle) { |
424 | 424 | \OCP\Util::writeLog('files', |
425 | - 'Can\'t write upload limit to ' . $filename . '. Please check the file permissions', |
|
425 | + 'Can\'t write upload limit to '.$filename.'. Please check the file permissions', |
|
426 | 426 | ILogger::WARN); |
427 | 427 | $success = false; |
428 | 428 | continue; // try to update as many files as possible |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $content = $newContent; |
443 | 443 | } |
444 | 444 | if ($hasReplaced === 0) { |
445 | - $content .= "\n" . $setting; |
|
445 | + $content .= "\n".$setting; |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 | |
@@ -473,12 +473,12 @@ discard block |
||
473 | 473 | } |
474 | 474 | if ($getType === self::ZIP_FILES) { |
475 | 475 | foreach ($files as $file) { |
476 | - $file = $dir . '/' . $file; |
|
476 | + $file = $dir.'/'.$file; |
|
477 | 477 | $view->unlockFile($file, ILockingProvider::LOCK_SHARED); |
478 | 478 | } |
479 | 479 | } |
480 | 480 | if ($getType === self::ZIP_DIR) { |
481 | - $file = $dir . '/' . $files; |
|
481 | + $file = $dir.'/'.$files; |
|
482 | 482 | $view->unlockFile($file, ILockingProvider::LOCK_SHARED); |
483 | 483 | } |
484 | 484 | } |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | throw new \Exception("Access Key, Secret and Bucket have to be configured."); |
53 | 53 | } |
54 | 54 | |
55 | - $this->id = 'amazon::' . $params['bucket']; |
|
55 | + $this->id = 'amazon::'.$params['bucket']; |
|
56 | 56 | |
57 | 57 | $this->test = isset($params['test']); |
58 | 58 | $this->bucket = $params['bucket']; |
59 | 59 | $this->timeout = !isset($params['timeout']) ? 15 : $params['timeout']; |
60 | 60 | $params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region']; |
61 | - $params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname']; |
|
61 | + $params['hostname'] = empty($params['hostname']) ? 's3.'.$params['region'].'.amazonaws.com' : $params['hostname']; |
|
62 | 62 | if (!isset($params['port']) || $params['port'] === '') { |
63 | 63 | $params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443; |
64 | 64 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | $scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https'; |
81 | - $base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/'; |
|
81 | + $base_url = $scheme.'://'.$this->params['hostname'].':'.$this->params['port'].'/'; |
|
82 | 82 | |
83 | 83 | $options = [ |
84 | 84 | 'version' => isset($this->params['version']) ? $this->params['version'] : 'latest', |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | $this->connection = new S3Client($options); |
101 | 101 | |
102 | 102 | if (!$this->connection->isBucketDnsCompatible($this->bucket)) { |
103 | - throw new \Exception("The configured bucket name is invalid: " . $this->bucket); |
|
103 | + throw new \Exception("The configured bucket name is invalid: ".$this->bucket); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | if (!$this->connection->doesBucketExist($this->bucket)) { |
107 | 107 | $logger = \OC::$server->getLogger(); |
108 | 108 | try { |
109 | - $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']); |
|
109 | + $logger->info('Bucket "'.$this->bucket.'" does not exist - creating it.', ['app' => 'objectstore']); |
|
110 | 110 | $this->connection->createBucket(array( |
111 | 111 | 'Bucket' => $this->bucket |
112 | 112 | )); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'level' => ILogger::DEBUG, |
118 | 118 | 'app' => 'objectstore', |
119 | 119 | ]); |
120 | - throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); |
|
120 | + throw new \Exception('Creation of bucket "'.$this->bucket.'" failed. '.$e->getMessage()); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 |