@@ -84,7 +84,7 @@ |
||
| 84 | 84 | */ |
| 85 | 85 | private function isRequestPublic(RequestInterface $request) { |
| 86 | 86 | $url = $request->getPath(); |
| 87 | - $matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) { |
|
| 87 | + $matchingUrls = array_filter($this->publicURLs, function($publicUrl) use ($url) { |
|
| 88 | 88 | return strpos($url, $publicUrl, 0) === 0; |
| 89 | 89 | }); |
| 90 | 90 | return !empty($matchingUrls); |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | static function xmlDeserialize(Reader $reader) { |
| 48 | 48 | |
| 49 | 49 | $elements = $reader->parseInnerTree([ |
| 50 | - '{' . Plugin::NS_OWNCLOUD. '}set' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 51 | - '{' . Plugin::NS_OWNCLOUD . '}remove' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 50 | + '{'.Plugin::NS_OWNCLOUD.'}set' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 51 | + '{'.Plugin::NS_OWNCLOUD.'}remove' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 52 | 52 | ]); |
| 53 | 53 | |
| 54 | 54 | $set = []; |
@@ -57,21 +57,21 @@ discard block |
||
| 57 | 57 | foreach ($elements as $elem) { |
| 58 | 58 | switch ($elem['name']) { |
| 59 | 59 | |
| 60 | - case '{' . Plugin::NS_OWNCLOUD . '}set' : |
|
| 60 | + case '{'.Plugin::NS_OWNCLOUD.'}set' : |
|
| 61 | 61 | $sharee = $elem['value']; |
| 62 | 62 | |
| 63 | - $sumElem = '{' . Plugin::NS_OWNCLOUD . '}summary'; |
|
| 64 | - $commonName = '{' . Plugin::NS_OWNCLOUD . '}common-name'; |
|
| 63 | + $sumElem = '{'.Plugin::NS_OWNCLOUD.'}summary'; |
|
| 64 | + $commonName = '{'.Plugin::NS_OWNCLOUD.'}common-name'; |
|
| 65 | 65 | |
| 66 | 66 | $set[] = [ |
| 67 | 67 | 'href' => $sharee['{DAV:}href'], |
| 68 | 68 | 'commonName' => isset($sharee[$commonName]) ? $sharee[$commonName] : null, |
| 69 | 69 | 'summary' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null, |
| 70 | - 'readOnly' => !array_key_exists('{' . Plugin::NS_OWNCLOUD . '}read-write', $sharee), |
|
| 70 | + 'readOnly' => !array_key_exists('{'.Plugin::NS_OWNCLOUD.'}read-write', $sharee), |
|
| 71 | 71 | ]; |
| 72 | 72 | break; |
| 73 | 73 | |
| 74 | - case '{' . Plugin::NS_OWNCLOUD . '}remove' : |
|
| 74 | + case '{'.Plugin::NS_OWNCLOUD.'}remove' : |
|
| 75 | 75 | $remove[] = $elem['value']['{DAV:}href']; |
| 76 | 76 | break; |
| 77 | 77 | |
@@ -121,21 +121,21 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | function xmlSerialize(Writer $writer) { |
| 123 | 123 | |
| 124 | - $cs = '{' . Plugin::NS_OWNCLOUD . '}'; |
|
| 124 | + $cs = '{'.Plugin::NS_OWNCLOUD.'}'; |
|
| 125 | 125 | |
| 126 | 126 | if (!is_null($this->organizer)) { |
| 127 | 127 | |
| 128 | - $writer->startElement($cs . 'organizer'); |
|
| 128 | + $writer->startElement($cs.'organizer'); |
|
| 129 | 129 | $writer->writeElement('{DAV:}href', $this->organizer['href']); |
| 130 | 130 | |
| 131 | 131 | if (isset($this->organizer['commonName']) && $this->organizer['commonName']) { |
| 132 | - $writer->writeElement($cs . 'common-name', $this->organizer['commonName']); |
|
| 132 | + $writer->writeElement($cs.'common-name', $this->organizer['commonName']); |
|
| 133 | 133 | } |
| 134 | 134 | if (isset($this->organizer['firstName']) && $this->organizer['firstName']) { |
| 135 | - $writer->writeElement($cs . 'first-name', $this->organizer['firstName']); |
|
| 135 | + $writer->writeElement($cs.'first-name', $this->organizer['firstName']); |
|
| 136 | 136 | } |
| 137 | 137 | if (isset($this->organizer['lastName']) && $this->organizer['lastName']) { |
| 138 | - $writer->writeElement($cs . 'last-name', $this->organizer['lastName']); |
|
| 138 | + $writer->writeElement($cs.'last-name', $this->organizer['lastName']); |
|
| 139 | 139 | } |
| 140 | 140 | $writer->endElement(); // organizer |
| 141 | 141 | |
@@ -143,23 +143,23 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | foreach ($this->users as $user) { |
| 145 | 145 | |
| 146 | - $writer->startElement($cs . 'user'); |
|
| 146 | + $writer->startElement($cs.'user'); |
|
| 147 | 147 | $writer->writeElement('{DAV:}href', $user['href']); |
| 148 | 148 | if (isset($user['commonName']) && $user['commonName']) { |
| 149 | - $writer->writeElement($cs . 'common-name', $user['commonName']); |
|
| 149 | + $writer->writeElement($cs.'common-name', $user['commonName']); |
|
| 150 | 150 | } |
| 151 | - $writer->writeElement($cs . 'invite-accepted'); |
|
| 151 | + $writer->writeElement($cs.'invite-accepted'); |
|
| 152 | 152 | |
| 153 | - $writer->startElement($cs . 'access'); |
|
| 153 | + $writer->startElement($cs.'access'); |
|
| 154 | 154 | if ($user['readOnly']) { |
| 155 | - $writer->writeElement($cs . 'read'); |
|
| 155 | + $writer->writeElement($cs.'read'); |
|
| 156 | 156 | } else { |
| 157 | - $writer->writeElement($cs . 'read-write'); |
|
| 157 | + $writer->writeElement($cs.'read-write'); |
|
| 158 | 158 | } |
| 159 | 159 | $writer->endElement(); // access |
| 160 | 160 | |
| 161 | 161 | if (isset($user['summary']) && $user['summary']) { |
| 162 | - $writer->writeElement($cs . 'summary', $user['summary']); |
|
| 162 | + $writer->writeElement($cs.'summary', $user['summary']); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $writer->endElement(); //user |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | \Closure $childExistsFunction |
| 70 | 70 | ) { |
| 71 | 71 | $name = trim($name); |
| 72 | - if(empty($name) || !is_string($name)) { |
|
| 72 | + if (empty($name) || !is_string($name)) { |
|
| 73 | 73 | throw new \InvalidArgumentException('"name" parameter must be non-empty string'); |
| 74 | 74 | } |
| 75 | 75 | $this->name = $name; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @throws NotFound |
| 92 | 92 | */ |
| 93 | 93 | function getChild($name) { |
| 94 | - if(!$this->childExists($name)) { |
|
| 94 | + if (!$this->childExists($name)) { |
|
| 95 | 95 | throw new NotFound('Entity does not exist or is not available'); |
| 96 | 96 | } |
| 97 | 97 | return new EntityCollection( |
@@ -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; |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | * @throws NotAuthenticated |
| 87 | 87 | */ |
| 88 | 88 | protected function initCollections() { |
| 89 | - if($this->entityTypeCollections !== null) { |
|
| 89 | + if ($this->entityTypeCollections !== null) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | $user = $this->userSession->getUser(); |
| 93 | - if(is_null($user)) { |
|
| 93 | + if (is_null($user)) { |
|
| 94 | 94 | throw new NotAuthenticated(); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | function getChild($name) { |
| 146 | 146 | $this->initCollections(); |
| 147 | - if(isset($this->entityTypeCollections[$name])) { |
|
| 147 | + if (isset($this->entityTypeCollections[$name])) { |
|
| 148 | 148 | return $this->entityTypeCollections[$name]; |
| 149 | 149 | } |
| 150 | - throw new NotFound('Entity type "' . $name . '" not found."'); |
|
| 150 | + throw new NotFound('Entity type "'.$name.'" not found."'); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -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 | |
@@ -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]; |
@@ -100,13 +100,13 @@ |
||
| 100 | 100 | if ($this->shareManager->checkPassword($share, $password)) { |
| 101 | 101 | return true; |
| 102 | 102 | } else if ($this->session->exists('public_link_authenticated') |
| 103 | - && $this->session->get('public_link_authenticated') === (string)$share->getId()) { |
|
| 103 | + && $this->session->get('public_link_authenticated') === (string) $share->getId()) { |
|
| 104 | 104 | return true; |
| 105 | 105 | } else { |
| 106 | 106 | if (in_array('XMLHttpRequest', explode(',', $this->request->getHeader('X-Requested-With')))) { |
| 107 | 107 | // do not re-authenticate over ajax, use dummy auth name to prevent browser popup |
| 108 | 108 | http_response_code(401); |
| 109 | - header('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"'); |
|
| 109 | + header('WWW-Authenticate', 'DummyBasic realm="'.$this->realm.'"'); |
|
| 110 | 110 | throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls'); |
| 111 | 111 | } |
| 112 | 112 | return false; |