@@ -31,32 +31,32 @@ |
||
31 | 31 | * @since 27.0.0 |
32 | 32 | */ |
33 | 33 | class AppEnableEvent extends Event { |
34 | - private string $appId; |
|
35 | - /** @var string[] */ |
|
36 | - private array $groupIds; |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string[] $groupIds |
|
40 | - * @since 27.0.0 |
|
41 | - */ |
|
42 | - public function __construct(string $appId, array $groupIds = []) { |
|
43 | - parent::__construct(); |
|
44 | - |
|
45 | - $this->appId = $appId; |
|
46 | - $this->groupIds = $groupIds; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @since 27.0.0 |
|
51 | - */ |
|
52 | - public function getAppId(): string { |
|
53 | - return $this->appId; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @since 27.0.0 |
|
58 | - */ |
|
59 | - public function getGroupIds(): array { |
|
60 | - return $this->groupIds; |
|
61 | - } |
|
34 | + private string $appId; |
|
35 | + /** @var string[] */ |
|
36 | + private array $groupIds; |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string[] $groupIds |
|
40 | + * @since 27.0.0 |
|
41 | + */ |
|
42 | + public function __construct(string $appId, array $groupIds = []) { |
|
43 | + parent::__construct(); |
|
44 | + |
|
45 | + $this->appId = $appId; |
|
46 | + $this->groupIds = $groupIds; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @since 27.0.0 |
|
51 | + */ |
|
52 | + public function getAppId(): string { |
|
53 | + return $this->appId; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @since 27.0.0 |
|
58 | + */ |
|
59 | + public function getGroupIds(): array { |
|
60 | + return $this->groupIds; |
|
61 | + } |
|
62 | 62 | } |
@@ -31,21 +31,21 @@ |
||
31 | 31 | * @since 27.0.0 |
32 | 32 | */ |
33 | 33 | class AppDisableEvent extends Event { |
34 | - private string $appId; |
|
34 | + private string $appId; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @since 27.0.0 |
|
38 | - */ |
|
39 | - public function __construct(string $appId) { |
|
40 | - parent::__construct(); |
|
36 | + /** |
|
37 | + * @since 27.0.0 |
|
38 | + */ |
|
39 | + public function __construct(string $appId) { |
|
40 | + parent::__construct(); |
|
41 | 41 | |
42 | - $this->appId = $appId; |
|
43 | - } |
|
42 | + $this->appId = $appId; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @since 27.0.0 |
|
47 | - */ |
|
48 | - public function getAppId(): string { |
|
49 | - return $this->appId; |
|
50 | - } |
|
45 | + /** |
|
46 | + * @since 27.0.0 |
|
47 | + */ |
|
48 | + public function getAppId(): string { |
|
49 | + return $this->appId; |
|
50 | + } |
|
51 | 51 | } |
@@ -27,31 +27,31 @@ |
||
27 | 27 | use OCP\Files\Search\ISearchOperator; |
28 | 28 | |
29 | 29 | class QueryOptimizerStep { |
30 | - /** |
|
31 | - * Allow optimizer steps to inspect the entire query before starting processing |
|
32 | - * |
|
33 | - * @param ISearchOperator $operator |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function inspectOperator(ISearchOperator $operator): void { |
|
37 | - if ($operator instanceof ISearchBinaryOperator) { |
|
38 | - foreach ($operator->getArguments() as $argument) { |
|
39 | - $this->inspectOperator($argument); |
|
40 | - } |
|
41 | - } |
|
42 | - } |
|
30 | + /** |
|
31 | + * Allow optimizer steps to inspect the entire query before starting processing |
|
32 | + * |
|
33 | + * @param ISearchOperator $operator |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function inspectOperator(ISearchOperator $operator): void { |
|
37 | + if ($operator instanceof ISearchBinaryOperator) { |
|
38 | + foreach ($operator->getArguments() as $argument) { |
|
39 | + $this->inspectOperator($argument); |
|
40 | + } |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Allow optimizer steps to modify query operators |
|
46 | - * |
|
47 | - * @param ISearchOperator $operator |
|
48 | - * @return void |
|
49 | - */ |
|
50 | - public function processOperator(ISearchOperator &$operator) { |
|
51 | - if ($operator instanceof ISearchBinaryOperator) { |
|
52 | - foreach ($operator->getArguments() as $argument) { |
|
53 | - $this->processOperator($argument); |
|
54 | - } |
|
55 | - } |
|
56 | - } |
|
44 | + /** |
|
45 | + * Allow optimizer steps to modify query operators |
|
46 | + * |
|
47 | + * @param ISearchOperator $operator |
|
48 | + * @return void |
|
49 | + */ |
|
50 | + public function processOperator(ISearchOperator &$operator) { |
|
51 | + if ($operator instanceof ISearchBinaryOperator) { |
|
52 | + foreach ($operator->getArguments() as $argument) { |
|
53 | + $this->processOperator($argument); |
|
54 | + } |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
@@ -34,196 +34,196 @@ |
||
34 | 34 | use OCP\Files\SimpleFS\ISimpleFile; |
35 | 35 | |
36 | 36 | class NewSimpleFile implements ISimpleFile { |
37 | - private Folder $parentFolder; |
|
38 | - private string $name; |
|
39 | - private ?File $file = null; |
|
40 | - |
|
41 | - /** |
|
42 | - * File constructor. |
|
43 | - */ |
|
44 | - public function __construct(Folder $parentFolder, string $name) { |
|
45 | - $this->parentFolder = $parentFolder; |
|
46 | - $this->name = $name; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Get the name |
|
51 | - */ |
|
52 | - public function getName(): string { |
|
53 | - return $this->name; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Get the size in bytes |
|
58 | - */ |
|
59 | - public function getSize(): int|float { |
|
60 | - if ($this->file) { |
|
61 | - return $this->file->getSize(); |
|
62 | - } else { |
|
63 | - return 0; |
|
64 | - } |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Get the ETag |
|
69 | - */ |
|
70 | - public function getETag(): string { |
|
71 | - if ($this->file) { |
|
72 | - return $this->file->getEtag(); |
|
73 | - } else { |
|
74 | - return ''; |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Get the last modification time |
|
80 | - */ |
|
81 | - public function getMTime(): int { |
|
82 | - if ($this->file) { |
|
83 | - return $this->file->getMTime(); |
|
84 | - } else { |
|
85 | - return time(); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Get the content |
|
91 | - * |
|
92 | - * @throws NotFoundException |
|
93 | - * @throws NotPermittedException |
|
94 | - */ |
|
95 | - public function getContent(): string { |
|
96 | - if ($this->file) { |
|
97 | - $result = $this->file->getContent(); |
|
98 | - |
|
99 | - if ($result === false) { |
|
100 | - $this->checkFile(); |
|
101 | - } |
|
102 | - |
|
103 | - return $result; |
|
104 | - } else { |
|
105 | - return ''; |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Overwrite the file |
|
111 | - * |
|
112 | - * @param string|resource $data |
|
113 | - * @throws NotPermittedException |
|
114 | - * @throws NotFoundException |
|
115 | - */ |
|
116 | - public function putContent($data): void { |
|
117 | - try { |
|
118 | - if ($this->file) { |
|
119 | - $this->file->putContent($data); |
|
120 | - } else { |
|
121 | - $this->file = $this->parentFolder->newFile($this->name, $data); |
|
122 | - } |
|
123 | - } catch (NotFoundException $e) { |
|
124 | - $this->checkFile(); |
|
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Sometimes there are some issues with the AppData. Most of them are from |
|
130 | - * user error. But we should handle them gracefully anyway. |
|
131 | - * |
|
132 | - * If for some reason the current file can't be found. We remove it. |
|
133 | - * Then traverse up and check all folders if they exists. This so that the |
|
134 | - * next request will have a valid appdata structure again. |
|
135 | - * |
|
136 | - * @throws NotFoundException |
|
137 | - */ |
|
138 | - private function checkFile(): void { |
|
139 | - if (!$this->file) { |
|
140 | - throw new NotFoundException('File not set'); |
|
141 | - } |
|
142 | - |
|
143 | - $cur = $this->file; |
|
144 | - |
|
145 | - while ($cur->stat() === false) { |
|
146 | - $parent = $cur->getParent(); |
|
147 | - try { |
|
148 | - $cur->delete(); |
|
149 | - } catch (NotFoundException $e) { |
|
150 | - // Just continue then |
|
151 | - } |
|
152 | - $cur = $parent; |
|
153 | - } |
|
154 | - |
|
155 | - if ($cur !== $this->file) { |
|
156 | - throw new NotFoundException('File does not exist'); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Delete the file |
|
163 | - * |
|
164 | - * @throws NotPermittedException |
|
165 | - */ |
|
166 | - public function delete(): void { |
|
167 | - if ($this->file) { |
|
168 | - $this->file->delete(); |
|
169 | - } |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Get the MimeType |
|
174 | - * |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - public function getMimeType(): string { |
|
178 | - if ($this->file) { |
|
179 | - return $this->file->getMimeType(); |
|
180 | - } else { |
|
181 | - return 'text/plain'; |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * {@inheritDoc} |
|
187 | - */ |
|
188 | - public function getExtension(): string { |
|
189 | - if ($this->file) { |
|
190 | - return $this->file->getExtension(); |
|
191 | - } else { |
|
192 | - return \pathinfo($this->name, PATHINFO_EXTENSION); |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen |
|
198 | - * |
|
199 | - * @return resource|false |
|
200 | - * @throws \OCP\Files\NotPermittedException |
|
201 | - * @since 14.0.0 |
|
202 | - */ |
|
203 | - public function read() { |
|
204 | - if ($this->file) { |
|
205 | - return $this->file->fopen('r'); |
|
206 | - } else { |
|
207 | - return fopen('php://temp', 'r'); |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen |
|
213 | - * |
|
214 | - * @return resource|bool |
|
215 | - * @throws \OCP\Files\NotPermittedException |
|
216 | - * @since 14.0.0 |
|
217 | - */ |
|
218 | - public function write() { |
|
219 | - if ($this->file) { |
|
220 | - return $this->file->fopen('w'); |
|
221 | - } else { |
|
222 | - $source = fopen('php://temp', 'w+'); |
|
223 | - return CallbackWrapper::wrap($source, null, null, null, null, function () use ($source) { |
|
224 | - rewind($source); |
|
225 | - $this->putContent($source); |
|
226 | - }); |
|
227 | - } |
|
228 | - } |
|
37 | + private Folder $parentFolder; |
|
38 | + private string $name; |
|
39 | + private ?File $file = null; |
|
40 | + |
|
41 | + /** |
|
42 | + * File constructor. |
|
43 | + */ |
|
44 | + public function __construct(Folder $parentFolder, string $name) { |
|
45 | + $this->parentFolder = $parentFolder; |
|
46 | + $this->name = $name; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Get the name |
|
51 | + */ |
|
52 | + public function getName(): string { |
|
53 | + return $this->name; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Get the size in bytes |
|
58 | + */ |
|
59 | + public function getSize(): int|float { |
|
60 | + if ($this->file) { |
|
61 | + return $this->file->getSize(); |
|
62 | + } else { |
|
63 | + return 0; |
|
64 | + } |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Get the ETag |
|
69 | + */ |
|
70 | + public function getETag(): string { |
|
71 | + if ($this->file) { |
|
72 | + return $this->file->getEtag(); |
|
73 | + } else { |
|
74 | + return ''; |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Get the last modification time |
|
80 | + */ |
|
81 | + public function getMTime(): int { |
|
82 | + if ($this->file) { |
|
83 | + return $this->file->getMTime(); |
|
84 | + } else { |
|
85 | + return time(); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Get the content |
|
91 | + * |
|
92 | + * @throws NotFoundException |
|
93 | + * @throws NotPermittedException |
|
94 | + */ |
|
95 | + public function getContent(): string { |
|
96 | + if ($this->file) { |
|
97 | + $result = $this->file->getContent(); |
|
98 | + |
|
99 | + if ($result === false) { |
|
100 | + $this->checkFile(); |
|
101 | + } |
|
102 | + |
|
103 | + return $result; |
|
104 | + } else { |
|
105 | + return ''; |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Overwrite the file |
|
111 | + * |
|
112 | + * @param string|resource $data |
|
113 | + * @throws NotPermittedException |
|
114 | + * @throws NotFoundException |
|
115 | + */ |
|
116 | + public function putContent($data): void { |
|
117 | + try { |
|
118 | + if ($this->file) { |
|
119 | + $this->file->putContent($data); |
|
120 | + } else { |
|
121 | + $this->file = $this->parentFolder->newFile($this->name, $data); |
|
122 | + } |
|
123 | + } catch (NotFoundException $e) { |
|
124 | + $this->checkFile(); |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Sometimes there are some issues with the AppData. Most of them are from |
|
130 | + * user error. But we should handle them gracefully anyway. |
|
131 | + * |
|
132 | + * If for some reason the current file can't be found. We remove it. |
|
133 | + * Then traverse up and check all folders if they exists. This so that the |
|
134 | + * next request will have a valid appdata structure again. |
|
135 | + * |
|
136 | + * @throws NotFoundException |
|
137 | + */ |
|
138 | + private function checkFile(): void { |
|
139 | + if (!$this->file) { |
|
140 | + throw new NotFoundException('File not set'); |
|
141 | + } |
|
142 | + |
|
143 | + $cur = $this->file; |
|
144 | + |
|
145 | + while ($cur->stat() === false) { |
|
146 | + $parent = $cur->getParent(); |
|
147 | + try { |
|
148 | + $cur->delete(); |
|
149 | + } catch (NotFoundException $e) { |
|
150 | + // Just continue then |
|
151 | + } |
|
152 | + $cur = $parent; |
|
153 | + } |
|
154 | + |
|
155 | + if ($cur !== $this->file) { |
|
156 | + throw new NotFoundException('File does not exist'); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Delete the file |
|
163 | + * |
|
164 | + * @throws NotPermittedException |
|
165 | + */ |
|
166 | + public function delete(): void { |
|
167 | + if ($this->file) { |
|
168 | + $this->file->delete(); |
|
169 | + } |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Get the MimeType |
|
174 | + * |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + public function getMimeType(): string { |
|
178 | + if ($this->file) { |
|
179 | + return $this->file->getMimeType(); |
|
180 | + } else { |
|
181 | + return 'text/plain'; |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * {@inheritDoc} |
|
187 | + */ |
|
188 | + public function getExtension(): string { |
|
189 | + if ($this->file) { |
|
190 | + return $this->file->getExtension(); |
|
191 | + } else { |
|
192 | + return \pathinfo($this->name, PATHINFO_EXTENSION); |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen |
|
198 | + * |
|
199 | + * @return resource|false |
|
200 | + * @throws \OCP\Files\NotPermittedException |
|
201 | + * @since 14.0.0 |
|
202 | + */ |
|
203 | + public function read() { |
|
204 | + if ($this->file) { |
|
205 | + return $this->file->fopen('r'); |
|
206 | + } else { |
|
207 | + return fopen('php://temp', 'r'); |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen |
|
213 | + * |
|
214 | + * @return resource|bool |
|
215 | + * @throws \OCP\Files\NotPermittedException |
|
216 | + * @since 14.0.0 |
|
217 | + */ |
|
218 | + public function write() { |
|
219 | + if ($this->file) { |
|
220 | + return $this->file->fopen('w'); |
|
221 | + } else { |
|
222 | + $source = fopen('php://temp', 'w+'); |
|
223 | + return CallbackWrapper::wrap($source, null, null, null, null, function () use ($source) { |
|
224 | + rewind($source); |
|
225 | + $this->putContent($source); |
|
226 | + }); |
|
227 | + } |
|
228 | + } |
|
229 | 229 | } |
@@ -33,19 +33,19 @@ |
||
33 | 33 | * @template-extends QBMapper<TransferOwnership> |
34 | 34 | */ |
35 | 35 | class TransferOwnershipMapper extends QBMapper { |
36 | - public function __construct(IDBConnection $db) { |
|
37 | - parent::__construct($db, 'user_transfer_owner', TransferOwnership::class); |
|
38 | - } |
|
36 | + public function __construct(IDBConnection $db) { |
|
37 | + parent::__construct($db, 'user_transfer_owner', TransferOwnership::class); |
|
38 | + } |
|
39 | 39 | |
40 | - public function getById(int $id): TransferOwnership { |
|
41 | - $qb = $this->db->getQueryBuilder(); |
|
40 | + public function getById(int $id): TransferOwnership { |
|
41 | + $qb = $this->db->getQueryBuilder(); |
|
42 | 42 | |
43 | - $qb->select('*') |
|
44 | - ->from($this->getTableName()) |
|
45 | - ->where( |
|
46 | - $qb->expr()->eq('id', $qb->createNamedParameter($id)) |
|
47 | - ); |
|
43 | + $qb->select('*') |
|
44 | + ->from($this->getTableName()) |
|
45 | + ->where( |
|
46 | + $qb->expr()->eq('id', $qb->createNamedParameter($id)) |
|
47 | + ); |
|
48 | 48 | |
49 | - return $this->findEntity($qb); |
|
50 | - } |
|
49 | + return $this->findEntity($qb); |
|
50 | + } |
|
51 | 51 | } |
@@ -33,19 +33,19 @@ |
||
33 | 33 | * @template-extends QBMapper<ProfileConfig> |
34 | 34 | */ |
35 | 35 | class ProfileConfigMapper extends QBMapper { |
36 | - public function __construct(IDBConnection $db) { |
|
37 | - parent::__construct($db, 'profile_config', ProfileConfig::class); |
|
38 | - } |
|
36 | + public function __construct(IDBConnection $db) { |
|
37 | + parent::__construct($db, 'profile_config', ProfileConfig::class); |
|
38 | + } |
|
39 | 39 | |
40 | - public function get(string $userId): ProfileConfig { |
|
41 | - $qb = $this->db->getQueryBuilder(); |
|
42 | - $qb->select('*') |
|
43 | - ->from($this->getTableName()) |
|
44 | - ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); |
|
45 | - return $this->findEntity($qb); |
|
46 | - } |
|
40 | + public function get(string $userId): ProfileConfig { |
|
41 | + $qb = $this->db->getQueryBuilder(); |
|
42 | + $qb->select('*') |
|
43 | + ->from($this->getTableName()) |
|
44 | + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); |
|
45 | + return $this->findEntity($qb); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getArray(string $userId): array { |
|
49 | - return $this->get($userId)->getConfigArray(); |
|
50 | - } |
|
48 | + public function getArray(string $userId): array { |
|
49 | + return $this->get($userId)->getConfigArray(); |
|
50 | + } |
|
51 | 51 | } |
@@ -36,93 +36,93 @@ |
||
36 | 36 | * @template-extends QBMapper<AuthorizedGroup> |
37 | 37 | */ |
38 | 38 | class AuthorizedGroupMapper extends QBMapper { |
39 | - public function __construct(IDBConnection $db) { |
|
40 | - parent::__construct($db, 'authorized_groups', AuthorizedGroup::class); |
|
41 | - } |
|
39 | + public function __construct(IDBConnection $db) { |
|
40 | + parent::__construct($db, 'authorized_groups', AuthorizedGroup::class); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @throws Exception |
|
45 | - */ |
|
46 | - public function findAllClassesForUser(IUser $user): array { |
|
47 | - $qb = $this->db->getQueryBuilder(); |
|
43 | + /** |
|
44 | + * @throws Exception |
|
45 | + */ |
|
46 | + public function findAllClassesForUser(IUser $user): array { |
|
47 | + $qb = $this->db->getQueryBuilder(); |
|
48 | 48 | |
49 | - /** @var IGroupManager $groupManager */ |
|
50 | - $groupManager = \OC::$server->get(IGroupManager::class); |
|
51 | - $groups = $groupManager->getUserGroups($user); |
|
52 | - if (count($groups) === 0) { |
|
53 | - return []; |
|
54 | - } |
|
49 | + /** @var IGroupManager $groupManager */ |
|
50 | + $groupManager = \OC::$server->get(IGroupManager::class); |
|
51 | + $groups = $groupManager->getUserGroups($user); |
|
52 | + if (count($groups) === 0) { |
|
53 | + return []; |
|
54 | + } |
|
55 | 55 | |
56 | - $result = $qb->select('class') |
|
57 | - ->from($this->getTableName(), 'auth') |
|
58 | - ->where($qb->expr()->in('group_id', array_map(function (IGroup $group) use ($qb) { |
|
59 | - return $qb->createNamedParameter($group->getGID()); |
|
60 | - }, $groups), IQueryBuilder::PARAM_STR)) |
|
61 | - ->executeQuery(); |
|
56 | + $result = $qb->select('class') |
|
57 | + ->from($this->getTableName(), 'auth') |
|
58 | + ->where($qb->expr()->in('group_id', array_map(function (IGroup $group) use ($qb) { |
|
59 | + return $qb->createNamedParameter($group->getGID()); |
|
60 | + }, $groups), IQueryBuilder::PARAM_STR)) |
|
61 | + ->executeQuery(); |
|
62 | 62 | |
63 | - $classes = []; |
|
64 | - while ($row = $result->fetch()) { |
|
65 | - $classes[] = $row['class']; |
|
66 | - } |
|
67 | - $result->closeCursor(); |
|
68 | - return $classes; |
|
69 | - } |
|
63 | + $classes = []; |
|
64 | + while ($row = $result->fetch()) { |
|
65 | + $classes[] = $row['class']; |
|
66 | + } |
|
67 | + $result->closeCursor(); |
|
68 | + return $classes; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @throws \OCP\AppFramework\Db\DoesNotExistException |
|
73 | - * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
|
74 | - * @throws \OCP\DB\Exception |
|
75 | - */ |
|
76 | - public function find(int $id): AuthorizedGroup { |
|
77 | - $queryBuilder = $this->db->getQueryBuilder(); |
|
78 | - $queryBuilder->select('*') |
|
79 | - ->from($this->getTableName()) |
|
80 | - ->where($queryBuilder->expr()->eq('id', $queryBuilder->createNamedParameter($id))); |
|
81 | - /** @var AuthorizedGroup $authorizedGroup */ |
|
82 | - $authorizedGroup = $this->findEntity($queryBuilder); |
|
83 | - return $authorizedGroup; |
|
84 | - } |
|
71 | + /** |
|
72 | + * @throws \OCP\AppFramework\Db\DoesNotExistException |
|
73 | + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
|
74 | + * @throws \OCP\DB\Exception |
|
75 | + */ |
|
76 | + public function find(int $id): AuthorizedGroup { |
|
77 | + $queryBuilder = $this->db->getQueryBuilder(); |
|
78 | + $queryBuilder->select('*') |
|
79 | + ->from($this->getTableName()) |
|
80 | + ->where($queryBuilder->expr()->eq('id', $queryBuilder->createNamedParameter($id))); |
|
81 | + /** @var AuthorizedGroup $authorizedGroup */ |
|
82 | + $authorizedGroup = $this->findEntity($queryBuilder); |
|
83 | + return $authorizedGroup; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get all the authorizations stored in the database. |
|
88 | - * |
|
89 | - * @return AuthorizedGroup[] |
|
90 | - * @throws \OCP\DB\Exception |
|
91 | - */ |
|
92 | - public function findAll(): array { |
|
93 | - $qb = $this->db->getQueryBuilder(); |
|
94 | - $qb->select('*')->from($this->getTableName()); |
|
95 | - return $this->findEntities($qb); |
|
96 | - } |
|
86 | + /** |
|
87 | + * Get all the authorizations stored in the database. |
|
88 | + * |
|
89 | + * @return AuthorizedGroup[] |
|
90 | + * @throws \OCP\DB\Exception |
|
91 | + */ |
|
92 | + public function findAll(): array { |
|
93 | + $qb = $this->db->getQueryBuilder(); |
|
94 | + $qb->select('*')->from($this->getTableName()); |
|
95 | + return $this->findEntities($qb); |
|
96 | + } |
|
97 | 97 | |
98 | - public function findByGroupIdAndClass(string $groupId, string $class) { |
|
99 | - $qb = $this->db->getQueryBuilder(); |
|
100 | - $qb->select('*') |
|
101 | - ->from($this->getTableName()) |
|
102 | - ->where($qb->expr()->eq('group_id', $qb->createNamedParameter($groupId))) |
|
103 | - ->andWhere($qb->expr()->eq('class', $qb->createNamedParameter($class))); |
|
104 | - return $this->findEntity($qb); |
|
105 | - } |
|
98 | + public function findByGroupIdAndClass(string $groupId, string $class) { |
|
99 | + $qb = $this->db->getQueryBuilder(); |
|
100 | + $qb->select('*') |
|
101 | + ->from($this->getTableName()) |
|
102 | + ->where($qb->expr()->eq('group_id', $qb->createNamedParameter($groupId))) |
|
103 | + ->andWhere($qb->expr()->eq('class', $qb->createNamedParameter($class))); |
|
104 | + return $this->findEntity($qb); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @return Entity[] |
|
109 | - * @throws \OCP\DB\Exception |
|
110 | - */ |
|
111 | - public function findExistingGroupsForClass(string $class): array { |
|
112 | - $qb = $this->db->getQueryBuilder(); |
|
113 | - $qb->select('*') |
|
114 | - ->from($this->getTableName()) |
|
115 | - ->where($qb->expr()->eq('class', $qb->createNamedParameter($class))); |
|
116 | - return $this->findEntities($qb); |
|
117 | - } |
|
107 | + /** |
|
108 | + * @return Entity[] |
|
109 | + * @throws \OCP\DB\Exception |
|
110 | + */ |
|
111 | + public function findExistingGroupsForClass(string $class): array { |
|
112 | + $qb = $this->db->getQueryBuilder(); |
|
113 | + $qb->select('*') |
|
114 | + ->from($this->getTableName()) |
|
115 | + ->where($qb->expr()->eq('class', $qb->createNamedParameter($class))); |
|
116 | + return $this->findEntities($qb); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * @throws Exception |
|
121 | - */ |
|
122 | - public function removeGroup(string $gid) { |
|
123 | - $qb = $this->db->getQueryBuilder(); |
|
124 | - $qb->delete($this->getTableName()) |
|
125 | - ->where($qb->expr()->eq('group_id', $qb->createNamedParameter($gid))) |
|
126 | - ->executeStatement(); |
|
127 | - } |
|
119 | + /** |
|
120 | + * @throws Exception |
|
121 | + */ |
|
122 | + public function removeGroup(string $gid) { |
|
123 | + $qb = $this->db->getQueryBuilder(); |
|
124 | + $qb->delete($this->getTableName()) |
|
125 | + ->where($qb->expr()->eq('group_id', $qb->createNamedParameter($gid))) |
|
126 | + ->executeStatement(); |
|
127 | + } |
|
128 | 128 | } |
@@ -36,49 +36,49 @@ |
||
36 | 36 | * @template-extends QBMapper<Tag> |
37 | 37 | */ |
38 | 38 | class TagMapper extends QBMapper { |
39 | - /** |
|
40 | - * Constructor. |
|
41 | - * |
|
42 | - * @param IDBConnection $db Instance of the Db abstraction layer. |
|
43 | - */ |
|
44 | - public function __construct(IDBConnection $db) { |
|
45 | - parent::__construct($db, 'vcategory', Tag::class); |
|
46 | - } |
|
39 | + /** |
|
40 | + * Constructor. |
|
41 | + * |
|
42 | + * @param IDBConnection $db Instance of the Db abstraction layer. |
|
43 | + */ |
|
44 | + public function __construct(IDBConnection $db) { |
|
45 | + parent::__construct($db, 'vcategory', Tag::class); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Load tags from the database. |
|
50 | - * |
|
51 | - * @param array $owners The user(s) whose tags we are going to load. |
|
52 | - * @param string $type The type of item for which we are loading tags. |
|
53 | - * @return array An array of Tag objects. |
|
54 | - */ |
|
55 | - public function loadTags(array $owners, string $type): array { |
|
56 | - $qb = $this->db->getQueryBuilder(); |
|
57 | - $qb->select(['id', 'uid', 'type', 'category']) |
|
58 | - ->from($this->getTableName()) |
|
59 | - ->where($qb->expr()->in('uid', $qb->createNamedParameter($owners, IQueryBuilder::PARAM_STR_ARRAY))) |
|
60 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($type, IQueryBuilder::PARAM_STR))) |
|
61 | - ->orderBy('category'); |
|
62 | - return $this->findEntities($qb); |
|
63 | - } |
|
48 | + /** |
|
49 | + * Load tags from the database. |
|
50 | + * |
|
51 | + * @param array $owners The user(s) whose tags we are going to load. |
|
52 | + * @param string $type The type of item for which we are loading tags. |
|
53 | + * @return array An array of Tag objects. |
|
54 | + */ |
|
55 | + public function loadTags(array $owners, string $type): array { |
|
56 | + $qb = $this->db->getQueryBuilder(); |
|
57 | + $qb->select(['id', 'uid', 'type', 'category']) |
|
58 | + ->from($this->getTableName()) |
|
59 | + ->where($qb->expr()->in('uid', $qb->createNamedParameter($owners, IQueryBuilder::PARAM_STR_ARRAY))) |
|
60 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($type, IQueryBuilder::PARAM_STR))) |
|
61 | + ->orderBy('category'); |
|
62 | + return $this->findEntities($qb); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Check if a given Tag object already exists in the database. |
|
67 | - * |
|
68 | - * @param Tag $tag The tag to look for in the database. |
|
69 | - */ |
|
70 | - public function tagExists(Tag $tag): bool { |
|
71 | - $qb = $this->db->getQueryBuilder(); |
|
72 | - $qb->select(['id', 'uid', 'type', 'category']) |
|
73 | - ->from($this->getTableName()) |
|
74 | - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($tag->getOwner(), IQueryBuilder::PARAM_STR))) |
|
75 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($tag->getType(), IQueryBuilder::PARAM_STR))) |
|
76 | - ->andWhere($qb->expr()->eq('category', $qb->createNamedParameter($tag->getName(), IQueryBuilder::PARAM_STR))); |
|
77 | - try { |
|
78 | - $this->findEntity($qb); |
|
79 | - } catch (DoesNotExistException $e) { |
|
80 | - return false; |
|
81 | - } |
|
82 | - return true; |
|
83 | - } |
|
65 | + /** |
|
66 | + * Check if a given Tag object already exists in the database. |
|
67 | + * |
|
68 | + * @param Tag $tag The tag to look for in the database. |
|
69 | + */ |
|
70 | + public function tagExists(Tag $tag): bool { |
|
71 | + $qb = $this->db->getQueryBuilder(); |
|
72 | + $qb->select(['id', 'uid', 'type', 'category']) |
|
73 | + ->from($this->getTableName()) |
|
74 | + ->where($qb->expr()->eq('uid', $qb->createNamedParameter($tag->getOwner(), IQueryBuilder::PARAM_STR))) |
|
75 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($tag->getType(), IQueryBuilder::PARAM_STR))) |
|
76 | + ->andWhere($qb->expr()->eq('category', $qb->createNamedParameter($tag->getName(), IQueryBuilder::PARAM_STR))); |
|
77 | + try { |
|
78 | + $this->findEntity($qb); |
|
79 | + } catch (DoesNotExistException $e) { |
|
80 | + return false; |
|
81 | + } |
|
82 | + return true; |
|
83 | + } |
|
84 | 84 | } |
@@ -34,57 +34,57 @@ |
||
34 | 34 | * @template-extends QBMapper<KnownUser> |
35 | 35 | */ |
36 | 36 | class KnownUserMapper extends QBMapper { |
37 | - /** |
|
38 | - * @param IDBConnection $db |
|
39 | - */ |
|
40 | - public function __construct(IDBConnection $db) { |
|
41 | - parent::__construct($db, 'known_users', KnownUser::class); |
|
42 | - } |
|
37 | + /** |
|
38 | + * @param IDBConnection $db |
|
39 | + */ |
|
40 | + public function __construct(IDBConnection $db) { |
|
41 | + parent::__construct($db, 'known_users', KnownUser::class); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param string $knownTo |
|
46 | - * @return int Number of deleted entities |
|
47 | - */ |
|
48 | - public function deleteKnownTo(string $knownTo): int { |
|
49 | - $query = $this->db->getQueryBuilder(); |
|
50 | - $query->delete($this->getTableName()) |
|
51 | - ->where($query->expr()->eq('known_to', $query->createNamedParameter($knownTo))); |
|
44 | + /** |
|
45 | + * @param string $knownTo |
|
46 | + * @return int Number of deleted entities |
|
47 | + */ |
|
48 | + public function deleteKnownTo(string $knownTo): int { |
|
49 | + $query = $this->db->getQueryBuilder(); |
|
50 | + $query->delete($this->getTableName()) |
|
51 | + ->where($query->expr()->eq('known_to', $query->createNamedParameter($knownTo))); |
|
52 | 52 | |
53 | - return $query->executeStatement(); |
|
54 | - } |
|
53 | + return $query->executeStatement(); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $knownUser |
|
58 | - * @return int Number of deleted entities |
|
59 | - */ |
|
60 | - public function deleteKnownUser(string $knownUser): int { |
|
61 | - $query = $this->db->getQueryBuilder(); |
|
62 | - $query->delete($this->getTableName()) |
|
63 | - ->where($query->expr()->eq('known_user', $query->createNamedParameter($knownUser))); |
|
56 | + /** |
|
57 | + * @param string $knownUser |
|
58 | + * @return int Number of deleted entities |
|
59 | + */ |
|
60 | + public function deleteKnownUser(string $knownUser): int { |
|
61 | + $query = $this->db->getQueryBuilder(); |
|
62 | + $query->delete($this->getTableName()) |
|
63 | + ->where($query->expr()->eq('known_user', $query->createNamedParameter($knownUser))); |
|
64 | 64 | |
65 | - return $query->executeStatement(); |
|
66 | - } |
|
65 | + return $query->executeStatement(); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Returns all "known users" for the given "known to" user |
|
70 | - * |
|
71 | - * @param string $knownTo |
|
72 | - * @return KnownUser[] |
|
73 | - */ |
|
74 | - public function getKnownUsers(string $knownTo): array { |
|
75 | - $query = $this->db->getQueryBuilder(); |
|
76 | - $query->select('*') |
|
77 | - ->from($this->getTableName()) |
|
78 | - ->where($query->expr()->eq('known_to', $query->createNamedParameter($knownTo))); |
|
68 | + /** |
|
69 | + * Returns all "known users" for the given "known to" user |
|
70 | + * |
|
71 | + * @param string $knownTo |
|
72 | + * @return KnownUser[] |
|
73 | + */ |
|
74 | + public function getKnownUsers(string $knownTo): array { |
|
75 | + $query = $this->db->getQueryBuilder(); |
|
76 | + $query->select('*') |
|
77 | + ->from($this->getTableName()) |
|
78 | + ->where($query->expr()->eq('known_to', $query->createNamedParameter($knownTo))); |
|
79 | 79 | |
80 | - return $this->findEntities($query); |
|
81 | - } |
|
80 | + return $this->findEntities($query); |
|
81 | + } |
|
82 | 82 | |
83 | - public function createKnownUserFromRow(array $row): KnownUser { |
|
84 | - return $this->mapRowToEntity([ |
|
85 | - 'id' => $row['s_id'], |
|
86 | - 'known_to' => $row['known_to'], |
|
87 | - 'known_user' => $row['known_user'], |
|
88 | - ]); |
|
89 | - } |
|
83 | + public function createKnownUserFromRow(array $row): KnownUser { |
|
84 | + return $this->mapRowToEntity([ |
|
85 | + 'id' => $row['s_id'], |
|
86 | + 'known_to' => $row['known_to'], |
|
87 | + 'known_user' => $row['known_user'], |
|
88 | + ]); |
|
89 | + } |
|
90 | 90 | } |