@@ -93,7 +93,7 @@ |
||
93 | 93 | /** |
94 | 94 | * returns a list of all possible property names |
95 | 95 | * |
96 | - * @return array |
|
96 | + * @return string[] |
|
97 | 97 | */ |
98 | 98 | static public function getPropertyNames() { |
99 | 99 | return [ |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | $this->logger = $logger; |
87 | 87 | |
88 | 88 | $methods = get_class_methods($this->comment); |
89 | - $methods = array_filter($methods, function($name){ |
|
89 | + $methods = array_filter($methods, function($name) { |
|
90 | 90 | return strpos($name, 'get') === 0; |
91 | 91 | }); |
92 | - foreach($methods as $getter) { |
|
93 | - if($getter === 'getMentions') { |
|
94 | - continue; // special treatment |
|
92 | + foreach ($methods as $getter) { |
|
93 | + if ($getter === 'getMentions') { |
|
94 | + continue; // special treatment |
|
95 | 95 | } |
96 | - $name = '{'.self::NS_OWNCLOUD.'}' . lcfirst(substr($getter, 3)); |
|
96 | + $name = '{'.self::NS_OWNCLOUD.'}'.lcfirst(substr($getter, 3)); |
|
97 | 97 | $this->properties[$name] = $getter; |
98 | 98 | } |
99 | 99 | $this->userManager = $userManager; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | protected function checkWriteAccessOnComment() { |
134 | 134 | $user = $this->userSession->getUser(); |
135 | - if( $this->comment->getActorType() !== 'users' |
|
135 | + if ($this->comment->getActorType() !== 'users' |
|
136 | 136 | || is_null($user) |
137 | 137 | || $this->comment->getActorId() !== $user->getUID() |
138 | 138 | ) { |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | return true; |
197 | 197 | } catch (\Exception $e) { |
198 | 198 | $this->logger->logException($e, ['app' => 'dav/comments']); |
199 | - if($e instanceof MessageTooLongException) { |
|
199 | + if ($e instanceof MessageTooLongException) { |
|
200 | 200 | $msg = 'Message exceeds allowed character limit of '; |
201 | - throw new BadRequest($msg . IComment::MAX_MESSAGE_LENGTH, 0, $e); |
|
201 | + throw new BadRequest($msg.IComment::MAX_MESSAGE_LENGTH, 0, $e); |
|
202 | 202 | } |
203 | 203 | throw $e; |
204 | 204 | } |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | $properties = array_keys($this->properties); |
241 | 241 | |
242 | 242 | $result = []; |
243 | - foreach($properties as $property) { |
|
243 | + foreach ($properties as $property) { |
|
244 | 244 | $getter = $this->properties[$property]; |
245 | - if(method_exists($this->comment, $getter)) { |
|
245 | + if (method_exists($this->comment, $getter)) { |
|
246 | 246 | $result[$property] = $this->comment->$getter(); |
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | - if($this->comment->getActorType() === 'users') { |
|
250 | + if ($this->comment->getActorType() === 'users') { |
|
251 | 251 | $user = $this->userManager->get($this->comment->getActorId()); |
252 | 252 | $displayName = is_null($user) ? null : $user->getDisplayName(); |
253 | 253 | $result[self::PROPERTY_NAME_ACTOR_DISPLAYNAME] = $displayName; |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | $result[self::PROPERTY_NAME_MENTIONS] = $this->composeMentionsPropertyValue(); |
257 | 257 | |
258 | 258 | $unread = null; |
259 | - $user = $this->userSession->getUser(); |
|
260 | - if(!is_null($user)) { |
|
259 | + $user = $this->userSession->getUser(); |
|
260 | + if (!is_null($user)) { |
|
261 | 261 | $readUntil = $this->commentsManager->getReadMark( |
262 | 262 | $this->comment->getObjectType(), |
263 | 263 | $this->comment->getObjectId(), |
264 | 264 | $user |
265 | 265 | ); |
266 | - if(is_null($readUntil)) { |
|
266 | + if (is_null($readUntil)) { |
|
267 | 267 | $unread = 'true'; |
268 | 268 | } else { |
269 | 269 | $unread = $this->comment->getCreationDateTime() > $readUntil; |
@@ -138,7 +138,7 @@ |
||
138 | 138 | * This will be used in the {DAV:}supported-report-set property. |
139 | 139 | * |
140 | 140 | * @param string $uri |
141 | - * @return array |
|
141 | + * @return string[] |
|
142 | 142 | */ |
143 | 143 | public function getSupportedReportSet($uri) { |
144 | 144 | return [self::REPORT_NAME]; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function initialize(Server $server) { |
86 | 86 | $this->server = $server; |
87 | - if(strpos($this->server->getRequestUri(), 'comments/') !== 0) { |
|
87 | + if (strpos($this->server->getRequestUri(), 'comments/') !== 0) { |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | // having their own comments marked as unread |
125 | 125 | $node->setReadMarker(null); |
126 | 126 | |
127 | - $url = rtrim($request->getUrl(), '/') . '/' . urlencode($comment->getId()); |
|
127 | + $url = rtrim($request->getUrl(), '/').'/'.urlencode($comment->getId()); |
|
128 | 128 | |
129 | 129 | $response->setHeader('Content-Location', $url); |
130 | 130 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function onReport($reportName, $report, $uri) { |
159 | 159 | $node = $this->server->tree->getNodeForPath($uri); |
160 | - if(!$node instanceof EntityCollection || $reportName !== self::REPORT_NAME) { |
|
160 | + if (!$node instanceof EntityCollection || $reportName !== self::REPORT_NAME) { |
|
161 | 161 | throw new ReportNotSupported(); |
162 | 162 | } |
163 | 163 | $args = ['limit' => 0, 'offset' => 0, 'datetime' => null]; |
@@ -166,27 +166,27 @@ discard block |
||
166 | 166 | $this::REPORT_PARAM_OFFSET, |
167 | 167 | $this::REPORT_PARAM_TIMESTAMP |
168 | 168 | ]; |
169 | - $ns = '{' . $this::NS_OWNCLOUD . '}'; |
|
170 | - foreach($report as $parameter) { |
|
171 | - if(!in_array($parameter['name'], $acceptableParameters) || empty($parameter['value'])) { |
|
169 | + $ns = '{'.$this::NS_OWNCLOUD.'}'; |
|
170 | + foreach ($report as $parameter) { |
|
171 | + if (!in_array($parameter['name'], $acceptableParameters) || empty($parameter['value'])) { |
|
172 | 172 | continue; |
173 | 173 | } |
174 | 174 | $args[str_replace($ns, '', $parameter['name'])] = $parameter['value']; |
175 | 175 | } |
176 | 176 | |
177 | - if(!is_null($args['datetime'])) { |
|
177 | + if (!is_null($args['datetime'])) { |
|
178 | 178 | $args['datetime'] = new \DateTime($args['datetime']); |
179 | 179 | } |
180 | 180 | |
181 | 181 | $results = $node->findChildren($args['limit'], $args['offset'], $args['datetime']); |
182 | 182 | |
183 | 183 | $responses = []; |
184 | - foreach($results as $node) { |
|
185 | - $nodePath = $this->server->getRequestUri() . '/' . $node->comment->getId(); |
|
184 | + foreach ($results as $node) { |
|
185 | + $nodePath = $this->server->getRequestUri().'/'.$node->comment->getId(); |
|
186 | 186 | $resultSet = $this->server->getPropertiesForPath($nodePath, CommentNode::getPropertyNames()); |
187 | - if(isset($resultSet[0]) && isset($resultSet[0][200])) { |
|
187 | + if (isset($resultSet[0]) && isset($resultSet[0][200])) { |
|
188 | 188 | $responses[] = new Response( |
189 | - $this->server->getBaseUri() . $nodePath, |
|
189 | + $this->server->getBaseUri().$nodePath, |
|
190 | 190 | [200 => $resultSet[0][200]], |
191 | 191 | 200 |
192 | 192 | ); |
@@ -227,14 +227,14 @@ discard block |
||
227 | 227 | |
228 | 228 | $actorType = $data['actorType']; |
229 | 229 | $actorId = null; |
230 | - if($actorType === 'users') { |
|
230 | + if ($actorType === 'users') { |
|
231 | 231 | $user = $this->userSession->getUser(); |
232 | - if(!is_null($user)) { |
|
232 | + if (!is_null($user)) { |
|
233 | 233 | $actorId = $user->getUID(); |
234 | 234 | } |
235 | 235 | } |
236 | - if(is_null($actorId)) { |
|
237 | - throw new BadRequest('Invalid actor "' . $actorType .'"'); |
|
236 | + if (is_null($actorId)) { |
|
237 | + throw new BadRequest('Invalid actor "'.$actorType.'"'); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | try { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | throw new BadRequest('Invalid input values', 0, $e); |
248 | 248 | } catch (\OCP\Comments\MessageTooLongException $e) { |
249 | 249 | $msg = 'Message exceeds allowed character limit of '; |
250 | - throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e); |
|
250 | + throw new BadRequest($msg.\OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 |
@@ -115,7 +115,7 @@ |
||
115 | 115 | /** |
116 | 116 | * Returns an array with all the child nodes |
117 | 117 | * |
118 | - * @return \Sabre\DAV\INode[] |
|
118 | + * @return CommentNode[] |
|
119 | 119 | */ |
120 | 120 | function getChildren() { |
121 | 121 | return $this->findChildren(); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @package OCA\DAV\Comments |
42 | 42 | */ |
43 | 43 | class EntityCollection extends RootCollection implements IProperties { |
44 | - const PROPERTY_NAME_READ_MARKER = '{http://owncloud.org/ns}readMarker'; |
|
44 | + const PROPERTY_NAME_READ_MARKER = '{http://owncloud.org/ns}readMarker'; |
|
45 | 45 | |
46 | 46 | /** @var string */ |
47 | 47 | protected $id; |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | IUserSession $userSession, |
66 | 66 | ILogger $logger |
67 | 67 | ) { |
68 | - foreach(['id', 'name'] as $property) { |
|
68 | + foreach (['id', 'name'] as $property) { |
|
69 | 69 | $$property = trim($$property); |
70 | - if(empty($$property) || !is_string($$property)) { |
|
71 | - throw new \InvalidArgumentException('"' . $property . '" parameter must be non-empty string'); |
|
70 | + if (empty($$property) || !is_string($$property)) { |
|
71 | + throw new \InvalidArgumentException('"'.$property.'" parameter must be non-empty string'); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | $this->id = $id; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | function findChildren($limit = 0, $offset = 0, \DateTime $datetime = null) { |
135 | 135 | $comments = $this->commentsManager->getForObject($this->name, $this->id, $limit, $offset, $datetime); |
136 | 136 | $result = []; |
137 | - foreach($comments as $comment) { |
|
137 | + foreach ($comments as $comment) { |
|
138 | 138 | $result[] = new CommentNode( |
139 | 139 | $this->commentsManager, |
140 | 140 | $comment, |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | function getProperties($properties) { |
188 | 188 | $marker = null; |
189 | 189 | $user = $this->userSession->getUser(); |
190 | - if(!is_null($user)) { |
|
190 | + if (!is_null($user)) { |
|
191 | 191 | $marker = $this->commentsManager->getReadMark($this->name, $this->id, $user); |
192 | 192 | } |
193 | 193 | return [self::PROPERTY_NAME_READ_MARKER => $marker]; |
@@ -75,7 +75,7 @@ |
||
75 | 75 | private $cache = []; |
76 | 76 | |
77 | 77 | /** |
78 | - * @param Tree $tree node tree |
|
78 | + * @param ObjectTree $tree node tree |
|
79 | 79 | * @param IDBConnection $connection database connection |
80 | 80 | * @param IUser $user owner of the tree and properties |
81 | 81 | */ |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // we catch the exception to prevent breaking the whole list with a 404 |
112 | 112 | // (soft fail) |
113 | 113 | \OC::$server->getLogger()->warning( |
114 | - 'Could not get node for path: \"' . $path . '\" : ' . $e->getMessage(), |
|
114 | + 'Could not get node for path: \"'.$path.'\" : '.$e->getMessage(), |
|
115 | 115 | array('app' => 'files') |
116 | 116 | ); |
117 | 117 | return; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $statement = $this->connection->prepare( |
171 | 171 | 'DELETE FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?' |
172 | 172 | ); |
173 | - $statement->execute(array($this->user, '/' . $path)); |
|
173 | + $statement->execute(array($this->user, '/'.$path)); |
|
174 | 174 | $statement->closeCursor(); |
175 | 175 | |
176 | 176 | unset($this->cache[$path]); |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function move($source, $destination) { |
188 | 188 | $statement = $this->connection->prepare( |
189 | - 'UPDATE `*PREFIX*properties` SET `propertypath` = ?' . |
|
189 | + 'UPDATE `*PREFIX*properties` SET `propertypath` = ?'. |
|
190 | 190 | ' WHERE `userid` = ? AND `propertypath` = ?' |
191 | 191 | ); |
192 | - $statement->execute(array('/' . $destination, $this->user, '/' . $source)); |
|
192 | + $statement->execute(array('/'.$destination, $this->user, '/'.$source)); |
|
193 | 193 | $statement->closeCursor(); |
194 | 194 | } |
195 | 195 | |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | private function updateProperties($node, $properties) { |
251 | 251 | $path = $node->getPath(); |
252 | 252 | |
253 | - $deleteStatement = 'DELETE FROM `*PREFIX*properties`' . |
|
253 | + $deleteStatement = 'DELETE FROM `*PREFIX*properties`'. |
|
254 | 254 | ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?'; |
255 | 255 | |
256 | - $insertStatement = 'INSERT INTO `*PREFIX*properties`' . |
|
256 | + $insertStatement = 'INSERT INTO `*PREFIX*properties`'. |
|
257 | 257 | ' (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)'; |
258 | 258 | |
259 | - $updateStatement = 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ?' . |
|
259 | + $updateStatement = 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ?'. |
|
260 | 260 | ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?'; |
261 | 261 | |
262 | 262 | // TODO: use "insert or update" strategy ? |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | $result = $this->connection->executeQuery( |
331 | 331 | $sql, |
332 | - array($this->user, $this->connection->escapeLikeParameter(rtrim($path, '/')) . '/%', $requestedProperties), |
|
332 | + array($this->user, $this->connection->escapeLikeParameter(rtrim($path, '/')).'/%', $requestedProperties), |
|
333 | 333 | array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY) |
334 | 334 | ); |
335 | 335 |
@@ -132,7 +132,7 @@ |
||
132 | 132 | * Returns the list of members for a group-principal |
133 | 133 | * |
134 | 134 | * @param string $principal |
135 | - * @return array |
|
135 | + * @return string[] |
|
136 | 136 | */ |
137 | 137 | function getGroupMemberSet($principal) { |
138 | 138 | // TODO: for now the group principal has only one member, the user itself |
@@ -163,7 +163,7 @@ |
||
163 | 163 | * @return array |
164 | 164 | */ |
165 | 165 | function getGroupMembership($principal) { |
166 | - list($prefix, ) = \Sabre\Uri\split($principal); |
|
166 | + list($prefix,) = \Sabre\Uri\split($principal); |
|
167 | 167 | |
168 | 168 | if ($prefix === 'principals/system') { |
169 | 169 | $principal = $this->getPrincipalByPath($principal); |
@@ -369,7 +369,7 @@ |
||
369 | 369 | * @param string $path path to the file which should be updated |
370 | 370 | * @param string $uid of the user who performs the operation |
371 | 371 | * @param array $accessList who has access to the file contains the key 'users' and 'public' |
372 | - * @return boolean |
|
372 | + * @return null|boolean |
|
373 | 373 | */ |
374 | 374 | public function update($path, $uid, array $accessList) { |
375 | 375 |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->isWriteOperation = false; |
178 | 178 | $this->writeCache = ''; |
179 | 179 | |
180 | - if($this->session->isReady() === false) { |
|
180 | + if ($this->session->isReady() === false) { |
|
181 | 181 | // if the master key is enabled we can initialize encryption |
182 | 182 | // with a empty password and user name |
183 | 183 | if ($this->util->isMasterKeyEnabled()) { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | // always use the version from the original file, also part files |
199 | 199 | // need to have a correct version number if they get moved over to the |
200 | 200 | // final location |
201 | - $this->version = (int)$this->keyManager->getVersion($this->stripPartFileExtension($path), new View()); |
|
201 | + $this->version = (int) $this->keyManager->getVersion($this->stripPartFileExtension($path), new View()); |
|
202 | 202 | |
203 | 203 | if ( |
204 | 204 | $mode === 'w' |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | // if we read a part file we need to increase the version by 1 |
215 | 215 | // because the version number was also increased by writing |
216 | 216 | // the part file |
217 | - if(Scanner::isPartialFile($path)) { |
|
217 | + if (Scanner::isPartialFile($path)) { |
|
218 | 218 | $this->version = $this->version + 1; |
219 | 219 | } |
220 | 220 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | if ($this->writeCache) { |
301 | 301 | |
302 | 302 | // Concat writeCache to start of $data |
303 | - $data = $this->writeCache . $data; |
|
303 | + $data = $this->writeCache.$data; |
|
304 | 304 | |
305 | 305 | // Clear the write cache, ready for reuse - it has been |
306 | 306 | // flushed and its old contents processed |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | try { |
403 | 403 | $publicKeys[$user] = $this->keyManager->getPublicKey($user); |
404 | 404 | } catch (PublicKeyMissingException $e) { |
405 | - $this->logger->warning('Could not encrypt file for ' . $user . ': ' . $e->getMessage()); |
|
405 | + $this->logger->warning('Could not encrypt file for '.$user.': '.$e->getMessage()); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | } |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | // error message because in this case it means that the file was |
490 | 490 | // shared with the user at a point where the user didn't had a |
491 | 491 | // valid private/public key |
492 | - $msg = 'Encryption module "' . $this->getDisplayName() . |
|
493 | - '" is not able to read ' . $path; |
|
492 | + $msg = 'Encryption module "'.$this->getDisplayName(). |
|
493 | + '" is not able to read '.$path; |
|
494 | 494 | $hint = $this->l->t('Can not read this file, probably this is a shared file. Please ask the file owner to reshare the file with you.'); |
495 | 495 | $this->logger->warning($msg); |
496 | 496 | throw new DecryptionFailedException($msg, $hint); |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | $realPath = $path; |
533 | 533 | $parts = explode('/', $path); |
534 | 534 | if ($parts[2] === 'files_versions') { |
535 | - $realPath = '/' . $parts[1] . '/files/' . implode('/', array_slice($parts, 3)); |
|
535 | + $realPath = '/'.$parts[1].'/files/'.implode('/', array_slice($parts, 3)); |
|
536 | 536 | $length = strrpos($realPath, '.'); |
537 | 537 | $realPath = substr($realPath, 0, $length); |
538 | 538 | } |
@@ -488,7 +488,7 @@ |
||
488 | 488 | |
489 | 489 | |
490 | 490 | /** |
491 | - * @param $path |
|
491 | + * @param string $path |
|
492 | 492 | * @param $uid |
493 | 493 | * @return mixed |
494 | 494 | */ |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $this->recoveryKeyId = $this->config->getAppValue('encryption', |
129 | 129 | 'recoveryKeyId'); |
130 | 130 | if (empty($this->recoveryKeyId)) { |
131 | - $this->recoveryKeyId = 'recoveryKey_' . substr(md5(time()), 0, 8); |
|
131 | + $this->recoveryKeyId = 'recoveryKey_'.substr(md5(time()), 0, 8); |
|
132 | 132 | $this->config->setAppValue('encryption', |
133 | 133 | 'recoveryKeyId', |
134 | 134 | $this->recoveryKeyId); |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | $this->publicShareKeyId = $this->config->getAppValue('encryption', |
138 | 138 | 'publicShareKeyId'); |
139 | 139 | if (empty($this->publicShareKeyId)) { |
140 | - $this->publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8); |
|
140 | + $this->publicShareKeyId = 'pubShare_'.substr(md5(time()), 0, 8); |
|
141 | 141 | $this->config->setAppValue('encryption', 'publicShareKeyId', $this->publicShareKeyId); |
142 | 142 | } |
143 | 143 | |
144 | 144 | $this->masterKeyId = $this->config->getAppValue('encryption', |
145 | 145 | 'masterKeyId'); |
146 | 146 | if (empty($this->masterKeyId)) { |
147 | - $this->masterKeyId = 'master_' . substr(md5(time()), 0, 8); |
|
147 | + $this->masterKeyId = 'master_'.substr(md5(time()), 0, 8); |
|
148 | 148 | $this->config->setAppValue('encryption', 'masterKeyId', $this->masterKeyId); |
149 | 149 | } |
150 | 150 | |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | |
163 | 163 | // Save public key |
164 | 164 | $this->keyStorage->setSystemUserKey( |
165 | - $this->publicShareKeyId . '.publicKey', $keyPair['publicKey'], |
|
165 | + $this->publicShareKeyId.'.publicKey', $keyPair['publicKey'], |
|
166 | 166 | Encryption::ID); |
167 | 167 | |
168 | 168 | // Encrypt private key empty passphrase |
169 | 169 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], ''); |
170 | 170 | $header = $this->crypt->generateHeader(); |
171 | - $this->setSystemPrivateKey($this->publicShareKeyId, $header . $encryptedKey); |
|
171 | + $this->setSystemPrivateKey($this->publicShareKeyId, $header.$encryptedKey); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | |
188 | 188 | // Save public key |
189 | 189 | $this->keyStorage->setSystemUserKey( |
190 | - $this->masterKeyId . '.publicKey', $keyPair['publicKey'], |
|
190 | + $this->masterKeyId.'.publicKey', $keyPair['publicKey'], |
|
191 | 191 | Encryption::ID); |
192 | 192 | |
193 | 193 | // Encrypt private key with system password |
194 | 194 | $encryptedKey = $this->crypt->encryptPrivateKey($keyPair['privateKey'], $this->getMasterKeyPassword(), $this->masterKeyId); |
195 | 195 | $header = $this->crypt->generateHeader(); |
196 | - $this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey); |
|
196 | + $this->setSystemPrivateKey($this->masterKeyId, $header.$encryptedKey); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if (!$this->session->isPrivateKeySet()) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return string |
221 | 221 | */ |
222 | 222 | public function getRecoveryKey() { |
223 | - return $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.publicKey', Encryption::ID); |
|
223 | + return $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.publicKey', Encryption::ID); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return bool |
238 | 238 | */ |
239 | 239 | public function checkRecoveryPassword($password) { |
240 | - $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId . '.privateKey', Encryption::ID); |
|
240 | + $recoveryKey = $this->keyStorage->getSystemUserKey($this->recoveryKeyId.'.privateKey', Encryption::ID); |
|
241 | 241 | $decryptedRecoveryKey = $this->crypt->decryptPrivateKey($recoveryKey, $password); |
242 | 242 | |
243 | 243 | if ($decryptedRecoveryKey) { |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $header = $this->crypt->generateHeader(); |
262 | 262 | |
263 | 263 | if ($encryptedKey) { |
264 | - $this->setPrivateKey($uid, $header . $encryptedKey); |
|
264 | + $this->setPrivateKey($uid, $header.$encryptedKey); |
|
265 | 265 | return true; |
266 | 266 | } |
267 | 267 | return false; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $header = $this->crypt->generateHeader(); |
284 | 284 | |
285 | 285 | if ($encryptedKey) { |
286 | - $this->setSystemPrivateKey($this->getRecoveryKeyId(), $header . $encryptedKey); |
|
286 | + $this->setSystemPrivateKey($this->getRecoveryKeyId(), $header.$encryptedKey); |
|
287 | 287 | return true; |
288 | 288 | } |
289 | 289 | return false; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @return boolean |
344 | 344 | */ |
345 | 345 | public function setShareKey($path, $uid, $key) { |
346 | - $keyId = $uid . '.' . $this->shareKeyId; |
|
346 | + $keyId = $uid.'.'.$this->shareKeyId; |
|
347 | 347 | return $this->keyStorage->setFileKey($path, $keyId, $key, Encryption::ID); |
348 | 348 | } |
349 | 349 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $this->session->setStatus(Session::INIT_EXECUTED); |
360 | 360 | |
361 | 361 | try { |
362 | - if($this->util->isMasterKeyEnabled()) { |
|
362 | + if ($this->util->isMasterKeyEnabled()) { |
|
363 | 363 | $uid = $this->getMasterKeyId(); |
364 | 364 | $passPhrase = $this->getMasterKeyPassword(); |
365 | 365 | $privateKey = $this->getSystemPrivateKey($uid); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | return false; |
374 | 374 | } catch (\Exception $e) { |
375 | 375 | $this->log->logException($e, [ |
376 | - 'message' => 'Could not decrypt the private key from user "' . $uid . '"" during login. Assume password change on the user back-end.', |
|
376 | + 'message' => 'Could not decrypt the private key from user "'.$uid.'"" during login. Assume password change on the user back-end.', |
|
377 | 377 | 'level' => ILogger::WARN, |
378 | 378 | 'app' => 'encryption', |
379 | 379 | ]); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | // use public share key for public links |
435 | 435 | $uid = $this->getPublicShareKeyId(); |
436 | 436 | $shareKey = $this->getShareKey($path, $uid); |
437 | - $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.privateKey', Encryption::ID); |
|
437 | + $privateKey = $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.privateKey', Encryption::ID); |
|
438 | 438 | $privateKey = $this->crypt->decryptPrivateKey($privateKey); |
439 | 439 | } else { |
440 | 440 | $shareKey = $this->getShareKey($path, $uid); |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function getVersion($path, View $view) { |
461 | 461 | $fileInfo = $view->getFileInfo($path); |
462 | - if($fileInfo === false) { |
|
462 | + if ($fileInfo === false) { |
|
463 | 463 | return 0; |
464 | 464 | } |
465 | 465 | return $fileInfo->getEncryptedVersion(); |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | * @param View $view |
474 | 474 | */ |
475 | 475 | public function setVersion($path, $version, View $view) { |
476 | - $fileInfo= $view->getFileInfo($path); |
|
476 | + $fileInfo = $view->getFileInfo($path); |
|
477 | 477 | |
478 | - if($fileInfo !== false) { |
|
478 | + if ($fileInfo !== false) { |
|
479 | 479 | $cache = $fileInfo->getStorage()->getCache(); |
480 | 480 | $cache->update($fileInfo->getId(), ['encrypted' => $version, 'encryptedVersion' => $version]); |
481 | 481 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | public function deleteShareKey($path, $keyId) { |
505 | 505 | return $this->keyStorage->deleteFileKey( |
506 | 506 | $path, |
507 | - $keyId . '.' . $this->shareKeyId, |
|
507 | + $keyId.'.'.$this->shareKeyId, |
|
508 | 508 | Encryption::ID); |
509 | 509 | } |
510 | 510 | |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @return mixed |
516 | 516 | */ |
517 | 517 | public function getShareKey($path, $uid) { |
518 | - $keyId = $uid . '.' . $this->shareKeyId; |
|
518 | + $keyId = $uid.'.'.$this->shareKeyId; |
|
519 | 519 | return $this->keyStorage->getFileKey($path, $keyId, Encryption::ID); |
520 | 520 | } |
521 | 521 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @return string |
578 | 578 | */ |
579 | 579 | public function getPublicShareKey() { |
580 | - return $this->keyStorage->getSystemUserKey($this->publicShareKeyId . '.publicKey', Encryption::ID); |
|
580 | + return $this->keyStorage->getSystemUserKey($this->publicShareKeyId.'.publicKey', Encryption::ID); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | * @return string returns openssl key |
648 | 648 | */ |
649 | 649 | public function getSystemPrivateKey($keyId) { |
650 | - return $this->keyStorage->getSystemUserKey($keyId . '.' . $this->privateKeyId, Encryption::ID); |
|
650 | + return $this->keyStorage->getSystemUserKey($keyId.'.'.$this->privateKeyId, Encryption::ID); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /** |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function setSystemPrivateKey($keyId, $key) { |
659 | 659 | return $this->keyStorage->setSystemUserKey( |
660 | - $keyId . '.' . $this->privateKeyId, |
|
660 | + $keyId.'.'.$this->privateKeyId, |
|
661 | 661 | $key, |
662 | 662 | Encryption::ID); |
663 | 663 | } |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | */ |
698 | 698 | public function getMasterKeyPassword() { |
699 | 699 | $password = $this->config->getSystemValue('secret'); |
700 | - if (empty($password)){ |
|
700 | + if (empty($password)) { |
|
701 | 701 | throw new \Exception('Can not get secret from Nextcloud instance'); |
702 | 702 | } |
703 | 703 | |
@@ -719,6 +719,6 @@ discard block |
||
719 | 719 | * @return string |
720 | 720 | */ |
721 | 721 | public function getPublicMasterKey() { |
722 | - return $this->keyStorage->getSystemUserKey($this->masterKeyId . '.publicKey', Encryption::ID); |
|
722 | + return $this->keyStorage->getSystemUserKey($this->masterKeyId.'.publicKey', Encryption::ID); |
|
723 | 723 | } |
724 | 724 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | /** |
392 | 392 | * store remote ID in federated reShare table |
393 | 393 | * |
394 | - * @param $shareId |
|
394 | + * @param integer $shareId |
|
395 | 395 | * @param $remoteId |
396 | 396 | */ |
397 | 397 | public function storeRemoteId($shareId, $remoteId) { |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | /** |
730 | 730 | * get database row of a give share |
731 | 731 | * |
732 | - * @param $id |
|
732 | + * @param integer $id |
|
733 | 733 | * @return array |
734 | 734 | * @throws ShareNotFound |
735 | 735 | */ |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($remoteShare) { |
193 | 193 | try { |
194 | 194 | $ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']); |
195 | - $shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time()); |
|
195 | + $shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_'.time()); |
|
196 | 196 | $share->setId($shareId); |
197 | 197 | list($token, $remoteId) = $this->askOwnerToReShare($shareWith, $share, $shareId); |
198 | 198 | // remote share was create successfully if we get a valid token as return |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $failure = true; |
273 | 273 | } |
274 | 274 | |
275 | - if($failure) { |
|
275 | + if ($failure) { |
|
276 | 276 | $this->removeShareFromTableById($shareId); |
277 | 277 | $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable or uses a self-signed certificate.', |
278 | 278 | [$share->getNode()->getName(), $share->getSharedWith()]); |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | ->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget()))); |
325 | 325 | $result = $query->execute()->fetchAll(); |
326 | 326 | |
327 | - if (isset($result[0]) && (int)$result[0]['remote_id'] > 0) { |
|
327 | + if (isset($result[0]) && (int) $result[0]['remote_id'] > 0) { |
|
328 | 328 | return $result[0]; |
329 | 329 | } |
330 | 330 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $qb->execute(); |
367 | 367 | $id = $qb->getLastInsertId(); |
368 | 368 | |
369 | - return (int)$id; |
|
369 | + return (int) $id; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | public function getRemoteId(IShare $share) { |
457 | 457 | $query = $this->dbConnection->getQueryBuilder(); |
458 | 458 | $query->select('remote_id')->from('federated_reshares') |
459 | - ->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId()))); |
|
459 | + ->where($query->expr()->eq('share_id', $query->createNamedParameter((int) $share->getId()))); |
|
460 | 460 | $data = $query->execute()->fetch(); |
461 | 461 | |
462 | 462 | if (!is_array($data) || !isset($data['remote_id'])) { |
463 | 463 | throw new ShareNotFound(); |
464 | 464 | } |
465 | 465 | |
466 | - return (int)$data['remote_id']; |
|
466 | + return (int) $data['remote_id']; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | ->orderBy('id'); |
495 | 495 | |
496 | 496 | $cursor = $qb->execute(); |
497 | - while($data = $cursor->fetch()) { |
|
497 | + while ($data = $cursor->fetch()) { |
|
498 | 498 | $children[] = $this->createShareObject($data); |
499 | 499 | } |
500 | 500 | $cursor->closeCursor(); |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | ); |
613 | 613 | } |
614 | 614 | |
615 | - $qb->innerJoin('s', 'filecache' ,'f', $qb->expr()->eq('s.file_source', 'f.fileid')); |
|
615 | + $qb->innerJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')); |
|
616 | 616 | $qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId()))); |
617 | 617 | |
618 | 618 | $qb->orderBy('id'); |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | |
676 | 676 | $cursor = $qb->execute(); |
677 | 677 | $shares = []; |
678 | - while($data = $cursor->fetch()) { |
|
678 | + while ($data = $cursor->fetch()) { |
|
679 | 679 | $shares[] = $this->createShareObject($data); |
680 | 680 | } |
681 | 681 | $cursor->closeCursor(); |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | $cursor->closeCursor(); |
700 | 700 | |
701 | 701 | if ($data === false) { |
702 | - throw new ShareNotFound('Can not find share with ID: ' . $id); |
|
702 | + throw new ShareNotFound('Can not find share with ID: '.$id); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | try { |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | ->execute(); |
728 | 728 | |
729 | 729 | $shares = []; |
730 | - while($data = $cursor->fetch()) { |
|
730 | + while ($data = $cursor->fetch()) { |
|
731 | 731 | $shares[] = $this->createShareObject($data); |
732 | 732 | } |
733 | 733 | $cursor->closeCursor(); |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | |
767 | 767 | $cursor = $qb->execute(); |
768 | 768 | |
769 | - while($data = $cursor->fetch()) { |
|
769 | + while ($data = $cursor->fetch()) { |
|
770 | 770 | $shares[] = $this->createShareObject($data); |
771 | 771 | } |
772 | 772 | $cursor->closeCursor(); |
@@ -843,15 +843,15 @@ discard block |
||
843 | 843 | private function createShareObject($data) { |
844 | 844 | |
845 | 845 | $share = new Share($this->rootFolder, $this->userManager); |
846 | - $share->setId((int)$data['id']) |
|
847 | - ->setShareType((int)$data['share_type']) |
|
848 | - ->setPermissions((int)$data['permissions']) |
|
846 | + $share->setId((int) $data['id']) |
|
847 | + ->setShareType((int) $data['share_type']) |
|
848 | + ->setPermissions((int) $data['permissions']) |
|
849 | 849 | ->setTarget($data['file_target']) |
850 | - ->setMailSend((bool)$data['mail_send']) |
|
850 | + ->setMailSend((bool) $data['mail_send']) |
|
851 | 851 | ->setToken($data['token']); |
852 | 852 | |
853 | 853 | $shareTime = new \DateTime(); |
854 | - $shareTime->setTimestamp((int)$data['stime']); |
|
854 | + $shareTime->setTimestamp((int) $data['stime']); |
|
855 | 855 | $share->setShareTime($shareTime); |
856 | 856 | $share->setSharedWith($data['share_with']); |
857 | 857 | |
@@ -861,13 +861,13 @@ discard block |
||
861 | 861 | } else { |
862 | 862 | //OLD SHARE |
863 | 863 | $share->setSharedBy($data['uid_owner']); |
864 | - $path = $this->getNode($share->getSharedBy(), (int)$data['file_source']); |
|
864 | + $path = $this->getNode($share->getSharedBy(), (int) $data['file_source']); |
|
865 | 865 | |
866 | 866 | $owner = $path->getOwner(); |
867 | 867 | $share->setShareOwner($owner->getUID()); |
868 | 868 | } |
869 | 869 | |
870 | - $share->setNodeId((int)$data['file_source']); |
|
870 | + $share->setNodeId((int) $data['file_source']); |
|
871 | 871 | $share->setNodeType($data['item_type']); |
872 | 872 | |
873 | 873 | $share->setProviderId($this->identifier()); |
@@ -110,7 +110,7 @@ |
||
110 | 110 | * check if it is a file located in data/user/files only files in the |
111 | 111 | * 'files' directory should be moved to the trash |
112 | 112 | * |
113 | - * @param $path |
|
113 | + * @param string $path |
|
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | protected function shouldMoveToTrash($path){ |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | if ($currentUser) { |
115 | 115 | $currentUserId = $currentUser->getUID(); |
116 | 116 | |
117 | - $view = new View($currentUserId . '/files'); |
|
117 | + $view = new View($currentUserId.'/files'); |
|
118 | 118 | $fileInfo = $view->getFileInfo($oldPath); |
119 | 119 | if ($fileInfo) { |
120 | 120 | $sourceStorage = $fileInfo->getStorage(); |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | ]); |
138 | 138 | } |
139 | 139 | |
140 | - if($fileMovedOutOfSharedFolder) { |
|
141 | - self::$moveOutOfSharedFolder['/' . $currentUserId . '/files' . $oldPath] = true; |
|
140 | + if ($fileMovedOutOfSharedFolder) { |
|
141 | + self::$moveOutOfSharedFolder['/'.$currentUserId.'/files'.$oldPath] = true; |
|
142 | 142 | } else { |
143 | 143 | self::$disableTrash = true; |
144 | 144 | } |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function unlink($path) { |
180 | 180 | try { |
181 | - if (isset(self::$moveOutOfSharedFolder[$this->mountPoint . $path])) { |
|
181 | + if (isset(self::$moveOutOfSharedFolder[$this->mountPoint.$path])) { |
|
182 | 182 | $result = $this->doDelete($path, 'unlink', true); |
183 | - unset(self::$moveOutOfSharedFolder[$this->mountPoint . $path]); |
|
183 | + unset(self::$moveOutOfSharedFolder[$this->mountPoint.$path]); |
|
184 | 184 | } else { |
185 | 185 | $result = $this->doDelete($path, 'unlink'); |
186 | 186 | } |
187 | 187 | } catch (GenericEncryptionException $e) { |
188 | 188 | // in case of a encryption exception we delete the file right away |
189 | 189 | $this->logger->info( |
190 | - "Can't move file" . $path . |
|
190 | + "Can't move file".$path. |
|
191 | 191 | "to the trash bin, therefore it was deleted right away"); |
192 | 192 | |
193 | 193 | $result = $this->storage->unlink($path); |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | * @return bool true if the operation succeeded, false otherwise |
205 | 205 | */ |
206 | 206 | public function rmdir($path) { |
207 | - if (isset(self::$moveOutOfSharedFolder[$this->mountPoint . $path])) { |
|
207 | + if (isset(self::$moveOutOfSharedFolder[$this->mountPoint.$path])) { |
|
208 | 208 | $result = $this->doDelete($path, 'rmdir', true); |
209 | - unset(self::$moveOutOfSharedFolder[$this->mountPoint . $path]); |
|
209 | + unset(self::$moveOutOfSharedFolder[$this->mountPoint.$path]); |
|
210 | 210 | } else { |
211 | 211 | $result = $this->doDelete($path, 'rmdir'); |
212 | 212 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param $path |
222 | 222 | * @return bool |
223 | 223 | */ |
224 | - protected function shouldMoveToTrash($path){ |
|
224 | + protected function shouldMoveToTrash($path) { |
|
225 | 225 | |
226 | 226 | // check if there is a app which want to disable the trash bin for this file |
227 | 227 | $fileId = $this->storage->getCache()->getId($path); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | - $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path); |
|
237 | + $normalized = Filesystem::normalizePath($this->mountPoint.'/'.$path); |
|
238 | 238 | $parts = explode('/', $normalized); |
239 | 239 | if (count($parts) < 4) { |
240 | 240 | return false; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
285 | - $normalized = Filesystem::normalizePath($this->mountPoint . '/' . $path, true, false, true); |
|
285 | + $normalized = Filesystem::normalizePath($this->mountPoint.'/'.$path, true, false, true); |
|
286 | 286 | $result = true; |
287 | 287 | $view = Filesystem::getView(); |
288 | 288 | if (!isset($this->deletedFiles[$normalized]) && $view instanceof View) { |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * Setup the storate wrapper callback |
311 | 311 | */ |
312 | 312 | public static function setupStorage() { |
313 | - \OC\Files\Filesystem::addStorageWrapper('oc_trashbin', function ($mountPoint, $storage) { |
|
313 | + \OC\Files\Filesystem::addStorageWrapper('oc_trashbin', function($mountPoint, $storage) { |
|
314 | 314 | return new \OCA\Files_Trashbin\Storage( |
315 | 315 | array('storage' => $storage, 'mountPoint' => $mountPoint), |
316 | 316 | \OC::$server->getUserManager(), |