@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param array $params |
| 34 | 34 | */ |
| 35 | 35 | public function __construct($params) { |
| 36 | - if (! isset($params['user']) || ! $params['user'] instanceof User) { |
|
| 36 | + if (!isset($params['user']) || !$params['user'] instanceof User) { |
|
| 37 | 37 | throw new \Exception('missing user object in parameters'); |
| 38 | 38 | } |
| 39 | 39 | $this->user = $params['user']; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function getId() { |
| 44 | - return 'object::user:' . $this->user->getUID(); |
|
| 44 | + return 'object::user:'.$this->user->getUID(); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | return true; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1; |
|
| 74 | + $size = isset($queryParams['size']) ? (int) $queryParams['size'] : -1; |
|
| 75 | 75 | |
| 76 | 76 | $path = $request->getPath(); |
| 77 | 77 | $node = $this->server->tree->getNodeForPath($path); |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | ?> |
| 7 | 7 | |
| 8 | 8 | -- |
| 9 | -<?php p($theme->getName() . ' - ' . $theme->getSlogan()); ?> |
|
| 9 | +<?php p($theme->getName().' - '.$theme->getSlogan()); ?> |
|
| 10 | 10 | <?php print_unescaped("\n".$theme->getBaseUrl()); |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | * @deprecated 14.0.0 |
| 91 | 91 | */ |
| 92 | 92 | public static function streamCopy($source, $target) { |
| 93 | - list($count, ) = \OC_Helper::streamCopy($source, $target); |
|
| 93 | + list($count,) = \OC_Helper::streamCopy($source, $target); |
|
| 94 | 94 | return $count; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | * mapped to queries without using sql |
| 59 | 59 | * @since 14.0.0 |
| 60 | 60 | */ |
| 61 | - public function __construct(IDBConnection $db, string $tableName, string $entityClass=null) { |
|
| 61 | + public function __construct(IDBConnection $db, string $tableName, string $entityClass = null) { |
|
| 62 | 62 | $this->db = $db; |
| 63 | 63 | $this->tableName = $tableName; |
| 64 | 64 | |
| 65 | 65 | // if not given set the entity name to the class without the mapper part |
| 66 | 66 | // cache it here for later use since reflection is slow |
| 67 | - if($entityClass === null) { |
|
| 67 | + if ($entityClass === null) { |
|
| 68 | 68 | $this->entityClass = str_replace('Mapper', '', \get_class($this)); |
| 69 | 69 | } else { |
| 70 | 70 | $this->entityClass = $entityClass; |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | $qb->insert($this->tableName); |
| 118 | 118 | |
| 119 | 119 | // build the fields |
| 120 | - foreach($properties as $property => $updated) { |
|
| 120 | + foreach ($properties as $property => $updated) { |
|
| 121 | 121 | $column = $entity->propertyToColumn($property); |
| 122 | - $getter = 'get' . ucfirst($property); |
|
| 122 | + $getter = 'get'.ucfirst($property); |
|
| 123 | 123 | $value = $entity->$getter(); |
| 124 | 124 | |
| 125 | 125 | $type = $this->getParameterTypeForProperty($entity, $property); |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $qb->execute(); |
| 130 | 130 | |
| 131 | - if($entity->id === null) { |
|
| 131 | + if ($entity->id === null) { |
|
| 132 | 132 | // When autoincrement is used id is always an int |
| 133 | - $entity->setId((int)$qb->getLastInsertId()); |
|
| 133 | + $entity->setId((int) $qb->getLastInsertId()); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | return $entity; |
@@ -166,13 +166,13 @@ discard block |
||
| 166 | 166 | public function update(Entity $entity): Entity { |
| 167 | 167 | // if entity wasn't changed it makes no sense to run a db query |
| 168 | 168 | $properties = $entity->getUpdatedFields(); |
| 169 | - if(\count($properties) === 0) { |
|
| 169 | + if (\count($properties) === 0) { |
|
| 170 | 170 | return $entity; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // entity needs an id |
| 174 | 174 | $id = $entity->getId(); |
| 175 | - if($id === null){ |
|
| 175 | + if ($id === null) { |
|
| 176 | 176 | throw new \InvalidArgumentException( |
| 177 | 177 | 'Entity which should be updated has no id'); |
| 178 | 178 | } |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | $qb->update($this->tableName); |
| 187 | 187 | |
| 188 | 188 | // build the fields |
| 189 | - foreach($properties as $property => $updated) { |
|
| 189 | + foreach ($properties as $property => $updated) { |
|
| 190 | 190 | $column = $entity->propertyToColumn($property); |
| 191 | - $getter = 'get' . ucfirst($property); |
|
| 191 | + $getter = 'get'.ucfirst($property); |
|
| 192 | 192 | $value = $entity->$getter(); |
| 193 | 193 | |
| 194 | 194 | $type = $this->getParameterTypeForProperty($entity, $property); |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | protected function getParameterTypeForProperty(Entity $entity, string $property): int { |
| 218 | 218 | $types = $entity->getFieldTypes(); |
| 219 | 219 | |
| 220 | - if(!isset($types[ $property ])) { |
|
| 220 | + if (!isset($types[$property])) { |
|
| 221 | 221 | return IQueryBuilder::PARAM_STR; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - switch($types[ $property ]) { |
|
| 224 | + switch ($types[$property]) { |
|
| 225 | 225 | case 'int': |
| 226 | 226 | case 'integer': |
| 227 | 227 | return IQueryBuilder::PARAM_INT; |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $cursor = $query->execute(); |
| 252 | 252 | |
| 253 | 253 | $row = $cursor->fetch(); |
| 254 | - if($row === false) { |
|
| 254 | + if ($row === false) { |
|
| 255 | 255 | $cursor->closeCursor(); |
| 256 | 256 | $msg = $this->buildDebugMessage( |
| 257 | 257 | 'Did expect one result but found none when executing', $query |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $row2 = $cursor->fetch(); |
| 263 | 263 | $cursor->closeCursor(); |
| 264 | - if($row2 !== false) { |
|
| 264 | + if ($row2 !== false) { |
|
| 265 | 265 | $msg = $this->buildDebugMessage( |
| 266 | 266 | 'Did not expect more than one result when executing', $query |
| 267 | 267 | ); |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | * @since 14.0.0 |
| 279 | 279 | */ |
| 280 | 280 | private function buildDebugMessage(string $msg, IQueryBuilder $sql): string { |
| 281 | - return $msg . |
|
| 282 | - ': query "' . $sql->getSQL() . '"; '; |
|
| 281 | + return $msg. |
|
| 282 | + ': query "'.$sql->getSQL().'"; '; |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | * @since 14.0.0 |
| 293 | 293 | */ |
| 294 | 294 | protected function mapRowToEntity(array $row): Entity { |
| 295 | - return \call_user_func($this->entityClass .'::fromRow', $row); |
|
| 295 | + return \call_user_func($this->entityClass.'::fromRow', $row); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | $entities = []; |
| 310 | 310 | |
| 311 | - while($row = $cursor->fetch()){ |
|
| 311 | + while ($row = $cursor->fetch()) { |
|
| 312 | 312 | $entities[] = $this->mapRowToEntity($row); |
| 313 | 313 | } |
| 314 | 314 | |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | * @since 7.0.0 |
| 50 | 50 | * @deprecated 14.0.0 Move over to QBMapper |
| 51 | 51 | */ |
| 52 | - public function __construct(IDBConnection $db, $tableName, $entityClass=null) { |
|
| 52 | + public function __construct(IDBConnection $db, $tableName, $entityClass = null) { |
|
| 53 | 53 | $this->db = $db; |
| 54 | - $this->tableName = '*PREFIX*' . $tableName; |
|
| 54 | + $this->tableName = '*PREFIX*'.$tableName; |
|
| 55 | 55 | |
| 56 | 56 | // if not given set the entity name to the class without the mapper part |
| 57 | 57 | // cache it here for later use since reflection is slow |
| 58 | - if($entityClass === null) { |
|
| 58 | + if ($entityClass === null) { |
|
| 59 | 59 | $this->entityClass = str_replace('Mapper', '', get_class($this)); |
| 60 | 60 | } else { |
| 61 | 61 | $this->entityClass = $entityClass; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @deprecated 14.0.0 Move over to QBMapper |
| 82 | 82 | */ |
| 83 | 83 | public function delete(Entity $entity) { |
| 84 | - $sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?'; |
|
| 84 | + $sql = 'DELETE FROM `'.$this->tableName.'` WHERE `id` = ?'; |
|
| 85 | 85 | $stmt = $this->execute($sql, [$entity->getId()]); |
| 86 | 86 | $stmt->closeCursor(); |
| 87 | 87 | return $entity; |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // build the fields |
| 107 | 107 | $i = 0; |
| 108 | - foreach($properties as $property => $updated) { |
|
| 108 | + foreach ($properties as $property => $updated) { |
|
| 109 | 109 | $column = $entity->propertyToColumn($property); |
| 110 | - $getter = 'get' . ucfirst($property); |
|
| 110 | + $getter = 'get'.ucfirst($property); |
|
| 111 | 111 | |
| 112 | - $columns .= '`' . $column . '`'; |
|
| 112 | + $columns .= '`'.$column.'`'; |
|
| 113 | 113 | $values .= '?'; |
| 114 | 114 | |
| 115 | 115 | // only append colon if there are more entries |
| 116 | - if($i < count($properties)-1){ |
|
| 116 | + if ($i < count($properties) - 1) { |
|
| 117 | 117 | $columns .= ','; |
| 118 | 118 | $values .= ','; |
| 119 | 119 | } |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $sql = 'INSERT INTO `' . $this->tableName . '`(' . |
|
| 127 | - $columns . ') VALUES(' . $values . ')'; |
|
| 126 | + $sql = 'INSERT INTO `'.$this->tableName.'`('. |
|
| 127 | + $columns.') VALUES('.$values.')'; |
|
| 128 | 128 | |
| 129 | 129 | $stmt = $this->execute($sql, $params); |
| 130 | 130 | |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | public function update(Entity $entity) { |
| 149 | 149 | // if entity wasn't changed it makes no sense to run a db query |
| 150 | 150 | $properties = $entity->getUpdatedFields(); |
| 151 | - if(count($properties) === 0) { |
|
| 151 | + if (count($properties) === 0) { |
|
| 152 | 152 | return $entity; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // entity needs an id |
| 156 | 156 | $id = $entity->getId(); |
| 157 | - if($id === null){ |
|
| 157 | + if ($id === null) { |
|
| 158 | 158 | throw new \InvalidArgumentException( |
| 159 | 159 | 'Entity which should be updated has no id'); |
| 160 | 160 | } |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | // build the fields |
| 171 | 171 | $i = 0; |
| 172 | - foreach($properties as $property => $updated) { |
|
| 172 | + foreach ($properties as $property => $updated) { |
|
| 173 | 173 | |
| 174 | 174 | $column = $entity->propertyToColumn($property); |
| 175 | - $getter = 'get' . ucfirst($property); |
|
| 175 | + $getter = 'get'.ucfirst($property); |
|
| 176 | 176 | |
| 177 | - $columns .= '`' . $column . '` = ?'; |
|
| 177 | + $columns .= '`'.$column.'` = ?'; |
|
| 178 | 178 | |
| 179 | 179 | // only append colon if there are more entries |
| 180 | - if($i < count($properties)-1){ |
|
| 180 | + if ($i < count($properties) - 1) { |
|
| 181 | 181 | $columns .= ','; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | $i++; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - $sql = 'UPDATE `' . $this->tableName . '` SET ' . |
|
| 189 | - $columns . ' WHERE `id` = ?'; |
|
| 188 | + $sql = 'UPDATE `'.$this->tableName.'` SET '. |
|
| 189 | + $columns.' WHERE `id` = ?'; |
|
| 190 | 190 | $params[] = $id; |
| 191 | 191 | |
| 192 | 192 | $stmt = $this->execute($sql, $params); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @since 7.0.0 |
| 236 | 236 | * @deprecated 14.0.0 Move over to QBMapper |
| 237 | 237 | */ |
| 238 | - protected function execute($sql, array $params=[], $limit=null, $offset=null) { |
|
| 238 | + protected function execute($sql, array $params = [], $limit = null, $offset = null) { |
|
| 239 | 239 | $query = $this->db->prepare($sql, $limit, $offset); |
| 240 | 240 | |
| 241 | 241 | if ($this->isAssocArray($params)) { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $query->bindValue($key, $param, $pdoConstant); |
| 245 | 245 | } |
| 246 | 246 | } else { |
| 247 | - $index = 1; // bindParam is 1 indexed |
|
| 247 | + $index = 1; // bindParam is 1 indexed |
|
| 248 | 248 | foreach ($params as $param) { |
| 249 | 249 | $pdoConstant = $this->getPDOType($param); |
| 250 | 250 | $query->bindValue($index, $param, $pdoConstant); |
@@ -271,11 +271,11 @@ discard block |
||
| 271 | 271 | * @since 7.0.0 |
| 272 | 272 | * @deprecated 14.0.0 Move over to QBMapper |
| 273 | 273 | */ |
| 274 | - protected function findOneQuery($sql, array $params=[], $limit=null, $offset=null) { |
|
| 274 | + protected function findOneQuery($sql, array $params = [], $limit = null, $offset = null) { |
|
| 275 | 275 | $stmt = $this->execute($sql, $params, $limit, $offset); |
| 276 | 276 | $row = $stmt->fetch(); |
| 277 | 277 | |
| 278 | - if($row === false || $row === null){ |
|
| 278 | + if ($row === false || $row === null) { |
|
| 279 | 279 | $stmt->closeCursor(); |
| 280 | 280 | $msg = $this->buildDebugMessage( |
| 281 | 281 | 'Did expect one result but found none when executing', $sql, $params, $limit, $offset |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $row2 = $stmt->fetch(); |
| 286 | 286 | $stmt->closeCursor(); |
| 287 | 287 | //MDB2 returns null, PDO and doctrine false when no row is available |
| 288 | - if(! ($row2 === false || $row2 === null)) { |
|
| 288 | + if (!($row2 === false || $row2 === null)) { |
|
| 289 | 289 | $msg = $this->buildDebugMessage( |
| 290 | 290 | 'Did not expect more than one result when executing', $sql, $params, $limit, $offset |
| 291 | 291 | ); |
@@ -307,12 +307,12 @@ discard block |
||
| 307 | 307 | * @since 9.1.0 |
| 308 | 308 | * @deprecated 14.0.0 Move over to QBMapper |
| 309 | 309 | */ |
| 310 | - private function buildDebugMessage($msg, $sql, array $params=[], $limit=null, $offset=null) { |
|
| 311 | - return $msg . |
|
| 312 | - ': query "' . $sql . '"; ' . |
|
| 313 | - 'parameters ' . print_r($params, true) . '; ' . |
|
| 314 | - 'limit "' . $limit . '"; '. |
|
| 315 | - 'offset "' . $offset . '"'; |
|
| 310 | + private function buildDebugMessage($msg, $sql, array $params = [], $limit = null, $offset = null) { |
|
| 311 | + return $msg. |
|
| 312 | + ': query "'.$sql.'"; '. |
|
| 313 | + 'parameters '.print_r($params, true).'; '. |
|
| 314 | + 'limit "'.$limit.'"; '. |
|
| 315 | + 'offset "'.$offset.'"'; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @deprecated 14.0.0 Move over to QBMapper |
| 326 | 326 | */ |
| 327 | 327 | protected function mapRowToEntity($row) { |
| 328 | - return call_user_func($this->entityClass .'::fromRow', $row); |
|
| 328 | + return call_user_func($this->entityClass.'::fromRow', $row); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -339,12 +339,12 @@ discard block |
||
| 339 | 339 | * @since 7.0.0 |
| 340 | 340 | * @deprecated 14.0.0 Move over to QBMapper |
| 341 | 341 | */ |
| 342 | - protected function findEntities($sql, array $params=[], $limit=null, $offset=null) { |
|
| 342 | + protected function findEntities($sql, array $params = [], $limit = null, $offset = null) { |
|
| 343 | 343 | $stmt = $this->execute($sql, $params, $limit, $offset); |
| 344 | 344 | |
| 345 | 345 | $entities = []; |
| 346 | 346 | |
| 347 | - while($row = $stmt->fetch()){ |
|
| 347 | + while ($row = $stmt->fetch()) { |
|
| 348 | 348 | $entities[] = $this->mapRowToEntity($row); |
| 349 | 349 | } |
| 350 | 350 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | * @since 7.0.0 |
| 368 | 368 | * @deprecated 14.0.0 Move over to QBMapper |
| 369 | 369 | */ |
| 370 | - protected function findEntity($sql, array $params=[], $limit=null, $offset=null) { |
|
| 370 | + protected function findEntity($sql, array $params = [], $limit = null, $offset = null) { |
|
| 371 | 371 | return $this->mapRowToEntity($this->findOneQuery($sql, $params, $limit, $offset)); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -60,23 +60,23 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * @deprecated 14.0.0 use \OCP\ILogger::DEBUG |
| 62 | 62 | */ |
| 63 | - const DEBUG=0; |
|
| 63 | + const DEBUG = 0; |
|
| 64 | 64 | /** |
| 65 | 65 | * @deprecated 14.0.0 use \OCP\ILogger::INFO |
| 66 | 66 | */ |
| 67 | - const INFO=1; |
|
| 67 | + const INFO = 1; |
|
| 68 | 68 | /** |
| 69 | 69 | * @deprecated 14.0.0 use \OCP\ILogger::WARN |
| 70 | 70 | */ |
| 71 | - const WARN=2; |
|
| 71 | + const WARN = 2; |
|
| 72 | 72 | /** |
| 73 | 73 | * @deprecated 14.0.0 use \OCP\ILogger::ERROR |
| 74 | 74 | */ |
| 75 | - const ERROR=3; |
|
| 75 | + const ERROR = 3; |
|
| 76 | 76 | /** |
| 77 | 77 | * @deprecated 14.0.0 use \OCP\ILogger::FATAL |
| 78 | 78 | */ |
| 79 | - const FATAL=4; |
|
| 79 | + const FATAL = 4; |
|
| 80 | 80 | |
| 81 | 81 | /** \OCP\Share\IManager */ |
| 82 | 82 | private static $shareManager; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param string $text the text content for the element |
| 204 | 204 | * @since 4.0.0 |
| 205 | 205 | */ |
| 206 | - public static function addHeader($tag, $attributes, $text=null) { |
|
| 206 | + public static function addHeader($tag, $attributes, $text = null) { |
|
| 207 | 207 | \OC_Util::addHeader($tag, $attributes, $text); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public static function linkToRemote($service) { |
| 233 | 233 | $urlGenerator = \OC::$server->getURLGenerator(); |
| 234 | - $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; |
|
| 234 | + $remoteBase = $urlGenerator->linkTo('', 'remote.php').'/'.$service; |
|
| 235 | 235 | return $urlGenerator->getAbsoluteURL( |
| 236 | - $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') |
|
| 236 | + $remoteBase.(($service[strlen($service) - 1] != '/') ? '/' : '') |
|
| 237 | 237 | ); |
| 238 | 238 | } |
| 239 | 239 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @since 4.5.0 |
| 367 | 367 | */ |
| 368 | 368 | public static function callRegister() { |
| 369 | - if(self::$token === '') { |
|
| 369 | + if (self::$token === '') { |
|
| 370 | 370 | self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); |
| 371 | 371 | } |
| 372 | 372 | return self::$token; |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | */ |
| 513 | 513 | public static function needUpgrade() { |
| 514 | 514 | if (!isset(self::$needUpgradeCache)) { |
| 515 | - self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getSystemConfig()); |
|
| 515 | + self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig()); |
|
| 516 | 516 | } |
| 517 | 517 | return self::$needUpgradeCache; |
| 518 | 518 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | * @deprecated 14.0.0 ise \OC::$server->getAppManager()->getAppInfo($appId) |
| 81 | 81 | * @since 4.0.0 |
| 82 | 82 | */ |
| 83 | - public static function getAppInfo($app, $path=false) { |
|
| 83 | + public static function getAppInfo($app, $path = false) { |
|
| 84 | 84 | return \OC_App::getAppInfo($app, $path); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | * the app path list is empty or contains an invalid path |
| 136 | 136 | */ |
| 137 | 137 | public static function initPaths() { |
| 138 | - if(defined('PHPUNIT_CONFIG_DIR')) { |
|
| 139 | - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; |
|
| 140 | - } elseif(defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT . '/tests/config/')) { |
|
| 141 | - self::$configDir = OC::$SERVERROOT . '/tests/config/'; |
|
| 142 | - } elseif($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
| 143 | - self::$configDir = rtrim($dir, '/') . '/'; |
|
| 138 | + if (defined('PHPUNIT_CONFIG_DIR')) { |
|
| 139 | + self::$configDir = OC::$SERVERROOT.'/'.PHPUNIT_CONFIG_DIR.'/'; |
|
| 140 | + } elseif (defined('PHPUNIT_RUN') and PHPUNIT_RUN and is_dir(OC::$SERVERROOT.'/tests/config/')) { |
|
| 141 | + self::$configDir = OC::$SERVERROOT.'/tests/config/'; |
|
| 142 | + } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { |
|
| 143 | + self::$configDir = rtrim($dir, '/').'/'; |
|
| 144 | 144 | } else { |
| 145 | - self::$configDir = OC::$SERVERROOT . '/config/'; |
|
| 145 | + self::$configDir = OC::$SERVERROOT.'/config/'; |
|
| 146 | 146 | } |
| 147 | 147 | self::$config = new \OC\Config(self::$configDir); |
| 148 | 148 | |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | //make sure suburi follows the same rules as scriptName |
| 165 | 165 | if (substr(OC::$SUBURI, -9) != 'index.php') { |
| 166 | 166 | if (substr(OC::$SUBURI, -1) != '/') { |
| 167 | - OC::$SUBURI = OC::$SUBURI . '/'; |
|
| 167 | + OC::$SUBURI = OC::$SUBURI.'/'; |
|
| 168 | 168 | } |
| 169 | - OC::$SUBURI = OC::$SUBURI . 'index.php'; |
|
| 169 | + OC::$SUBURI = OC::$SUBURI.'index.php'; |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | OC::$WEBROOT = substr($scriptName, 0, 0 - strlen(OC::$SUBURI)); |
| 179 | 179 | |
| 180 | 180 | if (OC::$WEBROOT != '' && OC::$WEBROOT[0] !== '/') { |
| 181 | - OC::$WEBROOT = '/' . OC::$WEBROOT; |
|
| 181 | + OC::$WEBROOT = '/'.OC::$WEBROOT; |
|
| 182 | 182 | } |
| 183 | 183 | } else { |
| 184 | 184 | // The scriptName is not ending with OC::$SUBURI |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | OC::$APPSROOTS[] = $paths; |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | - } elseif (file_exists(OC::$SERVERROOT . '/apps')) { |
|
| 211 | - OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true]; |
|
| 212 | - } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { |
|
| 210 | + } elseif (file_exists(OC::$SERVERROOT.'/apps')) { |
|
| 211 | + OC::$APPSROOTS[] = ['path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true]; |
|
| 212 | + } elseif (file_exists(OC::$SERVERROOT.'/../apps')) { |
|
| 213 | 213 | OC::$APPSROOTS[] = [ |
| 214 | - 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', |
|
| 214 | + 'path' => rtrim(dirname(OC::$SERVERROOT), '/').'/apps', |
|
| 215 | 215 | 'url' => '/apps', |
| 216 | 216 | 'writable' => true |
| 217 | 217 | ]; |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | $l = \OC::$server->getL10N('lib'); |
| 242 | 242 | |
| 243 | 243 | // Create config if it does not already exist |
| 244 | - $configFilePath = self::$configDir .'/config.php'; |
|
| 245 | - if(!file_exists($configFilePath)) { |
|
| 244 | + $configFilePath = self::$configDir.'/config.php'; |
|
| 245 | + if (!file_exists($configFilePath)) { |
|
| 246 | 246 | @touch($configFilePath); |
| 247 | 247 | } |
| 248 | 248 | |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | echo $l->t('This can usually be fixed by giving the webserver write access to the config directory')."\n"; |
| 259 | 259 | echo "\n"; |
| 260 | 260 | echo $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it.')."\n"; |
| 261 | - echo $l->t('See %s', [ $urlGenerator->linkToDocs('admin-config') ])."\n"; |
|
| 261 | + echo $l->t('See %s', [$urlGenerator->linkToDocs('admin-config')])."\n"; |
|
| 262 | 262 | exit; |
| 263 | 263 | } else { |
| 264 | 264 | OC_Template::printErrorPage( |
| 265 | 265 | $l->t('Cannot write into "config" directory!'), |
| 266 | - $l->t('This can usually be fixed by giving the webserver write access to the config directory.') . '. ' |
|
| 266 | + $l->t('This can usually be fixed by giving the webserver write access to the config directory.').'. ' |
|
| 267 | 267 | . $l->t('Or, if you prefer to keep config.php file read only, set the option "config_is_read_only" to true in it. See %s', |
| 268 | - [ $urlGenerator->linkToDocs('admin-config') ]), |
|
| 268 | + [$urlGenerator->linkToDocs('admin-config')]), |
|
| 269 | 269 | 503 |
| 270 | 270 | ); |
| 271 | 271 | } |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | if (OC::$CLI) { |
| 282 | 282 | throw new Exception('Not installed'); |
| 283 | 283 | } else { |
| 284 | - $url = OC::$WEBROOT . '/index.php'; |
|
| 285 | - header('Location: ' . $url); |
|
| 284 | + $url = OC::$WEBROOT.'/index.php'; |
|
| 285 | + header('Location: '.$url); |
|
| 286 | 286 | } |
| 287 | 287 | exit(); |
| 288 | 288 | } |
@@ -387,14 +387,14 @@ discard block |
||
| 387 | 387 | $incompatibleShippedApps = []; |
| 388 | 388 | foreach ($incompatibleApps as $appInfo) { |
| 389 | 389 | if ($appManager->isShipped($appInfo['id'])) { |
| 390 | - $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; |
|
| 390 | + $incompatibleShippedApps[] = $appInfo['name'].' ('.$appInfo['id'].')'; |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | if (!empty($incompatibleShippedApps)) { |
| 395 | 395 | $l = \OC::$server->getL10N('core'); |
| 396 | 396 | $hint = $l->t('The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]); |
| 397 | - throw new \OC\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint); |
|
| 397 | + throw new \OC\HintException('The files of the app '.implode(', ', $incompatibleShippedApps).' were not replaced correctly. Make sure it is a version compatible with the server.', $hint); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | public static function initSession() { |
| 408 | - if(self::$server->getRequest()->getServerProtocol() === 'https') { |
|
| 408 | + if (self::$server->getRequest()->getServerProtocol() === 'https') { |
|
| 409 | 409 | ini_set('session.cookie_secure', true); |
| 410 | 410 | } |
| 411 | 411 | |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | ini_set('session.cookie_httponly', 'true'); |
| 414 | 414 | |
| 415 | 415 | // set the cookie path to the Nextcloud directory |
| 416 | - $cookie_path = OC::$WEBROOT ? : '/'; |
|
| 416 | + $cookie_path = OC::$WEBROOT ?: '/'; |
|
| 417 | 417 | ini_set('session.cookie_path', $cookie_path); |
| 418 | 418 | |
| 419 | 419 | // Let the session name be changed in the initSession Hook |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | // session timeout |
| 447 | 447 | if ($session->exists('LAST_ACTIVITY') && (time() - $session->get('LAST_ACTIVITY') > $sessionLifeTime)) { |
| 448 | 448 | if (isset($_COOKIE[session_name()])) { |
| 449 | - setcookie(session_name(), '', -1, self::$WEBROOT ? : '/'); |
|
| 449 | + setcookie(session_name(), '', -1, self::$WEBROOT ?: '/'); |
|
| 450 | 450 | } |
| 451 | 451 | \OC::$server->getUserSession()->logout(); |
| 452 | 452 | } |
@@ -482,14 +482,14 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | // Append __Host to the cookie if it meets the requirements |
| 484 | 484 | $cookiePrefix = ''; |
| 485 | - if($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
| 485 | + if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') { |
|
| 486 | 486 | $cookiePrefix = '__Host-'; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - foreach($policies as $policy) { |
|
| 489 | + foreach ($policies as $policy) { |
|
| 490 | 490 | header( |
| 491 | 491 | sprintf( |
| 492 | - 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
| 492 | + 'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s', |
|
| 493 | 493 | $cookiePrefix, |
| 494 | 494 | $policy, |
| 495 | 495 | $cookieParams['path'], |
@@ -528,31 +528,31 @@ discard block |
||
| 528 | 528 | ]; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - if($request->isUserAgent($incompatibleUserAgents)) { |
|
| 531 | + if ($request->isUserAgent($incompatibleUserAgents)) { |
|
| 532 | 532 | return; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - if(count($_COOKIE) > 0) { |
|
| 535 | + if (count($_COOKIE) > 0) { |
|
| 536 | 536 | $requestUri = $request->getScriptName(); |
| 537 | 537 | $processingScript = explode('/', $requestUri); |
| 538 | - $processingScript = $processingScript[count($processingScript)-1]; |
|
| 538 | + $processingScript = $processingScript[count($processingScript) - 1]; |
|
| 539 | 539 | |
| 540 | 540 | // index.php routes are handled in the middleware |
| 541 | - if($processingScript === 'index.php') { |
|
| 541 | + if ($processingScript === 'index.php') { |
|
| 542 | 542 | return; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | // All other endpoints require the lax and the strict cookie |
| 546 | - if(!$request->passesStrictCookieCheck()) { |
|
| 546 | + if (!$request->passesStrictCookieCheck()) { |
|
| 547 | 547 | self::sendSameSiteCookies(); |
| 548 | 548 | // Debug mode gets access to the resources without strict cookie |
| 549 | 549 | // due to the fact that the SabreDAV browser also lives there. |
| 550 | - if(!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 550 | + if (!\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 551 | 551 | http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); |
| 552 | 552 | exit(); |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | - } elseif(!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
| 555 | + } elseif (!isset($_COOKIE['nc_sameSiteCookielax']) || !isset($_COOKIE['nc_sameSiteCookiestrict'])) { |
|
| 556 | 556 | self::sendSameSiteCookies(); |
| 557 | 557 | } |
| 558 | 558 | } |
@@ -563,12 +563,12 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | // register autoloader |
| 565 | 565 | $loaderStart = microtime(true); |
| 566 | - require_once __DIR__ . '/autoloader.php'; |
|
| 566 | + require_once __DIR__.'/autoloader.php'; |
|
| 567 | 567 | self::$loader = new \OC\Autoloader([ |
| 568 | - OC::$SERVERROOT . '/lib/private/legacy', |
|
| 568 | + OC::$SERVERROOT.'/lib/private/legacy', |
|
| 569 | 569 | ]); |
| 570 | 570 | if (defined('PHPUNIT_RUN')) { |
| 571 | - self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
|
| 571 | + self::$loader->addValidRoot(OC::$SERVERROOT.'/tests'); |
|
| 572 | 572 | } |
| 573 | 573 | spl_autoload_register([self::$loader, 'load']); |
| 574 | 574 | $loaderEnd = microtime(true); |
@@ -576,12 +576,12 @@ discard block |
||
| 576 | 576 | self::$CLI = (php_sapi_name() == 'cli'); |
| 577 | 577 | |
| 578 | 578 | // Add default composer PSR-4 autoloader |
| 579 | - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
|
| 579 | + self::$composerAutoloader = require_once OC::$SERVERROOT.'/lib/composer/autoload.php'; |
|
| 580 | 580 | |
| 581 | 581 | try { |
| 582 | 582 | self::initPaths(); |
| 583 | 583 | // setup 3rdparty autoloader |
| 584 | - $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
|
| 584 | + $vendorAutoLoad = OC::$SERVERROOT.'/3rdparty/autoload.php'; |
|
| 585 | 585 | if (!file_exists($vendorAutoLoad)) { |
| 586 | 586 | throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".'); |
| 587 | 587 | } |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | @ini_set('display_errors', '0'); |
| 612 | 612 | @ini_set('log_errors', '1'); |
| 613 | 613 | |
| 614 | - if(!date_default_timezone_set('UTC')) { |
|
| 614 | + if (!date_default_timezone_set('UTC')) { |
|
| 615 | 615 | throw new \RuntimeException('Could not set timezone to UTC'); |
| 616 | 616 | } |
| 617 | 617 | |
@@ -676,11 +676,11 @@ discard block |
||
| 676 | 676 | // Convert l10n string into regular string for usage in database |
| 677 | 677 | $staticErrors = []; |
| 678 | 678 | foreach ($errors as $error) { |
| 679 | - echo $error['error'] . "\n"; |
|
| 680 | - echo $error['hint'] . "\n\n"; |
|
| 679 | + echo $error['error']."\n"; |
|
| 680 | + echo $error['hint']."\n\n"; |
|
| 681 | 681 | $staticErrors[] = [ |
| 682 | - 'error' => (string)$error['error'], |
|
| 683 | - 'hint' => (string)$error['hint'], |
|
| 682 | + 'error' => (string) $error['error'], |
|
| 683 | + 'hint' => (string) $error['hint'], |
|
| 684 | 684 | ]; |
| 685 | 685 | } |
| 686 | 686 | |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | //try to set the session lifetime |
| 698 | 698 | $sessionLifeTime = self::getSessionLifeTime(); |
| 699 | - @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
|
| 699 | + @ini_set('gc_maxlifetime', (string) $sessionLifeTime); |
|
| 700 | 700 | |
| 701 | 701 | $systemConfig = \OC::$server->getSystemConfig(); |
| 702 | 702 | |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | register_shutdown_function([$lockProvider, 'releaseAll']); |
| 748 | 748 | |
| 749 | 749 | // Check whether the sample configuration has been copied |
| 750 | - if($systemConfig->getValue('copied_sample_config', false)) { |
|
| 750 | + if ($systemConfig->getValue('copied_sample_config', false)) { |
|
| 751 | 751 | $l = \OC::$server->getL10N('lib'); |
| 752 | 752 | OC_Template::printErrorPage( |
| 753 | 753 | $l->t('Sample configuration detected'), |
@@ -769,11 +769,11 @@ discard block |
||
| 769 | 769 | ) { |
| 770 | 770 | // Allow access to CSS resources |
| 771 | 771 | $isScssRequest = false; |
| 772 | - if(strpos($request->getPathInfo(), '/css/') === 0) { |
|
| 772 | + if (strpos($request->getPathInfo(), '/css/') === 0) { |
|
| 773 | 773 | $isScssRequest = true; |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - if(substr($request->getRequestUri(), -11) === '/status.php') { |
|
| 776 | + if (substr($request->getRequestUri(), -11) === '/status.php') { |
|
| 777 | 777 | http_response_code(400); |
| 778 | 778 | header('Content-Type: application/json'); |
| 779 | 779 | echo '{"error": "Trusted domain error.", "code": 15}'; |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | |
| 812 | 812 | // NOTE: This will be replaced to use OCP |
| 813 | 813 | $userSession = self::$server->getUserSession(); |
| 814 | - $userSession->listen('\OC\User', 'postLogin', function () use ($userSession) { |
|
| 814 | + $userSession->listen('\OC\User', 'postLogin', function() use ($userSession) { |
|
| 815 | 815 | if (!defined('PHPUNIT_RUN') && $userSession->isLoggedIn()) { |
| 816 | 816 | // reset brute force delay for this IP address and username |
| 817 | 817 | $uid = \OC::$server->getUserSession()->getUser()->getUID(); |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | |
| 864 | 864 | private static function registerAppRestrictionsHooks() { |
| 865 | 865 | $groupManager = self::$server->query(\OCP\IGroupManager::class); |
| 866 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { |
|
| 866 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OCP\IGroup $group) { |
|
| 867 | 867 | $appManager = self::$server->getAppManager(); |
| 868 | 868 | $apps = $appManager->getEnabledAppsForGroup($group); |
| 869 | 869 | foreach ($apps as $appId) { |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | if (empty($restrictions)) { |
| 878 | 878 | $appManager->disableApp($appId); |
| 879 | 879 | } |
| 880 | - else{ |
|
| 880 | + else { |
|
| 881 | 881 | $appManager->enableAppForGroups($appId, $restrictions); |
| 882 | 882 | } |
| 883 | 883 | |
@@ -973,12 +973,12 @@ discard block |
||
| 973 | 973 | // emergency app disabling |
| 974 | 974 | if ($requestPath === '/disableapp' |
| 975 | 975 | && $request->getMethod() === 'POST' |
| 976 | - && ((array)$request->getParam('appid')) !== '' |
|
| 976 | + && ((array) $request->getParam('appid')) !== '' |
|
| 977 | 977 | ) { |
| 978 | 978 | \OC_JSON::callCheck(); |
| 979 | 979 | \OC_JSON::checkAdminUser(); |
| 980 | - $appIds = (array)$request->getParam('appid'); |
|
| 981 | - foreach($appIds as $appId) { |
|
| 980 | + $appIds = (array) $request->getParam('appid'); |
|
| 981 | + foreach ($appIds as $appId) { |
|
| 982 | 982 | $appId = \OC_App::cleanAppId($appId); |
| 983 | 983 | \OC::$server->getAppManager()->disableApp($appId); |
| 984 | 984 | } |
@@ -993,7 +993,7 @@ discard block |
||
| 993 | 993 | if (!\OCP\Util::needUpgrade() |
| 994 | 994 | && !((bool) $systemConfig->getValue('maintenance', false))) { |
| 995 | 995 | // For logged-in users: Load everything |
| 996 | - if(\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 996 | + if (\OC::$server->getUserSession()->isLoggedIn()) { |
|
| 997 | 997 | OC_App::loadApps(); |
| 998 | 998 | } else { |
| 999 | 999 | // For guests: Load only filesystem and logging |