@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return [ |
| 108 | - 'created' => function ($role, $requested) use ($attributes) { |
|
| 108 | + 'created' => function($role, $requested) use ($attributes) { |
|
| 109 | 109 | return $attributes['created']->toDateTime()->format('c'); |
| 110 | 110 | }, |
| 111 | - 'changed' => function ($role, $requested) use ($attributes) { |
|
| 111 | + 'changed' => function($role, $requested) use ($attributes) { |
|
| 112 | 112 | return $attributes['changed']->toDateTime()->format('c'); |
| 113 | 113 | }, |
| 114 | - 'deleted' => function ($role, $requested) use ($attributes) { |
|
| 114 | + 'deleted' => function($role, $requested) use ($attributes) { |
|
| 115 | 115 | if (false === $attributes['deleted']) { |
| 116 | 116 | return null; |
| 117 | 117 | } |
@@ -164,14 +164,14 @@ discard block |
||
| 164 | 164 | 'name' => (string) $attributes['username'], |
| 165 | 165 | 'namespace' => (string) $attributes['namespace'], |
| 166 | 166 | 'mail' => (string) $attributes['mail'], |
| 167 | - 'avatar' => function ($role, $requested) use ($attributes) { |
|
| 167 | + 'avatar' => function($role, $requested) use ($attributes) { |
|
| 168 | 168 | if ($attributes['avatar'] instanceof Binary) { |
| 169 | 169 | return base64_encode($attributes['avatar']->getData()); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | return null; |
| 173 | 173 | }, |
| 174 | - 'soft_quota' => function ($role, $requested) use ($attributes, $user) { |
|
| 174 | + 'soft_quota' => function($role, $requested) use ($attributes, $user) { |
|
| 175 | 175 | if ($user === null) { |
| 176 | 176 | return null; |
| 177 | 177 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | return null; |
| 184 | 184 | }, |
| 185 | - 'hard_quota' => function ($role, $requested) use ($attributes, $user) { |
|
| 185 | + 'hard_quota' => function($role, $requested) use ($attributes, $user) { |
|
| 186 | 186 | if ($user === null) { |
| 187 | 187 | return null; |
| 188 | 188 | } |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | * Add decorator. |
| 74 | 74 | * |
| 75 | 75 | * |
| 76 | - * @return AttributeDecorator |
|
| 76 | + * @return RoleDecorator |
|
| 77 | 77 | */ |
| 78 | 78 | public function addDecorator(string $attribute, Closure $decorator): self |
| 79 | 79 | { |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | * Add decorator. |
| 87 | 87 | * |
| 88 | 88 | * |
| 89 | - * @return AttributeDecorator |
|
| 89 | + * @return NodeDecorator |
|
| 90 | 90 | */ |
| 91 | 91 | public function addDecorator(string $attribute, Closure $decorator): self |
| 92 | 92 | { |
@@ -127,20 +127,20 @@ discard block |
||
| 127 | 127 | 'mime' => (string) $attributes['mime'], |
| 128 | 128 | 'readonly' => (bool) $attributes['readonly'], |
| 129 | 129 | 'directory' => $node instanceof Collection, |
| 130 | - 'meta' => function ($node) { |
|
| 130 | + 'meta' => function($node) { |
|
| 131 | 131 | return (object) $node->getMetaAttributes(); |
| 132 | 132 | }, |
| 133 | - 'size' => function ($node) { |
|
| 133 | + 'size' => function($node) { |
|
| 134 | 134 | return $node->getSize(); |
| 135 | 135 | }, |
| 136 | - 'path' => function ($node) { |
|
| 136 | + 'path' => function($node) { |
|
| 137 | 137 | try { |
| 138 | 138 | return $node->getPath(); |
| 139 | 139 | } catch (\Exception $e) { |
| 140 | 140 | return null; |
| 141 | 141 | } |
| 142 | 142 | }, |
| 143 | - 'parent' => function ($node) { |
|
| 143 | + 'parent' => function($node) { |
|
| 144 | 144 | $parent = $node->getParent(); |
| 145 | 145 | |
| 146 | 146 | if (null === $parent || $parent->isRoot()) { |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | return (string) $parent->getId(); |
| 151 | 151 | }, |
| 152 | - 'access' => function ($node) use ($acl) { |
|
| 152 | + 'access' => function($node) use ($acl) { |
|
| 153 | 153 | return $acl->getAclPrivilege($node); |
| 154 | 154 | }, |
| 155 | - 'share' => function ($node) { |
|
| 155 | + 'share' => function($node) { |
|
| 156 | 156 | if (!$node->isShared() && !$node->isSpecial()) { |
| 157 | 157 | return false; |
| 158 | 158 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | return false; |
| 164 | 164 | } |
| 165 | 165 | }, |
| 166 | - 'shareowner' => function ($node) use ($server, $fs) { |
|
| 166 | + 'shareowner' => function($node) use ($server, $fs) { |
|
| 167 | 167 | if (!$node->isSpecial()) { |
| 168 | 168 | return null; |
| 169 | 169 | } |
@@ -206,20 +206,20 @@ discard block |
||
| 206 | 206 | protected function getTimeAttributes(NodeInterface $node, array $attributes): array |
| 207 | 207 | { |
| 208 | 208 | return [ |
| 209 | - 'created' => function ($node) use ($attributes) { |
|
| 209 | + 'created' => function($node) use ($attributes) { |
|
| 210 | 210 | return $this->dateTimeToUnix($attributes['created']); |
| 211 | 211 | }, |
| 212 | - 'changed' => function ($node) use ($attributes) { |
|
| 212 | + 'changed' => function($node) use ($attributes) { |
|
| 213 | 213 | return $this->dateTimeToUnix($attributes['changed']); |
| 214 | 214 | }, |
| 215 | - 'deleted' => function ($node) use ($attributes) { |
|
| 215 | + 'deleted' => function($node) use ($attributes) { |
|
| 216 | 216 | if (false === $attributes['deleted']) { |
| 217 | 217 | return false; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | return $this->dateTimeToUnix($attributes['deleted']); |
| 221 | 221 | }, |
| 222 | - 'destroy' => function ($node) use ($attributes) { |
|
| 222 | + 'destroy' => function($node) use ($attributes) { |
|
| 223 | 223 | if (null === $attributes['destroy']) { |
| 224 | 224 | return null; |
| 225 | 225 | } |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | namespace Balloon\App\Notification\Hook; |
| 13 | 13 | |
| 14 | 14 | use Balloon\App\Notification\Notifier; |
| 15 | -use Balloon\Async\Mail; |
|
| 16 | 15 | use Balloon\Filesystem\Node\Collection; |
| 17 | 16 | use Balloon\Filesystem\Node\NodeInterface; |
| 18 | 17 | use Balloon\Hook\AbstractHook; |
@@ -195,6 +195,7 @@ |
||
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * Filesystem factory. |
| 198 | + * @param User $user |
|
| 198 | 199 | */ |
| 199 | 200 | public function getFilesystem(?User $user = null): Filesystem |
| 200 | 201 | { |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | |
| 534 | 534 | $this->identity = $user; |
| 535 | 535 | $user->updateIdentity($identity) |
| 536 | - ->updateShares(); |
|
| 536 | + ->updateShares(); |
|
| 537 | 537 | $this->hook->run('postServerIdentity', [$user]); |
| 538 | 538 | |
| 539 | 539 | return true; |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | public function getGroupByName(string $name): Group |
| 643 | 643 | { |
| 644 | 644 | $group = $this->db->group->findOne([ |
| 645 | - 'name' => $name, |
|
| 645 | + 'name' => $name, |
|
| 646 | 646 | ]); |
| 647 | 647 | |
| 648 | 648 | if (null === $group) { |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | $group = $this->db->group->findOne([ |
| 667 | - '_id' => $id, |
|
| 667 | + '_id' => $id, |
|
| 668 | 668 | ]); |
| 669 | 669 | |
| 670 | 670 | if (null === $group) { |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | break; |
| 102 | 102 | default: |
| 103 | 103 | throw new InvalidArgumentException('invalid option '.$option.' given'); |
| 104 | - } |
|
| 104 | + } |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $this; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | protected function decorate(string $template, array $context): string |
| 220 | 220 | { |
| 221 | - return preg_replace_callback('/\{([^}\.]*)\}/', function ($match) use ($context) { |
|
| 221 | + return preg_replace_callback('/\{([^}\.]*)\}/', function($match) use ($context) { |
|
| 222 | 222 | $key = $match[1]; |
| 223 | 223 | |
| 224 | 224 | if (isset($context[$key])) { |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | protected function decorateResource(string $template, $resource, string $prefix, $decorator): string |
| 234 | 234 | { |
| 235 | - return preg_replace_callback('/(\{'.$prefix.'\.(([a-z]\.*)+)\})/', function ($match) use ($resource, $decorator) { |
|
| 235 | + return preg_replace_callback('/(\{'.$prefix.'\.(([a-z]\.*)+)\})/', function($match) use ($resource, $decorator) { |
|
| 236 | 236 | $key = explode('.', $match[2]); |
| 237 | 237 | $key = array_shift($key); |
| 238 | 238 | $attrs = $decorator->decorate($resource, [$key]); |
@@ -114,10 +114,10 @@ |
||
| 114 | 114 | $body->setParts([$html, $plain]); |
| 115 | 115 | |
| 116 | 116 | $mail = (new Message()) |
| 117 | - ->setSubject($message->getSubject($receiver)) |
|
| 118 | - ->setBody($body) |
|
| 119 | - ->setTo($address) |
|
| 120 | - ->setEncoding('UTF-8'); |
|
| 117 | + ->setSubject($message->getSubject($receiver)) |
|
| 118 | + ->setBody($body) |
|
| 119 | + ->setTo($address) |
|
| 120 | + ->setEncoding('UTF-8'); |
|
| 121 | 121 | |
| 122 | 122 | $type = $mail->getHeaders()->get('Content-Type'); |
| 123 | 123 | $type->setType('multipart/alternative'); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | 'directory' => $node instanceof Collection, |
| 57 | 57 | 'meta' => $node->getMetaAttributes(), |
| 58 | 58 | 'size' => $node->getSize(), |
| 59 | - 'parent' => function ($node, $requested) use ($attributes) { |
|
| 59 | + 'parent' => function($node, $requested) use ($attributes) { |
|
| 60 | 60 | $parent = $node->getParent(); |
| 61 | 61 | |
| 62 | 62 | if (null === $parent || $parent->isRoot()) { |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | 'shared' => (string) $attributes['shared'], |
| 70 | 70 | 'created' => $attributes['created']->toDateTime()->format('c'), |
| 71 | 71 | 'changed' => $attributes['changed']->toDateTime()->format('c'), |
| 72 | - 'deleted' => function ($node, $requested) use ($attributes) { |
|
| 72 | + 'deleted' => function($node, $requested) use ($attributes) { |
|
| 73 | 73 | if (!$attributes['deleted']) { |
| 74 | 74 | return null; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | return $attributes['deleted']->toDateTime()->format('c'); |
| 78 | 78 | }, |
| 79 | - 'destroy' => function ($node, $requested) use ($attributes) { |
|
| 79 | + 'destroy' => function($node, $requested) use ($attributes) { |
|
| 80 | 80 | if (!$attributes['destroy']) { |
| 81 | 81 | return null; |
| 82 | 82 | } |
@@ -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 | |