@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | }); |
| 67 | 67 | |
| 68 | - $node_decorator_v2->addDecorator('sharelink_has_password', function ($node) use ($sharelink) { |
|
| 68 | + $node_decorator_v2->addDecorator('sharelink_has_password', function($node) use ($sharelink) { |
|
| 69 | 69 | $attributes = $sharelink->getSharelink($node); |
| 70 | 70 | |
| 71 | 71 | return isset($attributes['password']); |
| 72 | 72 | }); |
| 73 | 73 | |
| 74 | - $node_decorator_v2->addDecorator('sharelink_token', function ($node) use ($sharelink) { |
|
| 74 | + $node_decorator_v2->addDecorator('sharelink_token', function($node) use ($sharelink) { |
|
| 75 | 75 | $attributes = $sharelink->getSharelink($node); |
| 76 | 76 | |
| 77 | 77 | if (isset($attributes['token'])) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | }); |
| 81 | 81 | |
| 82 | - $node_decorator_v2->addDecorator('sharelink_expire', function ($node) use ($sharelink) { |
|
| 82 | + $node_decorator_v2->addDecorator('sharelink_expire', function($node) use ($sharelink) { |
|
| 83 | 83 | $attributes = $sharelink->getSharelink($node); |
| 84 | 84 | |
| 85 | 85 | if (isset($attributes['expiration'])) { |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | }); |
| 91 | 91 | |
| 92 | - $node_decorator_v1->addDecorator('sharelink', function ($node) use ($sharelink) { |
|
| 92 | + $node_decorator_v1->addDecorator('sharelink', function($node) use ($sharelink) { |
|
| 93 | 93 | return isset($sharelink->getSharelink($node)['token']); |
| 94 | 94 | }); |
| 95 | 95 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @param string $class Force set node type |
| 211 | 211 | * @param bool $multiple Allow $id to be an array |
| 212 | 212 | * @param bool $allow_root Allow instance of root collection |
| 213 | - * @param bool $deleted How to handle deleted node |
|
| 213 | + * @param integer $deleted How to handle deleted node |
|
| 214 | 214 | */ |
| 215 | 215 | protected function _getNode( |
| 216 | 216 | ?string $id = null, |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @param string $id |
| 243 | 243 | * @param string $path |
| 244 | 244 | * @param string $class Force set node type |
| 245 | - * @param bool $deleted How to handle deleted node |
|
| 245 | + * @param integer $deleted How to handle deleted node |
|
| 246 | 246 | */ |
| 247 | 247 | protected function _getNodes( |
| 248 | 248 | $id = null, |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict, $move) { |
|
| 186 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict, $move) { |
|
| 187 | 187 | if (true === $move) { |
| 188 | 188 | $node = $node->setParent($parent, $conflict); |
| 189 | 189 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | $node = $this->_getNode($id, $p); |
| 262 | 262 | if ($node instanceof Collection) { |
| 263 | - return (new Response())->setBody(function () use ($node) { |
|
| 263 | + return (new Response())->setBody(function() use ($node) { |
|
| 264 | 264 | $node->getZip(); |
| 265 | 265 | }); |
| 266 | 266 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | return $response->setOutputFormat(null) |
| 281 | - ->setBody(function () use ($node, $encode, $offset, $length) { |
|
| 281 | + ->setBody(function() use ($node, $encode, $offset, $length) { |
|
| 282 | 282 | $mime = $node->getContentType(); |
| 283 | 283 | $stream = $node->get(); |
| 284 | 284 | $name = $node->getName(); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | */ |
| 350 | 350 | public function postReadonly($id = null, $p = null, bool $readonly = true): Response |
| 351 | 351 | { |
| 352 | - return $this->bulk($id, $p, function ($node) use ($readonly) { |
|
| 352 | + return $this->bulk($id, $p, function($node) use ($readonly) { |
|
| 353 | 353 | $node->setReadonly($readonly); |
| 354 | 354 | |
| 355 | 355 | return ['status' => 204]; |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | */ |
| 595 | 595 | public function postMetaAttributes(?string $id = null, ?string $p = null): Response |
| 596 | 596 | { |
| 597 | - return $this->bulk($id, $p, function ($node) { |
|
| 597 | + return $this->bulk($id, $p, function($node) { |
|
| 598 | 598 | $node->setMetaAttributes($_POST); |
| 599 | 599 | |
| 600 | 600 | return ['status' => 204]; |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | ); |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
| 679 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
| 680 | 680 | $result = $node->copyTo($parent, $conflict); |
| 681 | 681 | |
| 682 | 682 | return [ |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | ); |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
| 740 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
| 741 | 741 | $result = $node->setParent($parent, $conflict); |
| 742 | 742 | if (NodeInterface::CONFLICT_RENAME === $conflict) { |
| 743 | 743 | return [ |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | - return $this->bulk($id, $p, function ($node) use ($force, $ignore_flag, $at) { |
|
| 795 | + return $this->bulk($id, $p, function($node) use ($force, $ignore_flag, $at) { |
|
| 796 | 796 | if (null === $at) { |
| 797 | 797 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
| 798 | 798 | } else { |
@@ -287,49 +287,49 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | return $response->setOutputFormat(null) |
| 290 | - ->setBody(function () use ($node, $encode, $offset, $length) { |
|
| 291 | - $mime = $node->getContentType(); |
|
| 292 | - $stream = $node->get(); |
|
| 293 | - $name = $node->getName(); |
|
| 294 | - |
|
| 295 | - if (null === $stream) { |
|
| 296 | - return; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - if (0 !== $offset) { |
|
| 300 | - if (fseek($stream, $offset) === -1) { |
|
| 301 | - throw new Exception\Conflict( |
|
| 302 | - 'invalid offset requested', |
|
| 303 | - Exception\Conflict::INVALID_OFFSET |
|
| 290 | + ->setBody(function () use ($node, $encode, $offset, $length) { |
|
| 291 | + $mime = $node->getContentType(); |
|
| 292 | + $stream = $node->get(); |
|
| 293 | + $name = $node->getName(); |
|
| 294 | + |
|
| 295 | + if (null === $stream) { |
|
| 296 | + return; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + if (0 !== $offset) { |
|
| 300 | + if (fseek($stream, $offset) === -1) { |
|
| 301 | + throw new Exception\Conflict( |
|
| 302 | + 'invalid offset requested', |
|
| 303 | + Exception\Conflict::INVALID_OFFSET |
|
| 304 | 304 | ); |
| 305 | - } |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - $read = 0; |
|
| 309 | - header('Content-Type: '.$mime.''); |
|
| 310 | - if ('base64' === $encode) { |
|
| 311 | - header('Content-Encoding: base64'); |
|
| 312 | - while (!feof($stream)) { |
|
| 313 | - if (0 !== $length && $read + 8192 > $length) { |
|
| 314 | - echo base64_encode(fread($stream, $length - $read)); |
|
| 315 | - exit(); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - echo base64_encode(fread($stream, 8192)); |
|
| 319 | - $read += 8192; |
|
| 320 | - } |
|
| 321 | - } else { |
|
| 322 | - while (!feof($stream)) { |
|
| 323 | - if (0 !== $length && $read + 8192 > $length) { |
|
| 324 | - echo fread($stream, $length - $read); |
|
| 325 | - exit(); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - echo fread($stream, 8192); |
|
| 329 | - $read += 8192; |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - }); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + $read = 0; |
|
| 309 | + header('Content-Type: '.$mime.''); |
|
| 310 | + if ('base64' === $encode) { |
|
| 311 | + header('Content-Encoding: base64'); |
|
| 312 | + while (!feof($stream)) { |
|
| 313 | + if (0 !== $length && $read + 8192 > $length) { |
|
| 314 | + echo base64_encode(fread($stream, $length - $read)); |
|
| 315 | + exit(); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + echo base64_encode(fread($stream, 8192)); |
|
| 319 | + $read += 8192; |
|
| 320 | + } |
|
| 321 | + } else { |
|
| 322 | + while (!feof($stream)) { |
|
| 323 | + if (0 !== $length && $read + 8192 > $length) { |
|
| 324 | + echo fread($stream, $length - $read); |
|
| 325 | + exit(); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + echo fread($stream, 8192); |
|
| 329 | + $read += 8192; |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + }); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -1330,9 +1330,9 @@ discard block |
||
| 1330 | 1330 | $node->zip($archive); |
| 1331 | 1331 | } catch (\Exception $e) { |
| 1332 | 1332 | $this->logger->debug('failed zip node in multi node request ['.$node->getId().']', [ |
| 1333 | - 'category' => get_class($this), |
|
| 1334 | - 'exception' => $e, |
|
| 1335 | - ]); |
|
| 1333 | + 'category' => get_class($this), |
|
| 1334 | + 'exception' => $e, |
|
| 1335 | + ]); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | } |
| 1338 | 1338 | |
@@ -256,9 +256,9 @@ |
||
| 256 | 256 | $body->setParts([$html, $plain]); |
| 257 | 257 | |
| 258 | 258 | $mail = (new Message()) |
| 259 | - ->setSubject($message->getSubject()) |
|
| 260 | - ->setBody($body) |
|
| 261 | - ->setEncoding('UTF-8'); |
|
| 259 | + ->setSubject($message->getSubject()) |
|
| 260 | + ->setBody($body) |
|
| 261 | + ->setEncoding('UTF-8'); |
|
| 262 | 262 | |
| 263 | 263 | $type = $mail->getHeaders()->get('Content-Type'); |
| 264 | 264 | $type->setType('multipart/alternative'); |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | $attributes = compact('password', 'soft_quota', 'hard_quota', 'avatar', 'mail', 'admin', 'namespace', 'locale', 'optional'); |
| 373 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 373 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 374 | 374 | |
| 375 | 375 | if (isset($attributes['avatar'])) { |
| 376 | 376 | $attributes['avatar'] = new Binary(base64_decode($attributes['avatar']), Binary::TYPE_GENERIC); |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | public function patch(?string $id = null, ?string $uname = null, ?string $username = null, ?string $password = null, ?int $soft_quota = null, ?int $hard_quota = null, ?string $avatar = null, ?string $mail = null, ?bool $admin = null, ?string $namespace = null, ?string $locale = null, ?array $optional = null): Response |
| 416 | 416 | { |
| 417 | 417 | $attributes = compact('username', 'password', 'soft_quota', 'hard_quota', 'avatar', 'mail', 'admin', 'namespace', 'locale', 'optional'); |
| 418 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 418 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 419 | 419 | |
| 420 | 420 | if (isset($attributes['avatar'])) { |
| 421 | 421 | $attributes['avatar'] = new Binary(base64_decode($attributes['avatar']), Binary::TYPE_GENERIC); |
@@ -137,7 +137,7 @@ |
||
| 137 | 137 | * Get Session. |
| 138 | 138 | * |
| 139 | 139 | * |
| 140 | - * @return Session |
|
| 140 | + * @return Session|null |
|
| 141 | 141 | */ |
| 142 | 142 | public static function getByAccessToken(Server $server, ObjectId $session_id, string $access_token): self |
| 143 | 143 | { |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | namespace Balloon\Migration\Delta; |
| 13 | 13 | |
| 14 | 14 | use MongoDB\Database; |
| 15 | -use MongoDB\Driver\Exception\CommandException; |
|
| 16 | 15 | use MongoDB\Driver\Exception\RuntimeException; |
| 17 | 16 | |
| 18 | 17 | class Md5BlobIgnoreNull implements DeltaInterface |
@@ -236,8 +236,8 @@ discard block |
||
| 236 | 236 | $share = $node->getFilesystem()->findRawNode($node->getShareId()); |
| 237 | 237 | } catch (\Exception $e) { |
| 238 | 238 | $this->logger->error('could not find share node ['.$node->getShareId().'] for reference ['.$node->getId().'], dead reference?', [ |
| 239 | - 'category' => get_class($this), |
|
| 240 | - 'exception' => $e, |
|
| 239 | + 'category' => get_class($this), |
|
| 240 | + 'exception' => $e, |
|
| 241 | 241 | ]); |
| 242 | 242 | |
| 243 | 243 | return self::PRIVILEGE_DENY; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | if ($share['deleted'] instanceof UTCDateTime || true !== $share['shared']) { |
| 247 | 247 | $this->logger->error('share node ['.$share['_id'].'] has been deleted, dead reference?', [ |
| 248 | - 'category' => get_class($this), |
|
| 248 | + 'category' => get_class($this), |
|
| 249 | 249 | ]); |
| 250 | 250 | |
| 251 | 251 | return self::PRIVILEGE_DENY; |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | return [ |
| 95 | - 'created' => function ($role) use ($attributes) { |
|
| 95 | + 'created' => function($role) use ($attributes) { |
|
| 96 | 96 | return $attributes['created']->toDateTime()->format('c'); |
| 97 | 97 | }, |
| 98 | - 'changed' => function ($role) use ($attributes) { |
|
| 98 | + 'changed' => function($role) use ($attributes) { |
|
| 99 | 99 | return $attributes['changed']->toDateTime()->format('c'); |
| 100 | 100 | }, |
| 101 | - 'deleted' => function ($role) use ($attributes) { |
|
| 101 | + 'deleted' => function($role) use ($attributes) { |
|
| 102 | 102 | if (false === $attributes['deleted']) { |
| 103 | 103 | return null; |
| 104 | 104 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'name' => (string) $attributes['username'], |
| 147 | 147 | 'admin' => (bool) $attributes['admin'], |
| 148 | 148 | 'namespace' => isset($attributes['namespace']) ? (string) $attributes['namespace'] : null, |
| 149 | - 'mail' => function ($role) use ($attributes, $user) { |
|
| 149 | + 'mail' => function($role) use ($attributes, $user) { |
|
| 150 | 150 | if (!isset($attributes['mail'])) { |
| 151 | 151 | return null; |
| 152 | 152 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | 'locale' => isset($attributes['locale']) ? (string) $attributes['locale'] : null, |
| 161 | 161 | 'hard_quota' => isset($attributes['hard_quota']) ? (int) $attributes['hard_quota'] : null, |
| 162 | 162 | 'soft_quota' => isset($attributes['soft_quota']) ? (int) $attributes['soft_quota'] : null, |
| 163 | - 'available' => function ($role) use (&$quota, $attributes, $user) { |
|
| 163 | + 'available' => function($role) use (&$quota, $attributes, $user) { |
|
| 164 | 164 | $quota === null ? $quota = $role->getQuotaUsage() : null; |
| 165 | 165 | if ($attributes['_id'] == $user->getId() || $user->isAdmin()) { |
| 166 | 166 | return $quota['available']; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | return null; |
| 170 | 170 | }, |
| 171 | - 'used' => function ($role) use (&$quota, $attributes, $user) { |
|
| 171 | + 'used' => function($role) use (&$quota, $attributes, $user) { |
|
| 172 | 172 | $quota === null ? $quota = $role->getQuotaUsage() : null; |
| 173 | 173 | if ($attributes['_id'] == $user->getId() || $user->isAdmin()) { |
| 174 | 174 | return $quota['used']; |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | if ($node instanceof Collection && $recursive === true) { |
| 350 | 350 | $db = $this->db; |
| 351 | - $node->doRecursiveAction(function ($child) use ($db, $subscription) { |
|
| 351 | + $node->doRecursiveAction(function($child) use ($db, $subscription) { |
|
| 352 | 352 | $subscription['node'] = $child->getId(); |
| 353 | 353 | $db->subscription->replaceOne( |
| 354 | 354 | [ |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | if ($node instanceof Collection && $recursive === true) { |
| 376 | 376 | $db = $this->db; |
| 377 | - $node->doRecursiveAction(function ($child) use ($db, $node_id, $user_id) { |
|
| 377 | + $node->doRecursiveAction(function($child) use ($db, $node_id, $user_id) { |
|
| 378 | 378 | $db->subscription->deleteOne([ |
| 379 | 379 | 'user' => $user_id, |
| 380 | 380 | 'node' => $node_id, |
@@ -93,6 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * Send notification. |
| 96 | + * @param User $sender |
|
| 96 | 97 | */ |
| 97 | 98 | public function notify(Iterable $receiver, ?User $sender, MessageInterface $message): bool |
| 98 | 99 | { |
@@ -180,6 +181,7 @@ discard block |
||
| 180 | 181 | |
| 181 | 182 | /** |
| 182 | 183 | * Add notification. |
| 184 | + * @param User $sender |
|
| 183 | 185 | */ |
| 184 | 186 | public function postNotification(User $receiver, ?User $sender, MessageInterface $message): ObjectId |
| 185 | 187 | { |
@@ -206,6 +208,8 @@ discard block |
||
| 206 | 208 | |
| 207 | 209 | /** |
| 208 | 210 | * Get notifications. |
| 211 | + * @param integer $offset |
|
| 212 | + * @param integer $limit |
|
| 209 | 213 | */ |
| 210 | 214 | public function getNotifications(User $user, ?int $offset = null, ?int $limit = null, ?int &$total = null): Iterable |
| 211 | 215 | { |
@@ -278,6 +282,7 @@ discard block |
||
| 278 | 282 | |
| 279 | 283 | /** |
| 280 | 284 | * Get subscription. |
| 285 | + * @return NodeInterface |
|
| 281 | 286 | */ |
| 282 | 287 | public function getSubscription(NodeInterface $node, User $user): ?array |
| 283 | 288 | { |