@@ -31,47 +31,47 @@ |
||
31 | 31 | |
32 | 32 | class Version11301Date20191205150729 extends SimpleMigrationStep { |
33 | 33 | |
34 | - /** |
|
35 | - * @param IOutput $output |
|
36 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37 | - * @param array $options |
|
38 | - * @return null|ISchemaWrapper |
|
39 | - */ |
|
40 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
41 | - /** @var ISchemaWrapper $schema */ |
|
42 | - $schema = $schemaClosure(); |
|
34 | + /** |
|
35 | + * @param IOutput $output |
|
36 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37 | + * @param array $options |
|
38 | + * @return null|ISchemaWrapper |
|
39 | + */ |
|
40 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
41 | + /** @var ISchemaWrapper $schema */ |
|
42 | + $schema = $schemaClosure(); |
|
43 | 43 | |
44 | - $table = $schema->createTable('user_transfer_owner'); |
|
45 | - $table->addColumn('id', 'bigint', [ |
|
46 | - 'autoincrement' => true, |
|
47 | - 'notnull' => true, |
|
48 | - 'length' => 20, |
|
49 | - 'unsigned' => true, |
|
50 | - ]); |
|
51 | - $table->addColumn('source_user', 'string', [ |
|
52 | - 'notnull' => true, |
|
53 | - 'length' => 64, |
|
54 | - ]); |
|
55 | - $table->addColumn('target_user', 'string', [ |
|
56 | - 'notnull' => true, |
|
57 | - 'length' => 64, |
|
58 | - ]); |
|
59 | - $table->addColumn('file_id', 'bigint', [ |
|
60 | - 'notnull' => true, |
|
61 | - 'length' => 20, |
|
62 | - ]); |
|
63 | - $table->addColumn('node_name', 'string', [ |
|
64 | - 'notnull' => true, |
|
65 | - 'length' => 255, |
|
66 | - ]); |
|
67 | - $table->setPrimaryKey(['id']); |
|
44 | + $table = $schema->createTable('user_transfer_owner'); |
|
45 | + $table->addColumn('id', 'bigint', [ |
|
46 | + 'autoincrement' => true, |
|
47 | + 'notnull' => true, |
|
48 | + 'length' => 20, |
|
49 | + 'unsigned' => true, |
|
50 | + ]); |
|
51 | + $table->addColumn('source_user', 'string', [ |
|
52 | + 'notnull' => true, |
|
53 | + 'length' => 64, |
|
54 | + ]); |
|
55 | + $table->addColumn('target_user', 'string', [ |
|
56 | + 'notnull' => true, |
|
57 | + 'length' => 64, |
|
58 | + ]); |
|
59 | + $table->addColumn('file_id', 'bigint', [ |
|
60 | + 'notnull' => true, |
|
61 | + 'length' => 20, |
|
62 | + ]); |
|
63 | + $table->addColumn('node_name', 'string', [ |
|
64 | + 'notnull' => true, |
|
65 | + 'length' => 255, |
|
66 | + ]); |
|
67 | + $table->setPrimaryKey(['id']); |
|
68 | 68 | |
69 | - // Quite radical, we just assume no one updates cross beta with a pending request. |
|
70 | - // Do not try this at home |
|
71 | - if ($schema->hasTable('user_transfer_ownership')) { |
|
72 | - $schema->dropTable('user_transfer_ownership'); |
|
73 | - } |
|
69 | + // Quite radical, we just assume no one updates cross beta with a pending request. |
|
70 | + // Do not try this at home |
|
71 | + if ($schema->hasTable('user_transfer_ownership')) { |
|
72 | + $schema->dropTable('user_transfer_ownership'); |
|
73 | + } |
|
74 | 74 | |
75 | - return $schema; |
|
76 | - } |
|
75 | + return $schema; |
|
76 | + } |
|
77 | 77 | } |
@@ -27,5 +27,5 @@ |
||
27 | 27 | * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher |
28 | 28 | */ |
29 | 29 | abstract class BasicEmitter implements Emitter { |
30 | - use EmitterTrait; |
|
30 | + use EmitterTrait; |
|
31 | 31 | } |
@@ -36,12 +36,12 @@ |
||
36 | 36 | * @since 18.0.0 |
37 | 37 | */ |
38 | 38 | interface IFileCheck extends IEntityCheck { |
39 | - /** |
|
40 | - * @param IStorage $storage |
|
41 | - * @param string $path |
|
42 | - * @param bool $isDir |
|
43 | - * @since 18.0.0 |
|
44 | - */ |
|
45 | - public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void; |
|
39 | + /** |
|
40 | + * @param IStorage $storage |
|
41 | + * @param string $path |
|
42 | + * @param bool $isDir |
|
43 | + * @since 18.0.0 |
|
44 | + */ |
|
45 | + public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void; |
|
46 | 46 | |
47 | 47 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -33,46 +33,46 @@ |
||
33 | 33 | * @since 14.0.0 |
34 | 34 | */ |
35 | 35 | class ExternalShareMenuAction extends SimpleMenuAction { |
36 | - /** @var string */ |
|
37 | - private $owner; |
|
36 | + /** @var string */ |
|
37 | + private $owner; |
|
38 | 38 | |
39 | - /** @var string */ |
|
40 | - private $displayname; |
|
39 | + /** @var string */ |
|
40 | + private $displayname; |
|
41 | 41 | |
42 | - /** @var string */ |
|
43 | - private $shareName; |
|
42 | + /** @var string */ |
|
43 | + private $shareName; |
|
44 | 44 | |
45 | - /** |
|
46 | - * ExternalShareMenuAction constructor. |
|
47 | - * |
|
48 | - * @param string $label |
|
49 | - * @param string $icon |
|
50 | - * @param string $owner |
|
51 | - * @param string $displayname |
|
52 | - * @param string $shareName |
|
53 | - * @since 14.0.0 |
|
54 | - */ |
|
55 | - public function __construct(string $label, string $icon, string $owner, string $displayname, string $shareName) { |
|
56 | - parent::__construct('save', $label, $icon); |
|
57 | - $this->owner = $owner; |
|
58 | - $this->displayname = $displayname; |
|
59 | - $this->shareName = $shareName; |
|
60 | - } |
|
45 | + /** |
|
46 | + * ExternalShareMenuAction constructor. |
|
47 | + * |
|
48 | + * @param string $label |
|
49 | + * @param string $icon |
|
50 | + * @param string $owner |
|
51 | + * @param string $displayname |
|
52 | + * @param string $shareName |
|
53 | + * @since 14.0.0 |
|
54 | + */ |
|
55 | + public function __construct(string $label, string $icon, string $owner, string $displayname, string $shareName) { |
|
56 | + parent::__construct('save', $label, $icon); |
|
57 | + $this->owner = $owner; |
|
58 | + $this->displayname = $displayname; |
|
59 | + $this->shareName = $shareName; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @since 14.0.0 |
|
64 | - */ |
|
65 | - public function render(): string { |
|
66 | - return '<li>' . |
|
67 | - ' <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>' . |
|
68 | - '</li>' . |
|
69 | - '<li id="external-share-menu-item" class="hidden">' . |
|
70 | - ' <span class="menuitem">' . |
|
71 | - ' <form class="save-form" action="#">' . |
|
72 | - ' <input type="text" id="remote_address" placeholder="[email protected]">' . |
|
73 | - ' <input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>' . |
|
74 | - ' </form>' . |
|
75 | - ' </span>' . |
|
76 | - '</li>'; |
|
77 | - } |
|
62 | + /** |
|
63 | + * @since 14.0.0 |
|
64 | + */ |
|
65 | + public function render(): string { |
|
66 | + return '<li>' . |
|
67 | + ' <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>' . |
|
68 | + '</li>' . |
|
69 | + '<li id="external-share-menu-item" class="hidden">' . |
|
70 | + ' <span class="menuitem">' . |
|
71 | + ' <form class="save-form" action="#">' . |
|
72 | + ' <input type="text" id="remote_address" placeholder="[email protected]">' . |
|
73 | + ' <input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>' . |
|
74 | + ' </form>' . |
|
75 | + ' </span>' . |
|
76 | + '</li>'; |
|
77 | + } |
|
78 | 78 | } |
@@ -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 { |
@@ -35,151 +35,151 @@ |
||
35 | 35 | use OCP\WorkflowEngine\IFileCheck; |
36 | 36 | |
37 | 37 | class FileMimeType extends AbstractStringCheck implements IFileCheck { |
38 | - use TFileCheck { |
|
39 | - setFileInfo as _setFileInfo; |
|
40 | - } |
|
41 | - |
|
42 | - /** @var array */ |
|
43 | - protected $mimeType; |
|
44 | - |
|
45 | - /** @var IRequest */ |
|
46 | - protected $request; |
|
47 | - |
|
48 | - /** @var IMimeTypeDetector */ |
|
49 | - protected $mimeTypeDetector; |
|
50 | - |
|
51 | - /** |
|
52 | - * @param IL10N $l |
|
53 | - * @param IRequest $request |
|
54 | - * @param IMimeTypeDetector $mimeTypeDetector |
|
55 | - */ |
|
56 | - public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) { |
|
57 | - parent::__construct($l); |
|
58 | - $this->request = $request; |
|
59 | - $this->mimeTypeDetector = $mimeTypeDetector; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @param IStorage $storage |
|
64 | - * @param string $path |
|
65 | - * @param bool $isDir |
|
66 | - */ |
|
67 | - public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
68 | - $this->_setFileInfo($storage, $path, $isDir); |
|
69 | - if (!isset($this->mimeType[$this->storage->getId()][$this->path]) |
|
70 | - || $this->mimeType[$this->storage->getId()][$this->path] === '') { |
|
71 | - if ($isDir) { |
|
72 | - $this->mimeType[$this->storage->getId()][$this->path] = 'httpd/unix-directory'; |
|
73 | - } else { |
|
74 | - $this->mimeType[$this->storage->getId()][$this->path] = null; |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * The mimetype is only cached if the file has a valid mimetype. Otherwise files access |
|
81 | - * control will cache "application/octet-stream" for all the target node on: |
|
82 | - * rename, move, copy and all other methods which create a new item |
|
83 | - * |
|
84 | - * To check this: |
|
85 | - * 1. Add an automated tagging rule which tags on mimetype NOT "httpd/unix-directory" |
|
86 | - * 2. Add an access control rule which checks for any mimetype |
|
87 | - * 3. Create a folder and rename it, the folder should not be tagged, but it is |
|
88 | - * |
|
89 | - * @param string $storageId |
|
90 | - * @param string|null $path |
|
91 | - * @param string $mimeType |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - protected function cacheAndReturnMimeType(string $storageId, ?string $path, string $mimeType): string { |
|
95 | - if ($path !== null && $mimeType !== 'application/octet-stream') { |
|
96 | - $this->mimeType[$storageId][$path] = $mimeType; |
|
97 | - } |
|
98 | - |
|
99 | - return $mimeType; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Make sure that even though the content based check returns an application/octet-stream can still be checked based on mimetypemappings of their extension |
|
104 | - * |
|
105 | - * @param string $operator |
|
106 | - * @param string $value |
|
107 | - * @return bool |
|
108 | - */ |
|
109 | - public function executeCheck($operator, $value) { |
|
110 | - $actualValue = $this->getActualValue(); |
|
111 | - $plainMimetypeResult = $this->executeStringCheck($operator, $value, $actualValue); |
|
112 | - if ($actualValue === 'httpd/unix-directory') { |
|
113 | - return $plainMimetypeResult; |
|
114 | - } |
|
115 | - $detectMimetypeBasedOnFilenameResult = $this->executeStringCheck($operator, $value, $this->mimeTypeDetector->detectPath($this->path)); |
|
116 | - return $plainMimetypeResult || $detectMimetypeBasedOnFilenameResult; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - protected function getActualValue() { |
|
123 | - if ($this->mimeType[$this->storage->getId()][$this->path] !== null) { |
|
124 | - return $this->mimeType[$this->storage->getId()][$this->path]; |
|
125 | - } |
|
126 | - $cacheEntry = $this->storage->getCache()->get($this->path); |
|
127 | - if ($cacheEntry && $cacheEntry->getMimeType() !== 'application/octet-stream') { |
|
128 | - return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $cacheEntry->getMimeType()); |
|
129 | - } |
|
130 | - |
|
131 | - if ($this->storage->file_exists($this->path) && |
|
132 | - $this->storage->filesize($this->path) && |
|
133 | - $this->storage->instanceOfStorage(Local::class) |
|
134 | - ) { |
|
135 | - $path = $this->storage->getLocalFile($this->path); |
|
136 | - $mimeType = $this->mimeTypeDetector->detectContent($path); |
|
137 | - return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $mimeType); |
|
138 | - } |
|
139 | - |
|
140 | - if ($this->isWebDAVRequest() || $this->isPublicWebDAVRequest()) { |
|
141 | - // Creating a folder |
|
142 | - if ($this->request->getMethod() === 'MKCOL') { |
|
143 | - return 'httpd/unix-directory'; |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - // We do not cache this, as the file did not exist yet. |
|
148 | - // In case it does in the future, we will check with detectContent() |
|
149 | - // again to get the real mimetype of the content, rather than |
|
150 | - // guessing it from the path. |
|
151 | - return $this->mimeTypeDetector->detectPath($this->path); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @return bool |
|
156 | - */ |
|
157 | - protected function isWebDAVRequest() { |
|
158 | - return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
159 | - $this->request->getPathInfo() === '/webdav' || |
|
160 | - strpos($this->request->getPathInfo(), '/webdav/') === 0 || |
|
161 | - $this->request->getPathInfo() === '/dav/files' || |
|
162 | - strpos($this->request->getPathInfo(), '/dav/files/') === 0 || |
|
163 | - $this->request->getPathInfo() === '/dav/uploads' || |
|
164 | - strpos($this->request->getPathInfo(), '/dav/uploads/') === 0 |
|
165 | - ); |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return bool |
|
170 | - */ |
|
171 | - protected function isPublicWebDAVRequest() { |
|
172 | - return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && ( |
|
173 | - $this->request->getPathInfo() === '/webdav' || |
|
174 | - strpos($this->request->getPathInfo(), '/webdav/') === 0 |
|
175 | - ); |
|
176 | - } |
|
177 | - |
|
178 | - public function supportedEntities(): array { |
|
179 | - return [ File::class ]; |
|
180 | - } |
|
181 | - |
|
182 | - public function isAvailableForScope(int $scope): bool { |
|
183 | - return true; |
|
184 | - } |
|
38 | + use TFileCheck { |
|
39 | + setFileInfo as _setFileInfo; |
|
40 | + } |
|
41 | + |
|
42 | + /** @var array */ |
|
43 | + protected $mimeType; |
|
44 | + |
|
45 | + /** @var IRequest */ |
|
46 | + protected $request; |
|
47 | + |
|
48 | + /** @var IMimeTypeDetector */ |
|
49 | + protected $mimeTypeDetector; |
|
50 | + |
|
51 | + /** |
|
52 | + * @param IL10N $l |
|
53 | + * @param IRequest $request |
|
54 | + * @param IMimeTypeDetector $mimeTypeDetector |
|
55 | + */ |
|
56 | + public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) { |
|
57 | + parent::__construct($l); |
|
58 | + $this->request = $request; |
|
59 | + $this->mimeTypeDetector = $mimeTypeDetector; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @param IStorage $storage |
|
64 | + * @param string $path |
|
65 | + * @param bool $isDir |
|
66 | + */ |
|
67 | + public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
68 | + $this->_setFileInfo($storage, $path, $isDir); |
|
69 | + if (!isset($this->mimeType[$this->storage->getId()][$this->path]) |
|
70 | + || $this->mimeType[$this->storage->getId()][$this->path] === '') { |
|
71 | + if ($isDir) { |
|
72 | + $this->mimeType[$this->storage->getId()][$this->path] = 'httpd/unix-directory'; |
|
73 | + } else { |
|
74 | + $this->mimeType[$this->storage->getId()][$this->path] = null; |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * The mimetype is only cached if the file has a valid mimetype. Otherwise files access |
|
81 | + * control will cache "application/octet-stream" for all the target node on: |
|
82 | + * rename, move, copy and all other methods which create a new item |
|
83 | + * |
|
84 | + * To check this: |
|
85 | + * 1. Add an automated tagging rule which tags on mimetype NOT "httpd/unix-directory" |
|
86 | + * 2. Add an access control rule which checks for any mimetype |
|
87 | + * 3. Create a folder and rename it, the folder should not be tagged, but it is |
|
88 | + * |
|
89 | + * @param string $storageId |
|
90 | + * @param string|null $path |
|
91 | + * @param string $mimeType |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + protected function cacheAndReturnMimeType(string $storageId, ?string $path, string $mimeType): string { |
|
95 | + if ($path !== null && $mimeType !== 'application/octet-stream') { |
|
96 | + $this->mimeType[$storageId][$path] = $mimeType; |
|
97 | + } |
|
98 | + |
|
99 | + return $mimeType; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Make sure that even though the content based check returns an application/octet-stream can still be checked based on mimetypemappings of their extension |
|
104 | + * |
|
105 | + * @param string $operator |
|
106 | + * @param string $value |
|
107 | + * @return bool |
|
108 | + */ |
|
109 | + public function executeCheck($operator, $value) { |
|
110 | + $actualValue = $this->getActualValue(); |
|
111 | + $plainMimetypeResult = $this->executeStringCheck($operator, $value, $actualValue); |
|
112 | + if ($actualValue === 'httpd/unix-directory') { |
|
113 | + return $plainMimetypeResult; |
|
114 | + } |
|
115 | + $detectMimetypeBasedOnFilenameResult = $this->executeStringCheck($operator, $value, $this->mimeTypeDetector->detectPath($this->path)); |
|
116 | + return $plainMimetypeResult || $detectMimetypeBasedOnFilenameResult; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + protected function getActualValue() { |
|
123 | + if ($this->mimeType[$this->storage->getId()][$this->path] !== null) { |
|
124 | + return $this->mimeType[$this->storage->getId()][$this->path]; |
|
125 | + } |
|
126 | + $cacheEntry = $this->storage->getCache()->get($this->path); |
|
127 | + if ($cacheEntry && $cacheEntry->getMimeType() !== 'application/octet-stream') { |
|
128 | + return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $cacheEntry->getMimeType()); |
|
129 | + } |
|
130 | + |
|
131 | + if ($this->storage->file_exists($this->path) && |
|
132 | + $this->storage->filesize($this->path) && |
|
133 | + $this->storage->instanceOfStorage(Local::class) |
|
134 | + ) { |
|
135 | + $path = $this->storage->getLocalFile($this->path); |
|
136 | + $mimeType = $this->mimeTypeDetector->detectContent($path); |
|
137 | + return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $mimeType); |
|
138 | + } |
|
139 | + |
|
140 | + if ($this->isWebDAVRequest() || $this->isPublicWebDAVRequest()) { |
|
141 | + // Creating a folder |
|
142 | + if ($this->request->getMethod() === 'MKCOL') { |
|
143 | + return 'httpd/unix-directory'; |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + // We do not cache this, as the file did not exist yet. |
|
148 | + // In case it does in the future, we will check with detectContent() |
|
149 | + // again to get the real mimetype of the content, rather than |
|
150 | + // guessing it from the path. |
|
151 | + return $this->mimeTypeDetector->detectPath($this->path); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @return bool |
|
156 | + */ |
|
157 | + protected function isWebDAVRequest() { |
|
158 | + return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
159 | + $this->request->getPathInfo() === '/webdav' || |
|
160 | + strpos($this->request->getPathInfo(), '/webdav/') === 0 || |
|
161 | + $this->request->getPathInfo() === '/dav/files' || |
|
162 | + strpos($this->request->getPathInfo(), '/dav/files/') === 0 || |
|
163 | + $this->request->getPathInfo() === '/dav/uploads' || |
|
164 | + strpos($this->request->getPathInfo(), '/dav/uploads/') === 0 |
|
165 | + ); |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * @return bool |
|
170 | + */ |
|
171 | + protected function isPublicWebDAVRequest() { |
|
172 | + return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && ( |
|
173 | + $this->request->getPathInfo() === '/webdav' || |
|
174 | + strpos($this->request->getPathInfo(), '/webdav/') === 0 |
|
175 | + ); |
|
176 | + } |
|
177 | + |
|
178 | + public function supportedEntities(): array { |
|
179 | + return [ File::class ]; |
|
180 | + } |
|
181 | + |
|
182 | + public function isAvailableForScope(int $scope): bool { |
|
183 | + return true; |
|
184 | + } |
|
185 | 185 | } |
@@ -30,30 +30,30 @@ |
||
30 | 30 | |
31 | 31 | class Groupware implements IIconSection { |
32 | 32 | |
33 | - /** @var IL10N */ |
|
34 | - private $l; |
|
33 | + /** @var IL10N */ |
|
34 | + private $l; |
|
35 | 35 | |
36 | - /** @var IURLGenerator */ |
|
37 | - private $urlGenerator; |
|
36 | + /** @var IURLGenerator */ |
|
37 | + private $urlGenerator; |
|
38 | 38 | |
39 | - public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | - $this->l = $l; |
|
41 | - $this->urlGenerator = $urlGenerator; |
|
42 | - } |
|
39 | + public function __construct(IL10N $l, IURLGenerator $urlGenerator) { |
|
40 | + $this->l = $l; |
|
41 | + $this->urlGenerator = $urlGenerator; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getIcon(): string { |
|
45 | - return $this->urlGenerator->imagePath('core', 'places/contacts.svg'); |
|
46 | - } |
|
44 | + public function getIcon(): string { |
|
45 | + return $this->urlGenerator->imagePath('core', 'places/contacts.svg'); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getID(): string { |
|
49 | - return 'groupware'; |
|
50 | - } |
|
48 | + public function getID(): string { |
|
49 | + return 'groupware'; |
|
50 | + } |
|
51 | 51 | |
52 | - public function getName(): string { |
|
53 | - return $this->l->t('Groupware'); |
|
54 | - } |
|
52 | + public function getName(): string { |
|
53 | + return $this->l->t('Groupware'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function getPriority(): int { |
|
57 | - return 50; |
|
58 | - } |
|
56 | + public function getPriority(): int { |
|
57 | + return 50; |
|
58 | + } |
|
59 | 59 | } |