@@ -34,49 +34,49 @@ |
||
34 | 34 | use Sabre\DAV\INode; |
35 | 35 | |
36 | 36 | class RestoreFolder implements ICollection, IMoveTarget { |
37 | - public function createFile($name, $data = null) { |
|
38 | - throw new Forbidden(); |
|
39 | - } |
|
40 | - |
|
41 | - public function createDirectory($name) { |
|
42 | - throw new Forbidden(); |
|
43 | - } |
|
44 | - |
|
45 | - public function getChild($name) { |
|
46 | - return null; |
|
47 | - } |
|
48 | - |
|
49 | - public function delete() { |
|
50 | - throw new Forbidden(); |
|
51 | - } |
|
52 | - |
|
53 | - public function getName() { |
|
54 | - return 'restore'; |
|
55 | - } |
|
56 | - |
|
57 | - public function setName($name) { |
|
58 | - throw new Forbidden(); |
|
59 | - } |
|
60 | - |
|
61 | - public function getLastModified(): int { |
|
62 | - return 0; |
|
63 | - } |
|
64 | - |
|
65 | - public function getChildren(): array { |
|
66 | - return []; |
|
67 | - } |
|
68 | - |
|
69 | - public function childExists($name): bool { |
|
70 | - return false; |
|
71 | - } |
|
72 | - |
|
73 | - public function moveInto($targetName, $sourcePath, INode $sourceNode): bool { |
|
74 | - if (!($sourceNode instanceof VersionFile)) { |
|
75 | - return false; |
|
76 | - } |
|
77 | - |
|
78 | - $sourceNode->rollBack(); |
|
79 | - return true; |
|
80 | - } |
|
37 | + public function createFile($name, $data = null) { |
|
38 | + throw new Forbidden(); |
|
39 | + } |
|
40 | + |
|
41 | + public function createDirectory($name) { |
|
42 | + throw new Forbidden(); |
|
43 | + } |
|
44 | + |
|
45 | + public function getChild($name) { |
|
46 | + return null; |
|
47 | + } |
|
48 | + |
|
49 | + public function delete() { |
|
50 | + throw new Forbidden(); |
|
51 | + } |
|
52 | + |
|
53 | + public function getName() { |
|
54 | + return 'restore'; |
|
55 | + } |
|
56 | + |
|
57 | + public function setName($name) { |
|
58 | + throw new Forbidden(); |
|
59 | + } |
|
60 | + |
|
61 | + public function getLastModified(): int { |
|
62 | + return 0; |
|
63 | + } |
|
64 | + |
|
65 | + public function getChildren(): array { |
|
66 | + return []; |
|
67 | + } |
|
68 | + |
|
69 | + public function childExists($name): bool { |
|
70 | + return false; |
|
71 | + } |
|
72 | + |
|
73 | + public function moveInto($targetName, $sourcePath, INode $sourceNode): bool { |
|
74 | + if (!($sourceNode instanceof VersionFile)) { |
|
75 | + return false; |
|
76 | + } |
|
77 | + |
|
78 | + $sourceNode->rollBack(); |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | } |
@@ -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 | } |
@@ -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 | } |
@@ -13,92 +13,92 @@ |
||
13 | 13 | * @deprecated 20.0.0 |
14 | 14 | */ |
15 | 15 | class Result extends BaseResult { |
16 | - /** |
|
17 | - * @deprecated 20.0.0 |
|
18 | - */ |
|
19 | - public $type = 'comment'; |
|
20 | - /** |
|
21 | - * @deprecated 20.0.0 |
|
22 | - */ |
|
23 | - public $comment; |
|
24 | - /** |
|
25 | - * @deprecated 20.0.0 |
|
26 | - */ |
|
27 | - public $authorId; |
|
28 | - /** |
|
29 | - * @deprecated 20.0.0 |
|
30 | - */ |
|
31 | - public $path; |
|
32 | - /** |
|
33 | - * @deprecated 20.0.0 |
|
34 | - */ |
|
35 | - public $fileName; |
|
16 | + /** |
|
17 | + * @deprecated 20.0.0 |
|
18 | + */ |
|
19 | + public $type = 'comment'; |
|
20 | + /** |
|
21 | + * @deprecated 20.0.0 |
|
22 | + */ |
|
23 | + public $comment; |
|
24 | + /** |
|
25 | + * @deprecated 20.0.0 |
|
26 | + */ |
|
27 | + public $authorId; |
|
28 | + /** |
|
29 | + * @deprecated 20.0.0 |
|
30 | + */ |
|
31 | + public $path; |
|
32 | + /** |
|
33 | + * @deprecated 20.0.0 |
|
34 | + */ |
|
35 | + public $fileName; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @throws NotFoundException |
|
39 | - * @deprecated 20.0.0 |
|
40 | - */ |
|
41 | - public function __construct( |
|
42 | - string $search, |
|
43 | - IComment $comment, |
|
44 | - /** |
|
45 | - * @deprecated 20.0.0 |
|
46 | - */ |
|
47 | - public string $authorName, |
|
48 | - string $path, |
|
49 | - ) { |
|
50 | - parent::__construct( |
|
51 | - $comment->getId(), |
|
52 | - $comment->getMessage() |
|
53 | - /* @todo , [link to file] */ |
|
54 | - ); |
|
37 | + /** |
|
38 | + * @throws NotFoundException |
|
39 | + * @deprecated 20.0.0 |
|
40 | + */ |
|
41 | + public function __construct( |
|
42 | + string $search, |
|
43 | + IComment $comment, |
|
44 | + /** |
|
45 | + * @deprecated 20.0.0 |
|
46 | + */ |
|
47 | + public string $authorName, |
|
48 | + string $path, |
|
49 | + ) { |
|
50 | + parent::__construct( |
|
51 | + $comment->getId(), |
|
52 | + $comment->getMessage() |
|
53 | + /* @todo , [link to file] */ |
|
54 | + ); |
|
55 | 55 | |
56 | - $this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search); |
|
57 | - $this->authorId = $comment->getActorId(); |
|
58 | - $this->fileName = basename($path); |
|
59 | - $this->path = $this->getVisiblePath($path); |
|
60 | - } |
|
56 | + $this->comment = $this->getRelevantMessagePart($comment->getMessage(), $search); |
|
57 | + $this->authorId = $comment->getActorId(); |
|
58 | + $this->fileName = basename($path); |
|
59 | + $this->path = $this->getVisiblePath($path); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @throws NotFoundException |
|
64 | - */ |
|
65 | - protected function getVisiblePath(string $path): string { |
|
66 | - $segments = explode('/', trim($path, '/'), 3); |
|
62 | + /** |
|
63 | + * @throws NotFoundException |
|
64 | + */ |
|
65 | + protected function getVisiblePath(string $path): string { |
|
66 | + $segments = explode('/', trim($path, '/'), 3); |
|
67 | 67 | |
68 | - if (!isset($segments[2])) { |
|
69 | - throw new NotFoundException('Path not inside visible section'); |
|
70 | - } |
|
68 | + if (!isset($segments[2])) { |
|
69 | + throw new NotFoundException('Path not inside visible section'); |
|
70 | + } |
|
71 | 71 | |
72 | - return $segments[2]; |
|
73 | - } |
|
72 | + return $segments[2]; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @throws NotFoundException |
|
77 | - */ |
|
78 | - protected function getRelevantMessagePart(string $message, string $search): string { |
|
79 | - $start = mb_stripos($message, $search); |
|
80 | - if ($start === false) { |
|
81 | - throw new NotFoundException('Comment section not found'); |
|
82 | - } |
|
75 | + /** |
|
76 | + * @throws NotFoundException |
|
77 | + */ |
|
78 | + protected function getRelevantMessagePart(string $message, string $search): string { |
|
79 | + $start = mb_stripos($message, $search); |
|
80 | + if ($start === false) { |
|
81 | + throw new NotFoundException('Comment section not found'); |
|
82 | + } |
|
83 | 83 | |
84 | - $end = $start + mb_strlen($search); |
|
84 | + $end = $start + mb_strlen($search); |
|
85 | 85 | |
86 | - if ($start <= 25) { |
|
87 | - $start = 0; |
|
88 | - $prefix = ''; |
|
89 | - } else { |
|
90 | - $start -= 25; |
|
91 | - $prefix = '…'; |
|
92 | - } |
|
86 | + if ($start <= 25) { |
|
87 | + $start = 0; |
|
88 | + $prefix = ''; |
|
89 | + } else { |
|
90 | + $start -= 25; |
|
91 | + $prefix = '…'; |
|
92 | + } |
|
93 | 93 | |
94 | - if ((mb_strlen($message) - $end) <= 25) { |
|
95 | - $end = mb_strlen($message); |
|
96 | - $suffix = ''; |
|
97 | - } else { |
|
98 | - $end += 25; |
|
99 | - $suffix = '…'; |
|
100 | - } |
|
94 | + if ((mb_strlen($message) - $end) <= 25) { |
|
95 | + $end = mb_strlen($message); |
|
96 | + $suffix = ''; |
|
97 | + } else { |
|
98 | + $end += 25; |
|
99 | + $suffix = '…'; |
|
100 | + } |
|
101 | 101 | |
102 | - return $prefix . mb_substr($message, $start, $end - $start) . $suffix; |
|
103 | - } |
|
102 | + return $prefix . mb_substr($message, $start, $end - $start) . $suffix; |
|
103 | + } |
|
104 | 104 | } |
@@ -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 { |
@@ -15,141 +15,141 @@ |
||
15 | 15 | use OCP\WorkflowEngine\IFileCheck; |
16 | 16 | |
17 | 17 | class FileMimeType extends AbstractStringCheck implements IFileCheck { |
18 | - use TFileCheck { |
|
19 | - setFileInfo as _setFileInfo; |
|
20 | - } |
|
21 | - |
|
22 | - /** @var array */ |
|
23 | - protected $mimeType; |
|
24 | - |
|
25 | - /** |
|
26 | - * @param IL10N $l |
|
27 | - * @param IRequest $request |
|
28 | - * @param IMimeTypeDetector $mimeTypeDetector |
|
29 | - */ |
|
30 | - public function __construct( |
|
31 | - IL10N $l, |
|
32 | - protected IRequest $request, |
|
33 | - protected IMimeTypeDetector $mimeTypeDetector, |
|
34 | - ) { |
|
35 | - parent::__construct($l); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @param IStorage $storage |
|
40 | - * @param string $path |
|
41 | - * @param bool $isDir |
|
42 | - */ |
|
43 | - public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
44 | - $this->_setFileInfo($storage, $path, $isDir); |
|
45 | - if (!isset($this->mimeType[$this->storage->getId()][$this->path]) |
|
46 | - || $this->mimeType[$this->storage->getId()][$this->path] === '') { |
|
47 | - if ($isDir) { |
|
48 | - $this->mimeType[$this->storage->getId()][$this->path] = 'httpd/unix-directory'; |
|
49 | - } else { |
|
50 | - $this->mimeType[$this->storage->getId()][$this->path] = null; |
|
51 | - } |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * The mimetype is only cached if the file has a valid mimetype. Otherwise files access |
|
57 | - * control will cache "application/octet-stream" for all the target node on: |
|
58 | - * rename, move, copy and all other methods which create a new item |
|
59 | - * |
|
60 | - * To check this: |
|
61 | - * 1. Add an automated tagging rule which tags on mimetype NOT "httpd/unix-directory" |
|
62 | - * 2. Add an access control rule which checks for any mimetype |
|
63 | - * 3. Create a folder and rename it, the folder should not be tagged, but it is |
|
64 | - * |
|
65 | - * @param string $storageId |
|
66 | - * @param string|null $path |
|
67 | - * @param string $mimeType |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - protected function cacheAndReturnMimeType(string $storageId, ?string $path, string $mimeType): string { |
|
71 | - if ($path !== null && $mimeType !== 'application/octet-stream') { |
|
72 | - $this->mimeType[$storageId][$path] = $mimeType; |
|
73 | - } |
|
74 | - |
|
75 | - return $mimeType; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Make sure that even though the content based check returns an application/octet-stream can still be checked based on mimetypemappings of their extension |
|
80 | - * |
|
81 | - * @param string $operator |
|
82 | - * @param string $value |
|
83 | - * @return bool |
|
84 | - */ |
|
85 | - public function executeCheck($operator, $value) { |
|
86 | - return $this->executeStringCheck($operator, $value, $this->getActualValue()); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - protected function getActualValue() { |
|
93 | - if ($this->mimeType[$this->storage->getId()][$this->path] !== null) { |
|
94 | - return $this->mimeType[$this->storage->getId()][$this->path]; |
|
95 | - } |
|
96 | - $cacheEntry = $this->storage->getCache()->get($this->path); |
|
97 | - if ($cacheEntry && $cacheEntry->getMimeType() !== 'application/octet-stream') { |
|
98 | - return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $cacheEntry->getMimeType()); |
|
99 | - } |
|
100 | - |
|
101 | - if ($this->storage->file_exists($this->path) |
|
102 | - && $this->storage->filesize($this->path) |
|
103 | - && $this->storage->instanceOfStorage(Local::class) |
|
104 | - ) { |
|
105 | - $path = $this->storage->getLocalFile($this->path); |
|
106 | - $mimeType = $this->mimeTypeDetector->detectContent($path); |
|
107 | - return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $mimeType); |
|
108 | - } |
|
109 | - |
|
110 | - if ($this->isWebDAVRequest() || $this->isPublicWebDAVRequest()) { |
|
111 | - // Creating a folder |
|
112 | - if ($this->request->getMethod() === 'MKCOL') { |
|
113 | - return 'httpd/unix-directory'; |
|
114 | - } |
|
115 | - } |
|
116 | - |
|
117 | - // We do not cache this, as the file did not exist yet. |
|
118 | - // In case it does in the future, we will check with detectContent() |
|
119 | - // again to get the real mimetype of the content, rather than |
|
120 | - // guessing it from the path. |
|
121 | - return $this->mimeTypeDetector->detectPath($this->path); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @return bool |
|
126 | - */ |
|
127 | - protected function isWebDAVRequest() { |
|
128 | - return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
129 | - $this->request->getPathInfo() === '/webdav' |
|
130 | - || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') |
|
131 | - || $this->request->getPathInfo() === '/dav/files' |
|
132 | - || str_starts_with($this->request->getPathInfo() ?? '', '/dav/files/') |
|
133 | - || $this->request->getPathInfo() === '/dav/uploads' |
|
134 | - || str_starts_with($this->request->getPathInfo() ?? '', '/dav/uploads/') |
|
135 | - ); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @return bool |
|
140 | - */ |
|
141 | - protected function isPublicWebDAVRequest() { |
|
142 | - return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && ( |
|
143 | - $this->request->getPathInfo() === '/webdav' |
|
144 | - || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - public function supportedEntities(): array { |
|
149 | - return [ File::class ]; |
|
150 | - } |
|
151 | - |
|
152 | - public function isAvailableForScope(int $scope): bool { |
|
153 | - return true; |
|
154 | - } |
|
18 | + use TFileCheck { |
|
19 | + setFileInfo as _setFileInfo; |
|
20 | + } |
|
21 | + |
|
22 | + /** @var array */ |
|
23 | + protected $mimeType; |
|
24 | + |
|
25 | + /** |
|
26 | + * @param IL10N $l |
|
27 | + * @param IRequest $request |
|
28 | + * @param IMimeTypeDetector $mimeTypeDetector |
|
29 | + */ |
|
30 | + public function __construct( |
|
31 | + IL10N $l, |
|
32 | + protected IRequest $request, |
|
33 | + protected IMimeTypeDetector $mimeTypeDetector, |
|
34 | + ) { |
|
35 | + parent::__construct($l); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @param IStorage $storage |
|
40 | + * @param string $path |
|
41 | + * @param bool $isDir |
|
42 | + */ |
|
43 | + public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void { |
|
44 | + $this->_setFileInfo($storage, $path, $isDir); |
|
45 | + if (!isset($this->mimeType[$this->storage->getId()][$this->path]) |
|
46 | + || $this->mimeType[$this->storage->getId()][$this->path] === '') { |
|
47 | + if ($isDir) { |
|
48 | + $this->mimeType[$this->storage->getId()][$this->path] = 'httpd/unix-directory'; |
|
49 | + } else { |
|
50 | + $this->mimeType[$this->storage->getId()][$this->path] = null; |
|
51 | + } |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * The mimetype is only cached if the file has a valid mimetype. Otherwise files access |
|
57 | + * control will cache "application/octet-stream" for all the target node on: |
|
58 | + * rename, move, copy and all other methods which create a new item |
|
59 | + * |
|
60 | + * To check this: |
|
61 | + * 1. Add an automated tagging rule which tags on mimetype NOT "httpd/unix-directory" |
|
62 | + * 2. Add an access control rule which checks for any mimetype |
|
63 | + * 3. Create a folder and rename it, the folder should not be tagged, but it is |
|
64 | + * |
|
65 | + * @param string $storageId |
|
66 | + * @param string|null $path |
|
67 | + * @param string $mimeType |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + protected function cacheAndReturnMimeType(string $storageId, ?string $path, string $mimeType): string { |
|
71 | + if ($path !== null && $mimeType !== 'application/octet-stream') { |
|
72 | + $this->mimeType[$storageId][$path] = $mimeType; |
|
73 | + } |
|
74 | + |
|
75 | + return $mimeType; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Make sure that even though the content based check returns an application/octet-stream can still be checked based on mimetypemappings of their extension |
|
80 | + * |
|
81 | + * @param string $operator |
|
82 | + * @param string $value |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | + public function executeCheck($operator, $value) { |
|
86 | + return $this->executeStringCheck($operator, $value, $this->getActualValue()); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + protected function getActualValue() { |
|
93 | + if ($this->mimeType[$this->storage->getId()][$this->path] !== null) { |
|
94 | + return $this->mimeType[$this->storage->getId()][$this->path]; |
|
95 | + } |
|
96 | + $cacheEntry = $this->storage->getCache()->get($this->path); |
|
97 | + if ($cacheEntry && $cacheEntry->getMimeType() !== 'application/octet-stream') { |
|
98 | + return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $cacheEntry->getMimeType()); |
|
99 | + } |
|
100 | + |
|
101 | + if ($this->storage->file_exists($this->path) |
|
102 | + && $this->storage->filesize($this->path) |
|
103 | + && $this->storage->instanceOfStorage(Local::class) |
|
104 | + ) { |
|
105 | + $path = $this->storage->getLocalFile($this->path); |
|
106 | + $mimeType = $this->mimeTypeDetector->detectContent($path); |
|
107 | + return $this->cacheAndReturnMimeType($this->storage->getId(), $this->path, $mimeType); |
|
108 | + } |
|
109 | + |
|
110 | + if ($this->isWebDAVRequest() || $this->isPublicWebDAVRequest()) { |
|
111 | + // Creating a folder |
|
112 | + if ($this->request->getMethod() === 'MKCOL') { |
|
113 | + return 'httpd/unix-directory'; |
|
114 | + } |
|
115 | + } |
|
116 | + |
|
117 | + // We do not cache this, as the file did not exist yet. |
|
118 | + // In case it does in the future, we will check with detectContent() |
|
119 | + // again to get the real mimetype of the content, rather than |
|
120 | + // guessing it from the path. |
|
121 | + return $this->mimeTypeDetector->detectPath($this->path); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @return bool |
|
126 | + */ |
|
127 | + protected function isWebDAVRequest() { |
|
128 | + return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && ( |
|
129 | + $this->request->getPathInfo() === '/webdav' |
|
130 | + || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') |
|
131 | + || $this->request->getPathInfo() === '/dav/files' |
|
132 | + || str_starts_with($this->request->getPathInfo() ?? '', '/dav/files/') |
|
133 | + || $this->request->getPathInfo() === '/dav/uploads' |
|
134 | + || str_starts_with($this->request->getPathInfo() ?? '', '/dav/uploads/') |
|
135 | + ); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @return bool |
|
140 | + */ |
|
141 | + protected function isPublicWebDAVRequest() { |
|
142 | + return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && ( |
|
143 | + $this->request->getPathInfo() === '/webdav' |
|
144 | + || str_starts_with($this->request->getPathInfo() ?? '', '/webdav/') |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + public function supportedEntities(): array { |
|
149 | + return [ File::class ]; |
|
150 | + } |
|
151 | + |
|
152 | + public function isAvailableForScope(int $scope): bool { |
|
153 | + return true; |
|
154 | + } |
|
155 | 155 | } |
@@ -106,12 +106,12 @@ |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | return [ |
109 | - 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
109 | + 'providers' => array_map(function(IProvidesPersonalSettings $provider) use ($user) { |
|
110 | 110 | return [ |
111 | 111 | 'provider' => $provider, |
112 | 112 | 'settings' => $provider->getPersonalSettings($user) |
113 | 113 | ]; |
114 | - }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
114 | + }, array_filter($this->providerLoader->getProviders($user), function(IProvider $provider) { |
|
115 | 115 | return $provider instanceof IProvidesPersonalSettings; |
116 | 116 | })) |
117 | 117 | ]; |
@@ -24,85 +24,85 @@ |
||
24 | 24 | |
25 | 25 | class TwoFactor implements ISettings { |
26 | 26 | |
27 | - /** @var ProviderLoader */ |
|
28 | - private $providerLoader; |
|
27 | + /** @var ProviderLoader */ |
|
28 | + private $providerLoader; |
|
29 | 29 | |
30 | - /** @var MandatoryTwoFactor */ |
|
31 | - private $mandatoryTwoFactor; |
|
30 | + /** @var MandatoryTwoFactor */ |
|
31 | + private $mandatoryTwoFactor; |
|
32 | 32 | |
33 | - public function __construct( |
|
34 | - ProviderLoader $providerLoader, |
|
35 | - MandatoryTwoFactor $mandatoryTwoFactor, |
|
36 | - private IUserSession $userSession, |
|
37 | - private IConfig $config, |
|
38 | - private ?string $userId, |
|
39 | - ) { |
|
40 | - $this->providerLoader = $providerLoader; |
|
41 | - $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
42 | - } |
|
33 | + public function __construct( |
|
34 | + ProviderLoader $providerLoader, |
|
35 | + MandatoryTwoFactor $mandatoryTwoFactor, |
|
36 | + private IUserSession $userSession, |
|
37 | + private IConfig $config, |
|
38 | + private ?string $userId, |
|
39 | + ) { |
|
40 | + $this->providerLoader = $providerLoader; |
|
41 | + $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
42 | + } |
|
43 | 43 | |
44 | - public function getForm(): TemplateResponse { |
|
45 | - return new TemplateResponse('settings', 'settings/personal/security/twofactor', [ |
|
46 | - 'twoFactorProviderData' => $this->getTwoFactorProviderData(), |
|
47 | - ]); |
|
48 | - } |
|
44 | + public function getForm(): TemplateResponse { |
|
45 | + return new TemplateResponse('settings', 'settings/personal/security/twofactor', [ |
|
46 | + 'twoFactorProviderData' => $this->getTwoFactorProviderData(), |
|
47 | + ]); |
|
48 | + } |
|
49 | 49 | |
50 | - public function getSection(): ?string { |
|
51 | - if (!$this->shouldShow()) { |
|
52 | - return null; |
|
53 | - } |
|
54 | - return 'security'; |
|
55 | - } |
|
50 | + public function getSection(): ?string { |
|
51 | + if (!$this->shouldShow()) { |
|
52 | + return null; |
|
53 | + } |
|
54 | + return 'security'; |
|
55 | + } |
|
56 | 56 | |
57 | - public function getPriority(): int { |
|
58 | - return 15; |
|
59 | - } |
|
57 | + public function getPriority(): int { |
|
58 | + return 15; |
|
59 | + } |
|
60 | 60 | |
61 | - private function shouldShow(): bool { |
|
62 | - $user = $this->userSession->getUser(); |
|
63 | - if (is_null($user)) { |
|
64 | - // Actually impossible, but still … |
|
65 | - return false; |
|
66 | - } |
|
61 | + private function shouldShow(): bool { |
|
62 | + $user = $this->userSession->getUser(); |
|
63 | + if (is_null($user)) { |
|
64 | + // Actually impossible, but still … |
|
65 | + return false; |
|
66 | + } |
|
67 | 67 | |
68 | - // Anyone who's supposed to use 2FA should see 2FA settings |
|
69 | - if ($this->mandatoryTwoFactor->isEnforcedFor($user)) { |
|
70 | - return true; |
|
71 | - } |
|
68 | + // Anyone who's supposed to use 2FA should see 2FA settings |
|
69 | + if ($this->mandatoryTwoFactor->isEnforcedFor($user)) { |
|
70 | + return true; |
|
71 | + } |
|
72 | 72 | |
73 | - // If there is at least one provider with personal settings but it's not |
|
74 | - // the backup codes provider, then these settings should show. |
|
75 | - try { |
|
76 | - $providers = $this->providerLoader->getProviders($user); |
|
77 | - } catch (Exception $e) { |
|
78 | - // Let's hope for the best |
|
79 | - return true; |
|
80 | - } |
|
81 | - foreach ($providers as $provider) { |
|
82 | - if ($provider instanceof IProvidesPersonalSettings |
|
83 | - && !($provider instanceof BackupCodesProvider)) { |
|
84 | - return true; |
|
85 | - } |
|
86 | - } |
|
87 | - return false; |
|
88 | - } |
|
73 | + // If there is at least one provider with personal settings but it's not |
|
74 | + // the backup codes provider, then these settings should show. |
|
75 | + try { |
|
76 | + $providers = $this->providerLoader->getProviders($user); |
|
77 | + } catch (Exception $e) { |
|
78 | + // Let's hope for the best |
|
79 | + return true; |
|
80 | + } |
|
81 | + foreach ($providers as $provider) { |
|
82 | + if ($provider instanceof IProvidesPersonalSettings |
|
83 | + && !($provider instanceof BackupCodesProvider)) { |
|
84 | + return true; |
|
85 | + } |
|
86 | + } |
|
87 | + return false; |
|
88 | + } |
|
89 | 89 | |
90 | - private function getTwoFactorProviderData(): array { |
|
91 | - $user = $this->userSession->getUser(); |
|
92 | - if (is_null($user)) { |
|
93 | - // Actually impossible, but still … |
|
94 | - return []; |
|
95 | - } |
|
90 | + private function getTwoFactorProviderData(): array { |
|
91 | + $user = $this->userSession->getUser(); |
|
92 | + if (is_null($user)) { |
|
93 | + // Actually impossible, but still … |
|
94 | + return []; |
|
95 | + } |
|
96 | 96 | |
97 | - return [ |
|
98 | - 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
99 | - return [ |
|
100 | - 'provider' => $provider, |
|
101 | - 'settings' => $provider->getPersonalSettings($user) |
|
102 | - ]; |
|
103 | - }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
104 | - return $provider instanceof IProvidesPersonalSettings; |
|
105 | - })) |
|
106 | - ]; |
|
107 | - } |
|
97 | + return [ |
|
98 | + 'providers' => array_map(function (IProvidesPersonalSettings $provider) use ($user) { |
|
99 | + return [ |
|
100 | + 'provider' => $provider, |
|
101 | + 'settings' => $provider->getPersonalSettings($user) |
|
102 | + ]; |
|
103 | + }, array_filter($this->providerLoader->getProviders($user), function (IProvider $provider) { |
|
104 | + return $provider instanceof IProvidesPersonalSettings; |
|
105 | + })) |
|
106 | + ]; |
|
107 | + } |
|
108 | 108 | } |
@@ -32,42 +32,42 @@ |
||
32 | 32 | */ |
33 | 33 | interface ICalendarProvider { |
34 | 34 | |
35 | - /** |
|
36 | - * Provides the appId of the plugin |
|
37 | - * |
|
38 | - * @since 19.0.0 |
|
39 | - * @return string AppId |
|
40 | - */ |
|
41 | - public function getAppId(): string; |
|
35 | + /** |
|
36 | + * Provides the appId of the plugin |
|
37 | + * |
|
38 | + * @since 19.0.0 |
|
39 | + * @return string AppId |
|
40 | + */ |
|
41 | + public function getAppId(): string; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Fetches all calendars for a given principal uri |
|
45 | - * |
|
46 | - * @since 19.0.0 |
|
47 | - * @param string $principalUri E.g. principals/users/user1 |
|
48 | - * @return ExternalCalendar[] Array of all calendars |
|
49 | - */ |
|
50 | - public function fetchAllForCalendarHome(string $principalUri): array; |
|
43 | + /** |
|
44 | + * Fetches all calendars for a given principal uri |
|
45 | + * |
|
46 | + * @since 19.0.0 |
|
47 | + * @param string $principalUri E.g. principals/users/user1 |
|
48 | + * @return ExternalCalendar[] Array of all calendars |
|
49 | + */ |
|
50 | + public function fetchAllForCalendarHome(string $principalUri): array; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Checks whether plugin has a calendar for a given principalUri and calendarUri |
|
54 | - * |
|
55 | - * @since 19.0.0 |
|
56 | - * @param string $principalUri E.g. principals/users/user1 |
|
57 | - * @param string $calendarUri E.g. personal |
|
58 | - * @return bool True if calendar for principalUri and calendarUri exists, false otherwise |
|
59 | - */ |
|
60 | - public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool; |
|
52 | + /** |
|
53 | + * Checks whether plugin has a calendar for a given principalUri and calendarUri |
|
54 | + * |
|
55 | + * @since 19.0.0 |
|
56 | + * @param string $principalUri E.g. principals/users/user1 |
|
57 | + * @param string $calendarUri E.g. personal |
|
58 | + * @return bool True if calendar for principalUri and calendarUri exists, false otherwise |
|
59 | + */ |
|
60 | + public function hasCalendarInCalendarHome(string $principalUri, string $calendarUri): bool; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Fetches a calendar for a given principalUri and calendarUri |
|
64 | - * Returns null if calendar does not exist |
|
65 | - * |
|
66 | - * @since 19.0.0 |
|
67 | - * @param string $principalUri E.g. principals/users/user1 |
|
68 | - * @param string $calendarUri E.g. personal |
|
69 | - * @return ExternalCalendar|null Calendar if it exists, null otherwise |
|
70 | - */ |
|
71 | - public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; |
|
62 | + /** |
|
63 | + * Fetches a calendar for a given principalUri and calendarUri |
|
64 | + * Returns null if calendar does not exist |
|
65 | + * |
|
66 | + * @since 19.0.0 |
|
67 | + * @param string $principalUri E.g. principals/users/user1 |
|
68 | + * @param string $calendarUri E.g. personal |
|
69 | + * @return ExternalCalendar|null Calendar if it exists, null otherwise |
|
70 | + */ |
|
71 | + public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; |
|
72 | 72 | |
73 | 73 | } |
@@ -33,61 +33,61 @@ |
||
33 | 33 | |
34 | 34 | class Version010000Date20200304152605 extends SimpleMigrationStep { |
35 | 35 | |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * |
|
41 | - * @return ISchemaWrapper |
|
42 | - */ |
|
43 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
44 | - /** @var ISchemaWrapper $schema */ |
|
45 | - $schema = $schemaClosure(); |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * |
|
41 | + * @return ISchemaWrapper |
|
42 | + */ |
|
43 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
44 | + /** @var ISchemaWrapper $schema */ |
|
45 | + $schema = $schemaClosure(); |
|
46 | 46 | |
47 | - $table = $schema->createTable(RecentContactMapper::TABLE_NAME); |
|
48 | - $table->addColumn('id', 'integer', [ |
|
49 | - 'autoincrement' => true, |
|
50 | - 'notnull' => true, |
|
51 | - 'length' => 4, |
|
52 | - ]); |
|
53 | - $table->addColumn('actor_uid', 'string', [ |
|
54 | - 'notnull' => true, |
|
55 | - 'length' => 64, |
|
56 | - ]); |
|
57 | - $table->addColumn('uid', 'string', [ |
|
58 | - 'notnull' => false, |
|
59 | - 'length' => 64, |
|
60 | - ]); |
|
61 | - $table->addColumn('email', 'string', [ |
|
62 | - 'notnull' => false, |
|
63 | - 'length' => 255, |
|
64 | - ]); |
|
65 | - $table->addColumn('federated_cloud_id', 'string', [ |
|
66 | - 'notnull' => false, |
|
67 | - 'length' => 255, |
|
68 | - ]); |
|
69 | - $table->addColumn('card', 'blob', [ |
|
70 | - 'notnull' => true, |
|
71 | - ]); |
|
72 | - $table->addColumn('last_contact', 'integer', [ |
|
73 | - 'notnull' => true, |
|
74 | - 'length' => 4, |
|
75 | - ]); |
|
76 | - $table->setPrimaryKey(['id']); |
|
77 | - // To find all recent entries |
|
78 | - $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
79 | - // To find a specific entry |
|
80 | - $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
81 | - // To find all recent entries with a given UID |
|
82 | - $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
83 | - // To find all recent entries with a given email address |
|
84 | - $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
85 | - // To find all recent entries with a give federated cloud id |
|
86 | - $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
87 | - // For the cleanup |
|
88 | - $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
47 | + $table = $schema->createTable(RecentContactMapper::TABLE_NAME); |
|
48 | + $table->addColumn('id', 'integer', [ |
|
49 | + 'autoincrement' => true, |
|
50 | + 'notnull' => true, |
|
51 | + 'length' => 4, |
|
52 | + ]); |
|
53 | + $table->addColumn('actor_uid', 'string', [ |
|
54 | + 'notnull' => true, |
|
55 | + 'length' => 64, |
|
56 | + ]); |
|
57 | + $table->addColumn('uid', 'string', [ |
|
58 | + 'notnull' => false, |
|
59 | + 'length' => 64, |
|
60 | + ]); |
|
61 | + $table->addColumn('email', 'string', [ |
|
62 | + 'notnull' => false, |
|
63 | + 'length' => 255, |
|
64 | + ]); |
|
65 | + $table->addColumn('federated_cloud_id', 'string', [ |
|
66 | + 'notnull' => false, |
|
67 | + 'length' => 255, |
|
68 | + ]); |
|
69 | + $table->addColumn('card', 'blob', [ |
|
70 | + 'notnull' => true, |
|
71 | + ]); |
|
72 | + $table->addColumn('last_contact', 'integer', [ |
|
73 | + 'notnull' => true, |
|
74 | + 'length' => 4, |
|
75 | + ]); |
|
76 | + $table->setPrimaryKey(['id']); |
|
77 | + // To find all recent entries |
|
78 | + $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
79 | + // To find a specific entry |
|
80 | + $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
81 | + // To find all recent entries with a given UID |
|
82 | + $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
83 | + // To find all recent entries with a given email address |
|
84 | + $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
85 | + // To find all recent entries with a give federated cloud id |
|
86 | + $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
87 | + // For the cleanup |
|
88 | + $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
89 | 89 | |
90 | - return $schema; |
|
91 | - } |
|
90 | + return $schema; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | } |
@@ -75,17 +75,17 @@ |
||
75 | 75 | ]); |
76 | 76 | $table->setPrimaryKey(['id']); |
77 | 77 | // To find all recent entries |
78 | - $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME . '_actor_uid'); |
|
78 | + $table->addIndex(['actor_uid'], RecentContactMapper::TABLE_NAME.'_actor_uid'); |
|
79 | 79 | // To find a specific entry |
80 | - $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME . '_id_uid'); |
|
80 | + $table->addIndex(['id', 'actor_uid'], RecentContactMapper::TABLE_NAME.'_id_uid'); |
|
81 | 81 | // To find all recent entries with a given UID |
82 | - $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME . '_uid'); |
|
82 | + $table->addIndex(['uid'], RecentContactMapper::TABLE_NAME.'_uid'); |
|
83 | 83 | // To find all recent entries with a given email address |
84 | - $table->addIndex(['email'], RecentContactMapper::TABLE_NAME . '_email'); |
|
84 | + $table->addIndex(['email'], RecentContactMapper::TABLE_NAME.'_email'); |
|
85 | 85 | // To find all recent entries with a give federated cloud id |
86 | - $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME . '_fed_id'); |
|
86 | + $table->addIndex(['federated_cloud_id'], RecentContactMapper::TABLE_NAME.'_fed_id'); |
|
87 | 87 | // For the cleanup |
88 | - $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME . '_last_contact'); |
|
88 | + $table->addIndex(['last_contact'], RecentContactMapper::TABLE_NAME.'_last_contact'); |
|
89 | 89 | |
90 | 90 | return $schema; |
91 | 91 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | $baseDir = $vendorDir; |
7 | 7 | |
8 | 8 | return array( |
9 | - 'OCA\\ContactsInteraction\\' => array($baseDir . '/../lib'), |
|
9 | + 'OCA\\ContactsInteraction\\' => array($baseDir.'/../lib'), |
|
10 | 10 | ); |