@@ -31,40 +31,40 @@ |
||
31 | 31 | use OCP\WorkflowEngine\IEntity; |
32 | 32 | |
33 | 33 | trait TFileCheck { |
34 | - /** @var IStorage */ |
|
35 | - protected $storage; |
|
34 | + /** @var IStorage */ |
|
35 | + protected $storage; |
|
36 | 36 | |
37 | - /** @var string */ |
|
38 | - protected $path; |
|
37 | + /** @var string */ |
|
38 | + protected $path; |
|
39 | 39 | |
40 | - /** @var bool */ |
|
41 | - protected $isDir; |
|
40 | + /** @var bool */ |
|
41 | + protected $isDir; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param IStorage $storage |
|
45 | - * @param string $path |
|
46 | - * @param bool $isDir |
|
47 | - * @since 18.0.0 |
|
48 | - */ |
|
49 | - public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
50 | - $this->storage = $storage; |
|
51 | - $this->path = $path; |
|
52 | - $this->isDir = $isDir; |
|
53 | - } |
|
43 | + /** |
|
44 | + * @param IStorage $storage |
|
45 | + * @param string $path |
|
46 | + * @param bool $isDir |
|
47 | + * @since 18.0.0 |
|
48 | + */ |
|
49 | + public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
50 | + $this->storage = $storage; |
|
51 | + $this->path = $path; |
|
52 | + $this->isDir = $isDir; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @throws \OCP\Files\NotFoundException |
|
57 | - */ |
|
58 | - public function setEntitySubject(IEntity $entity, $subject): void { |
|
59 | - if ($entity instanceof File) { |
|
60 | - if (!$subject instanceof Node) { |
|
61 | - throw new \UnexpectedValueException( |
|
62 | - 'Expected Node subject for File entity, got {class}', |
|
63 | - ['app' => Application::APP_ID, 'class' => get_class($subject)] |
|
64 | - ); |
|
65 | - } |
|
66 | - $this->storage = $subject->getStorage(); |
|
67 | - $this->path = $subject->getPath(); |
|
68 | - } |
|
69 | - } |
|
55 | + /** |
|
56 | + * @throws \OCP\Files\NotFoundException |
|
57 | + */ |
|
58 | + public function setEntitySubject(IEntity $entity, $subject): void { |
|
59 | + if ($entity instanceof File) { |
|
60 | + if (!$subject instanceof Node) { |
|
61 | + throw new \UnexpectedValueException( |
|
62 | + 'Expected Node subject for File entity, got {class}', |
|
63 | + ['app' => Application::APP_ID, 'class' => get_class($subject)] |
|
64 | + ); |
|
65 | + } |
|
66 | + $this->storage = $subject->getStorage(); |
|
67 | + $this->path = $subject->getPath(); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |
@@ -33,38 +33,38 @@ |
||
33 | 33 | */ |
34 | 34 | class NodeRemovedFromCache extends Event { |
35 | 35 | |
36 | - /** @var IStorage */ |
|
37 | - private $storage; |
|
36 | + /** @var IStorage */ |
|
37 | + private $storage; |
|
38 | 38 | |
39 | - /** @var string */ |
|
40 | - private $path; |
|
39 | + /** @var string */ |
|
40 | + private $path; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IStorage $storage |
|
44 | - * @param string $path |
|
45 | - * @since 18.0.0 |
|
46 | - */ |
|
47 | - public function __construct(IStorage $storage, |
|
48 | - string $path) { |
|
49 | - parent::__construct(); |
|
50 | - $this->storage = $storage; |
|
51 | - $this->path = $path; |
|
52 | - } |
|
42 | + /** |
|
43 | + * @param IStorage $storage |
|
44 | + * @param string $path |
|
45 | + * @since 18.0.0 |
|
46 | + */ |
|
47 | + public function __construct(IStorage $storage, |
|
48 | + string $path) { |
|
49 | + parent::__construct(); |
|
50 | + $this->storage = $storage; |
|
51 | + $this->path = $path; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return IStorage |
|
56 | - * @since 18.0.0 |
|
57 | - */ |
|
58 | - public function getStorage(): IStorage { |
|
59 | - return $this->storage; |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return IStorage |
|
56 | + * @since 18.0.0 |
|
57 | + */ |
|
58 | + public function getStorage(): IStorage { |
|
59 | + return $this->storage; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - * @since 18.0.0 |
|
65 | - */ |
|
66 | - public function getPath(): string { |
|
67 | - return $this->path; |
|
68 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + * @since 18.0.0 |
|
65 | + */ |
|
66 | + public function getPath(): string { |
|
67 | + return $this->path; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
@@ -33,38 +33,38 @@ |
||
33 | 33 | */ |
34 | 34 | class FileCacheUpdated extends Event { |
35 | 35 | |
36 | - /** @var IStorage */ |
|
37 | - private $storage; |
|
36 | + /** @var IStorage */ |
|
37 | + private $storage; |
|
38 | 38 | |
39 | - /** @var string */ |
|
40 | - private $path; |
|
39 | + /** @var string */ |
|
40 | + private $path; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IStorage $storage |
|
44 | - * @param string $path |
|
45 | - * @since 18.0.0 |
|
46 | - */ |
|
47 | - public function __construct(IStorage $storage, |
|
48 | - string $path) { |
|
49 | - parent::__construct(); |
|
50 | - $this->storage = $storage; |
|
51 | - $this->path = $path; |
|
52 | - } |
|
42 | + /** |
|
43 | + * @param IStorage $storage |
|
44 | + * @param string $path |
|
45 | + * @since 18.0.0 |
|
46 | + */ |
|
47 | + public function __construct(IStorage $storage, |
|
48 | + string $path) { |
|
49 | + parent::__construct(); |
|
50 | + $this->storage = $storage; |
|
51 | + $this->path = $path; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return IStorage |
|
56 | - * @since 18.0.0 |
|
57 | - */ |
|
58 | - public function getStorage(): IStorage { |
|
59 | - return $this->storage; |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return IStorage |
|
56 | + * @since 18.0.0 |
|
57 | + */ |
|
58 | + public function getStorage(): IStorage { |
|
59 | + return $this->storage; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - * @since 18.0.0 |
|
65 | - */ |
|
66 | - public function getPath(): string { |
|
67 | - return $this->path; |
|
68 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + * @since 18.0.0 |
|
65 | + */ |
|
66 | + public function getPath(): string { |
|
67 | + return $this->path; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
@@ -33,38 +33,38 @@ |
||
33 | 33 | */ |
34 | 34 | class NodeAddedToCache extends Event { |
35 | 35 | |
36 | - /** @var IStorage */ |
|
37 | - private $storage; |
|
36 | + /** @var IStorage */ |
|
37 | + private $storage; |
|
38 | 38 | |
39 | - /** @var string */ |
|
40 | - private $path; |
|
39 | + /** @var string */ |
|
40 | + private $path; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IStorage $storage |
|
44 | - * @param string $path |
|
45 | - * @since 18.0.0 |
|
46 | - */ |
|
47 | - public function __construct(IStorage $storage, |
|
48 | - string $path) { |
|
49 | - parent::__construct(); |
|
50 | - $this->storage = $storage; |
|
51 | - $this->path = $path; |
|
52 | - } |
|
42 | + /** |
|
43 | + * @param IStorage $storage |
|
44 | + * @param string $path |
|
45 | + * @since 18.0.0 |
|
46 | + */ |
|
47 | + public function __construct(IStorage $storage, |
|
48 | + string $path) { |
|
49 | + parent::__construct(); |
|
50 | + $this->storage = $storage; |
|
51 | + $this->path = $path; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return IStorage |
|
56 | - * @since 18.0.0 |
|
57 | - */ |
|
58 | - public function getStorage(): IStorage { |
|
59 | - return $this->storage; |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return IStorage |
|
56 | + * @since 18.0.0 |
|
57 | + */ |
|
58 | + public function getStorage(): IStorage { |
|
59 | + return $this->storage; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - * @since 18.0.0 |
|
65 | - */ |
|
66 | - public function getPath(): string { |
|
67 | - return $this->path; |
|
68 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + * @since 18.0.0 |
|
65 | + */ |
|
66 | + public function getPath(): string { |
|
67 | + return $this->path; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
@@ -105,7 +105,7 @@ |
||
105 | 105 | $suffix = '…'; |
106 | 106 | } |
107 | 107 | |
108 | - return $prefix . mb_substr($message, $start, $end - $start) . $suffix; |
|
108 | + return $prefix.mb_substr($message, $start, $end - $start).$suffix; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } |
@@ -32,101 +32,101 @@ |
||
32 | 32 | * @deprecated 20.0.0 |
33 | 33 | */ |
34 | 34 | class Result extends BaseResult { |
35 | - /** |
|
36 | - * @deprecated 20.0.0 |
|
37 | - */ |
|
38 | - public $type = 'comment'; |
|
39 | - /** |
|
40 | - * @deprecated 20.0.0 |
|
41 | - */ |
|
42 | - public $comment; |
|
43 | - /** |
|
44 | - * @deprecated 20.0.0 |
|
45 | - */ |
|
46 | - public $authorId; |
|
47 | - /** |
|
48 | - * @deprecated 20.0.0 |
|
49 | - */ |
|
50 | - public $authorName; |
|
51 | - /** |
|
52 | - * @deprecated 20.0.0 |
|
53 | - */ |
|
54 | - public $path; |
|
55 | - /** |
|
56 | - * @deprecated 20.0.0 |
|
57 | - */ |
|
58 | - public $fileName; |
|
35 | + /** |
|
36 | + * @deprecated 20.0.0 |
|
37 | + */ |
|
38 | + public $type = 'comment'; |
|
39 | + /** |
|
40 | + * @deprecated 20.0.0 |
|
41 | + */ |
|
42 | + public $comment; |
|
43 | + /** |
|
44 | + * @deprecated 20.0.0 |
|
45 | + */ |
|
46 | + public $authorId; |
|
47 | + /** |
|
48 | + * @deprecated 20.0.0 |
|
49 | + */ |
|
50 | + public $authorName; |
|
51 | + /** |
|
52 | + * @deprecated 20.0.0 |
|
53 | + */ |
|
54 | + public $path; |
|
55 | + /** |
|
56 | + * @deprecated 20.0.0 |
|
57 | + */ |
|
58 | + public $fileName; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $search |
|
62 | - * @param IComment $comment |
|
63 | - * @param string $authorName |
|
64 | - * @param string $path |
|
65 | - * @throws NotFoundException |
|
66 | - * @deprecated 20.0.0 |
|
67 | - */ |
|
68 | - public function __construct(string $search, |
|
69 | - IComment $comment, |
|
70 | - string $authorName, |
|
71 | - string $path) { |
|
72 | - parent::__construct( |
|
73 | - (int) $comment->getId(), |
|
74 | - $comment->getMessage() |
|
75 | - /* @todo , [link to file] */ |
|
76 | - ); |
|
60 | + /** |
|
61 | + * @param string $search |
|
62 | + * @param IComment $comment |
|
63 | + * @param string $authorName |
|
64 | + * @param string $path |
|
65 | + * @throws NotFoundException |
|
66 | + * @deprecated 20.0.0 |
|
67 | + */ |
|
68 | + public function __construct(string $search, |
|
69 | + IComment $comment, |
|
70 | + string $authorName, |
|
71 | + string $path) { |
|
72 | + parent::__construct( |
|
73 | + (int) $comment->getId(), |
|
74 | + $comment->getMessage() |
|
75 | + /* @todo , [link to file] */ |
|
76 | + ); |
|
77 | 77 | |
78 | - $this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search); |
|
79 | - $this->authorId = $comment->getActorId(); |
|
80 | - $this->authorName = $authorName; |
|
81 | - $this->fileName = basename($path); |
|
82 | - $this->path = $this->getVisiblePath($path); |
|
83 | - } |
|
78 | + $this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search); |
|
79 | + $this->authorId = $comment->getActorId(); |
|
80 | + $this->authorName = $authorName; |
|
81 | + $this->fileName = basename($path); |
|
82 | + $this->path = $this->getVisiblePath($path); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $path |
|
87 | - * @return string |
|
88 | - * @throws NotFoundException |
|
89 | - */ |
|
90 | - protected function getVisiblePath(string $path): string { |
|
91 | - $segments = explode('/', trim($path, '/'), 3); |
|
85 | + /** |
|
86 | + * @param string $path |
|
87 | + * @return string |
|
88 | + * @throws NotFoundException |
|
89 | + */ |
|
90 | + protected function getVisiblePath(string $path): string { |
|
91 | + $segments = explode('/', trim($path, '/'), 3); |
|
92 | 92 | |
93 | - if (!isset($segments[2])) { |
|
94 | - throw new NotFoundException('Path not inside visible section'); |
|
95 | - } |
|
93 | + if (!isset($segments[2])) { |
|
94 | + throw new NotFoundException('Path not inside visible section'); |
|
95 | + } |
|
96 | 96 | |
97 | - return $segments[2]; |
|
98 | - } |
|
97 | + return $segments[2]; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @param string $message |
|
102 | - * @param string $search |
|
103 | - * @return string |
|
104 | - * @throws NotFoundException |
|
105 | - */ |
|
106 | - protected function getRelevantMessagePart(string $message, string $search): string { |
|
107 | - $start = mb_stripos($message, $search); |
|
108 | - if ($start === false) { |
|
109 | - throw new NotFoundException('Comment section not found'); |
|
110 | - } |
|
100 | + /** |
|
101 | + * @param string $message |
|
102 | + * @param string $search |
|
103 | + * @return string |
|
104 | + * @throws NotFoundException |
|
105 | + */ |
|
106 | + protected function getRelevantMessagePart(string $message, string $search): string { |
|
107 | + $start = mb_stripos($message, $search); |
|
108 | + if ($start === false) { |
|
109 | + throw new NotFoundException('Comment section not found'); |
|
110 | + } |
|
111 | 111 | |
112 | - $end = $start + mb_strlen($search); |
|
112 | + $end = $start + mb_strlen($search); |
|
113 | 113 | |
114 | - if ($start <= 25) { |
|
115 | - $start = 0; |
|
116 | - $prefix = ''; |
|
117 | - } else { |
|
118 | - $start -= 25; |
|
119 | - $prefix = '…'; |
|
120 | - } |
|
114 | + if ($start <= 25) { |
|
115 | + $start = 0; |
|
116 | + $prefix = ''; |
|
117 | + } else { |
|
118 | + $start -= 25; |
|
119 | + $prefix = '…'; |
|
120 | + } |
|
121 | 121 | |
122 | - if ((mb_strlen($message) - $end) <= 25) { |
|
123 | - $end = mb_strlen($message); |
|
124 | - $suffix = ''; |
|
125 | - } else { |
|
126 | - $end += 25; |
|
127 | - $suffix = '…'; |
|
128 | - } |
|
122 | + if ((mb_strlen($message) - $end) <= 25) { |
|
123 | + $end = mb_strlen($message); |
|
124 | + $suffix = ''; |
|
125 | + } else { |
|
126 | + $end += 25; |
|
127 | + $suffix = '…'; |
|
128 | + } |
|
129 | 129 | |
130 | - return $prefix . mb_substr($message, $start, $end - $start) . $suffix; |
|
131 | - } |
|
130 | + return $prefix . mb_substr($message, $start, $end - $start) . $suffix; |
|
131 | + } |
|
132 | 132 | } |
@@ -34,22 +34,22 @@ |
||
34 | 34 | */ |
35 | 35 | class ShareCreatedEvent extends Event { |
36 | 36 | |
37 | - /** @var IShare */ |
|
38 | - private $share; |
|
39 | - |
|
40 | - /** |
|
41 | - * @since 18.0.0 |
|
42 | - */ |
|
43 | - public function __construct(IShare $share) { |
|
44 | - parent::__construct(); |
|
45 | - |
|
46 | - $this->share = $share; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @since 18.0.0 |
|
51 | - */ |
|
52 | - public function getShare(): IShare { |
|
53 | - return $this->share; |
|
54 | - } |
|
37 | + /** @var IShare */ |
|
38 | + private $share; |
|
39 | + |
|
40 | + /** |
|
41 | + * @since 18.0.0 |
|
42 | + */ |
|
43 | + public function __construct(IShare $share) { |
|
44 | + parent::__construct(); |
|
45 | + |
|
46 | + $this->share = $share; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @since 18.0.0 |
|
51 | + */ |
|
52 | + public function getShare(): IShare { |
|
53 | + return $this->share; |
|
54 | + } |
|
55 | 55 | } |
@@ -37,47 +37,47 @@ |
||
37 | 37 | |
38 | 38 | class AcceptController extends Controller { |
39 | 39 | |
40 | - /** @var ShareManager */ |
|
41 | - private $shareManager; |
|
40 | + /** @var ShareManager */ |
|
41 | + private $shareManager; |
|
42 | 42 | |
43 | - /** @var IUserSession */ |
|
44 | - private $userSession; |
|
43 | + /** @var IUserSession */ |
|
44 | + private $userSession; |
|
45 | 45 | |
46 | - /** @var IURLGenerator */ |
|
47 | - private $urlGenerator; |
|
46 | + /** @var IURLGenerator */ |
|
47 | + private $urlGenerator; |
|
48 | 48 | |
49 | - public function __construct(IRequest $request, ShareManager $shareManager, IUserSession $userSession, IURLGenerator $urlGenerator) { |
|
50 | - parent::__construct(Application::APP_ID, $request); |
|
49 | + public function __construct(IRequest $request, ShareManager $shareManager, IUserSession $userSession, IURLGenerator $urlGenerator) { |
|
50 | + parent::__construct(Application::APP_ID, $request); |
|
51 | 51 | |
52 | - $this->shareManager = $shareManager; |
|
53 | - $this->userSession = $userSession; |
|
54 | - $this->urlGenerator = $urlGenerator; |
|
55 | - } |
|
52 | + $this->shareManager = $shareManager; |
|
53 | + $this->userSession = $userSession; |
|
54 | + $this->urlGenerator = $urlGenerator; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @NoAdminRequired |
|
59 | - * @NoCSRFRequired |
|
60 | - */ |
|
61 | - public function accept(string $shareId): Response { |
|
62 | - try { |
|
63 | - $share = $this->shareManager->getShareById($shareId); |
|
64 | - } catch (ShareNotFound $e) { |
|
65 | - return new NotFoundResponse(); |
|
66 | - } |
|
57 | + /** |
|
58 | + * @NoAdminRequired |
|
59 | + * @NoCSRFRequired |
|
60 | + */ |
|
61 | + public function accept(string $shareId): Response { |
|
62 | + try { |
|
63 | + $share = $this->shareManager->getShareById($shareId); |
|
64 | + } catch (ShareNotFound $e) { |
|
65 | + return new NotFoundResponse(); |
|
66 | + } |
|
67 | 67 | |
68 | - $user = $this->userSession->getUser(); |
|
69 | - if ($user === null) { |
|
70 | - return new NotFoundResponse(); |
|
71 | - } |
|
68 | + $user = $this->userSession->getUser(); |
|
69 | + if ($user === null) { |
|
70 | + return new NotFoundResponse(); |
|
71 | + } |
|
72 | 72 | |
73 | - try { |
|
74 | - $share = $this->shareManager->acceptShare($share, $user->getUID()); |
|
75 | - } catch (\Exception $e) { |
|
76 | - // Just ignore |
|
77 | - } |
|
73 | + try { |
|
74 | + $share = $this->shareManager->acceptShare($share, $user->getUID()); |
|
75 | + } catch (\Exception $e) { |
|
76 | + // Just ignore |
|
77 | + } |
|
78 | 78 | |
79 | - $url = $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]); |
|
79 | + $url = $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNode()->getId()]); |
|
80 | 80 | |
81 | - return new RedirectResponse($url); |
|
82 | - } |
|
81 | + return new RedirectResponse($url); |
|
82 | + } |
|
83 | 83 | } |
@@ -36,46 +36,46 @@ |
||
36 | 36 | */ |
37 | 37 | class ExternalShareMenuAction extends SimpleMenuAction { |
38 | 38 | |
39 | - /** @var string */ |
|
40 | - private $owner; |
|
39 | + /** @var string */ |
|
40 | + private $owner; |
|
41 | 41 | |
42 | - /** @var string */ |
|
43 | - private $displayname; |
|
42 | + /** @var string */ |
|
43 | + private $displayname; |
|
44 | 44 | |
45 | - /** @var string */ |
|
46 | - private $shareName; |
|
45 | + /** @var string */ |
|
46 | + private $shareName; |
|
47 | 47 | |
48 | - /** |
|
49 | - * ExternalShareMenuAction constructor. |
|
50 | - * |
|
51 | - * @param string $label |
|
52 | - * @param string $icon |
|
53 | - * @param string $owner |
|
54 | - * @param string $displayname |
|
55 | - * @param string $shareName |
|
56 | - * @since 14.0.0 |
|
57 | - */ |
|
58 | - public function __construct(string $label, string $icon, string $owner, string $displayname, string $shareName) { |
|
59 | - parent::__construct('save', $label, $icon); |
|
60 | - $this->owner = $owner; |
|
61 | - $this->displayname = $displayname; |
|
62 | - $this->shareName = $shareName; |
|
63 | - } |
|
48 | + /** |
|
49 | + * ExternalShareMenuAction constructor. |
|
50 | + * |
|
51 | + * @param string $label |
|
52 | + * @param string $icon |
|
53 | + * @param string $owner |
|
54 | + * @param string $displayname |
|
55 | + * @param string $shareName |
|
56 | + * @since 14.0.0 |
|
57 | + */ |
|
58 | + public function __construct(string $label, string $icon, string $owner, string $displayname, string $shareName) { |
|
59 | + parent::__construct('save', $label, $icon); |
|
60 | + $this->owner = $owner; |
|
61 | + $this->displayname = $displayname; |
|
62 | + $this->shareName = $shareName; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @since 14.0.0 |
|
67 | - */ |
|
68 | - public function render(): string { |
|
69 | - return '<li>' . |
|
70 | - ' <button id="save-external-share" class="icon ' . Util::sanitizeHTML($this->getIcon()) . '" data-protected="false" data-owner-display-name="' . Util::sanitizeHTML($this->displayname) . '" data-owner="' . Util::sanitizeHTML($this->owner) . '" data-name="' . Util::sanitizeHTML($this->shareName) . '">' . Util::sanitizeHTML($this->getLabel()) . '</button>' . |
|
71 | - '</li>' . |
|
72 | - '<li id="external-share-menu-item" class="hidden">' . |
|
73 | - ' <span class="menuitem">' . |
|
74 | - ' <form class="save-form" action="#">' . |
|
75 | - ' <input type="text" id="remote_address" placeholder="[email protected]">' . |
|
76 | - ' <input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>' . |
|
77 | - ' </form>' . |
|
78 | - ' </span>' . |
|
79 | - '</li>'; |
|
80 | - } |
|
65 | + /** |
|
66 | + * @since 14.0.0 |
|
67 | + */ |
|
68 | + public function render(): string { |
|
69 | + return '<li>' . |
|
70 | + ' <button id="save-external-share" class="icon ' . Util::sanitizeHTML($this->getIcon()) . '" data-protected="false" data-owner-display-name="' . Util::sanitizeHTML($this->displayname) . '" data-owner="' . Util::sanitizeHTML($this->owner) . '" data-name="' . Util::sanitizeHTML($this->shareName) . '">' . Util::sanitizeHTML($this->getLabel()) . '</button>' . |
|
71 | + '</li>' . |
|
72 | + '<li id="external-share-menu-item" class="hidden">' . |
|
73 | + ' <span class="menuitem">' . |
|
74 | + ' <form class="save-form" action="#">' . |
|
75 | + ' <input type="text" id="remote_address" placeholder="[email protected]">' . |
|
76 | + ' <input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>' . |
|
77 | + ' </form>' . |
|
78 | + ' </span>' . |
|
79 | + '</li>'; |
|
80 | + } |
|
81 | 81 | } |
@@ -66,16 +66,16 @@ |
||
66 | 66 | * @since 14.0.0 |
67 | 67 | */ |
68 | 68 | public function render(): string { |
69 | - return '<li>' . |
|
70 | - ' <button id="save-external-share" class="icon ' . Util::sanitizeHTML($this->getIcon()) . '" data-protected="false" data-owner-display-name="' . Util::sanitizeHTML($this->displayname) . '" data-owner="' . Util::sanitizeHTML($this->owner) . '" data-name="' . Util::sanitizeHTML($this->shareName) . '">' . Util::sanitizeHTML($this->getLabel()) . '</button>' . |
|
71 | - '</li>' . |
|
72 | - '<li id="external-share-menu-item" class="hidden">' . |
|
73 | - ' <span class="menuitem">' . |
|
74 | - ' <form class="save-form" action="#">' . |
|
75 | - ' <input type="text" id="remote_address" placeholder="[email protected]">' . |
|
76 | - ' <input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>' . |
|
77 | - ' </form>' . |
|
78 | - ' </span>' . |
|
69 | + return '<li>'. |
|
70 | + ' <button id="save-external-share" class="icon '.Util::sanitizeHTML($this->getIcon()).'" data-protected="false" data-owner-display-name="'.Util::sanitizeHTML($this->displayname).'" data-owner="'.Util::sanitizeHTML($this->owner).'" data-name="'.Util::sanitizeHTML($this->shareName).'">'.Util::sanitizeHTML($this->getLabel()).'</button>'. |
|
71 | + '</li>'. |
|
72 | + '<li id="external-share-menu-item" class="hidden">'. |
|
73 | + ' <span class="menuitem">'. |
|
74 | + ' <form class="save-form" action="#">'. |
|
75 | + ' <input type="text" id="remote_address" placeholder="[email protected]">'. |
|
76 | + ' <input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>'. |
|
77 | + ' </form>'. |
|
78 | + ' </span>'. |
|
79 | 79 | '</li>'; |
80 | 80 | } |
81 | 81 | } |
@@ -155,7 +155,7 @@ |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | public function supportedEntities(): array { |
158 | - return [ File::class ]; |
|
158 | + return [File::class]; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | public function isAvailableForScope(int $scope): bool { |
@@ -34,148 +34,148 @@ |
||
34 | 34 | use OCP\WorkflowEngine\IFileCheck; |
35 | 35 | |
36 | 36 | class FileMimeType extends AbstractStringCheck implements IFileCheck { |
37 | - use TFileCheck { |
|
38 | - setFileInfo as _setFileInfo; |
|
39 | - } |
|
40 | - |
|
41 | - /** @var array */ |
|
42 | - protected $mimeType; |
|
43 | - |
|
44 | - /** @var IRequest */ |
|
45 | - protected $request; |
|
46 | - |
|
47 | - /** @var IMimeTypeDetector */ |
|
48 | - protected $mimeTypeDetector; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param IL10N $l |
|
52 | - * @param IRequest $request |
|
53 | - * @param IMimeTypeDetector $mimeTypeDetector |
|
54 | - */ |
|
55 | - public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) { |
|
56 | - parent::__construct($l); |
|
57 | - $this->request = $request; |
|
58 | - $this->mimeTypeDetector = $mimeTypeDetector; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param IStorage $storage |
|
63 | - * @param string $path |
|
64 | - * @param bool $isDir |
|
65 | - */ |
|
66 | - public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
67 | - $this->_setFileInfo($storage, $path, $isDir); |
|
68 | - if (!isset($this->mimeType[$this->storage->getId()][$this->path]) |
|
69 | - || $this->mimeType[$this->storage->getId()][$this->path] === '') { |
|
70 | - if ($isDir) { |
|
71 | - $this->mimeType[$this->storage->getId()][$this->path] = 'httpd/unix-directory'; |
|
72 | - } else { |
|
73 | - $this->mimeType[$this->storage->getId()][$this->path] = null; |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * The mimetype is only cached if the file exists. Otherwise files access |
|
80 | - * control will cache "application/octet-stream" for all the target node on: |
|
81 | - * rename, move, copy and all other methods which create a new item |
|
82 | - * |
|
83 | - * To check this: |
|
84 | - * 1. Add an automated tagging rule which tags on mimetype NOT "httpd/unix-directory" |
|
85 | - * 2. Add an access control rule which checks for any mimetype |
|
86 | - * 3. Create a folder and rename it, the folder should not be tagged, but it is |
|
87 | - * |
|
88 | - * @param string $storageId |
|
89 | - * @param string|null $path |
|
90 | - * @param string $mimeType |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - protected function cacheAndReturnMimeType(string $storageId, ?string $path, string $mimeType): string { |
|
94 | - if ($path !== null && $this->storage->file_exists($path)) { |
|
95 | - $this->mimeType[$storageId][$path] = $mimeType; |
|
96 | - } |
|
97 | - |
|
98 | - return $mimeType; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Make sure that even though the content based check returns an application/octet-stream can still be checked based on mimetypemappings of their extension |
|
103 | - * |
|
104 | - * @param string $operator |
|
105 | - * @param string $value |
|
106 | - * @return bool |
|
107 | - */ |
|
108 | - public function executeCheck($operator, $value) { |
|
109 | - $actualValue = $this->getActualValue(); |
|
110 | - $plainMimetypeResult = $this->executeStringCheck($operator, $value, $actualValue); |
|
111 | - if ($actualValue === 'httpd/unix-directory') { |
|
112 | - return $plainMimetypeResult; |
|
113 | - } |
|
114 | - $detectMimetypeBasedOnFilenameResult = $this->executeStringCheck($operator, $value, $this->mimeTypeDetector->detectPath($this->path)); |
|
115 | - return $plainMimetypeResult || $detectMimetypeBasedOnFilenameResult; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - protected function getActualValue() { |
|
122 | - if ($this->mimeType[$this->storage->getId()][$this->path] !== null) { |
|
123 | - return $this->mimeType[$this->storage->getId()][$this->path]; |
|
124 | - } |
|
125 | - |
|
126 | - if ($this->storage->is_dir($this->path)) { |
|
127 | - return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, 'httpd/unix-directory'); |
|
128 | - } |
|
129 | - |
|
130 | - if ($this->storage->file_exists($this->path) && $this->storage->filesize($this->path)) { |
|
131 | - $path = $this->storage->getLocalFile($this->path); |
|
132 | - $mimeType = $this->mimeTypeDetector->detectContent($path); |
|
133 | - return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $mimeType); |
|
134 | - } |
|
135 | - |
|
136 | - if ($this->isWebDAVRequest() || $this->isPublicWebDAVRequest()) { |
|
137 | - // Creating a folder |
|
138 | - if ($this->request->getMethod() === 'MKCOL') { |
|
139 | - return 'httpd/unix-directory'; |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - // We do not cache this, as the file did not exist yet. |
|
144 | - // In case it does in the future, we will check with detectContent() |
|
145 | - // again to get the real mimetype of the content, rather than |
|
146 | - // guessing it from the path. |
|
147 | - return $this->mimeTypeDetector->detectPath($this->path); |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @return bool |
|
152 | - */ |
|
153 | - protected function isWebDAVRequest() { |
|
154 | - return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
155 | - $this->request->getPathInfo() === '/webdav' || |
|
156 | - strpos($this->request->getPathInfo(), '/webdav/') === 0 || |
|
157 | - $this->request->getPathInfo() === '/dav/files' || |
|
158 | - strpos($this->request->getPathInfo(), '/dav/files/') === 0 || |
|
159 | - $this->request->getPathInfo() === '/dav/uploads' || |
|
160 | - strpos($this->request->getPathInfo(), '/dav/uploads/') === 0 |
|
161 | - ); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @return bool |
|
166 | - */ |
|
167 | - protected function isPublicWebDAVRequest() { |
|
168 | - return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && ( |
|
169 | - $this->request->getPathInfo() === '/webdav' || |
|
170 | - strpos($this->request->getPathInfo(), '/webdav/') === 0 |
|
171 | - ); |
|
172 | - } |
|
173 | - |
|
174 | - public function supportedEntities(): array { |
|
175 | - return [ File::class ]; |
|
176 | - } |
|
177 | - |
|
178 | - public function isAvailableForScope(int $scope): bool { |
|
179 | - return true; |
|
180 | - } |
|
37 | + use TFileCheck { |
|
38 | + setFileInfo as _setFileInfo; |
|
39 | + } |
|
40 | + |
|
41 | + /** @var array */ |
|
42 | + protected $mimeType; |
|
43 | + |
|
44 | + /** @var IRequest */ |
|
45 | + protected $request; |
|
46 | + |
|
47 | + /** @var IMimeTypeDetector */ |
|
48 | + protected $mimeTypeDetector; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param IL10N $l |
|
52 | + * @param IRequest $request |
|
53 | + * @param IMimeTypeDetector $mimeTypeDetector |
|
54 | + */ |
|
55 | + public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) { |
|
56 | + parent::__construct($l); |
|
57 | + $this->request = $request; |
|
58 | + $this->mimeTypeDetector = $mimeTypeDetector; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param IStorage $storage |
|
63 | + * @param string $path |
|
64 | + * @param bool $isDir |
|
65 | + */ |
|
66 | + public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
67 | + $this->_setFileInfo($storage, $path, $isDir); |
|
68 | + if (!isset($this->mimeType[$this->storage->getId()][$this->path]) |
|
69 | + || $this->mimeType[$this->storage->getId()][$this->path] === '') { |
|
70 | + if ($isDir) { |
|
71 | + $this->mimeType[$this->storage->getId()][$this->path] = 'httpd/unix-directory'; |
|
72 | + } else { |
|
73 | + $this->mimeType[$this->storage->getId()][$this->path] = null; |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * The mimetype is only cached if the file exists. Otherwise files access |
|
80 | + * control will cache "application/octet-stream" for all the target node on: |
|
81 | + * rename, move, copy and all other methods which create a new item |
|
82 | + * |
|
83 | + * To check this: |
|
84 | + * 1. Add an automated tagging rule which tags on mimetype NOT "httpd/unix-directory" |
|
85 | + * 2. Add an access control rule which checks for any mimetype |
|
86 | + * 3. Create a folder and rename it, the folder should not be tagged, but it is |
|
87 | + * |
|
88 | + * @param string $storageId |
|
89 | + * @param string|null $path |
|
90 | + * @param string $mimeType |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + protected function cacheAndReturnMimeType(string $storageId, ?string $path, string $mimeType): string { |
|
94 | + if ($path !== null && $this->storage->file_exists($path)) { |
|
95 | + $this->mimeType[$storageId][$path] = $mimeType; |
|
96 | + } |
|
97 | + |
|
98 | + return $mimeType; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Make sure that even though the content based check returns an application/octet-stream can still be checked based on mimetypemappings of their extension |
|
103 | + * |
|
104 | + * @param string $operator |
|
105 | + * @param string $value |
|
106 | + * @return bool |
|
107 | + */ |
|
108 | + public function executeCheck($operator, $value) { |
|
109 | + $actualValue = $this->getActualValue(); |
|
110 | + $plainMimetypeResult = $this->executeStringCheck($operator, $value, $actualValue); |
|
111 | + if ($actualValue === 'httpd/unix-directory') { |
|
112 | + return $plainMimetypeResult; |
|
113 | + } |
|
114 | + $detectMimetypeBasedOnFilenameResult = $this->executeStringCheck($operator, $value, $this->mimeTypeDetector->detectPath($this->path)); |
|
115 | + return $plainMimetypeResult || $detectMimetypeBasedOnFilenameResult; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + protected function getActualValue() { |
|
122 | + if ($this->mimeType[$this->storage->getId()][$this->path] !== null) { |
|
123 | + return $this->mimeType[$this->storage->getId()][$this->path]; |
|
124 | + } |
|
125 | + |
|
126 | + if ($this->storage->is_dir($this->path)) { |
|
127 | + return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, 'httpd/unix-directory'); |
|
128 | + } |
|
129 | + |
|
130 | + if ($this->storage->file_exists($this->path) && $this->storage->filesize($this->path)) { |
|
131 | + $path = $this->storage->getLocalFile($this->path); |
|
132 | + $mimeType = $this->mimeTypeDetector->detectContent($path); |
|
133 | + return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $mimeType); |
|
134 | + } |
|
135 | + |
|
136 | + if ($this->isWebDAVRequest() || $this->isPublicWebDAVRequest()) { |
|
137 | + // Creating a folder |
|
138 | + if ($this->request->getMethod() === 'MKCOL') { |
|
139 | + return 'httpd/unix-directory'; |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + // We do not cache this, as the file did not exist yet. |
|
144 | + // In case it does in the future, we will check with detectContent() |
|
145 | + // again to get the real mimetype of the content, rather than |
|
146 | + // guessing it from the path. |
|
147 | + return $this->mimeTypeDetector->detectPath($this->path); |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @return bool |
|
152 | + */ |
|
153 | + protected function isWebDAVRequest() { |
|
154 | + return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
155 | + $this->request->getPathInfo() === '/webdav' || |
|
156 | + strpos($this->request->getPathInfo(), '/webdav/') === 0 || |
|
157 | + $this->request->getPathInfo() === '/dav/files' || |
|
158 | + strpos($this->request->getPathInfo(), '/dav/files/') === 0 || |
|
159 | + $this->request->getPathInfo() === '/dav/uploads' || |
|
160 | + strpos($this->request->getPathInfo(), '/dav/uploads/') === 0 |
|
161 | + ); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @return bool |
|
166 | + */ |
|
167 | + protected function isPublicWebDAVRequest() { |
|
168 | + return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && ( |
|
169 | + $this->request->getPathInfo() === '/webdav' || |
|
170 | + strpos($this->request->getPathInfo(), '/webdav/') === 0 |
|
171 | + ); |
|
172 | + } |
|
173 | + |
|
174 | + public function supportedEntities(): array { |
|
175 | + return [ File::class ]; |
|
176 | + } |
|
177 | + |
|
178 | + public function isAvailableForScope(int $scope): bool { |
|
179 | + return true; |
|
180 | + } |
|
181 | 181 | } |