@@ -323,7 +323,7 @@ |
||
| 323 | 323 | /** |
| 324 | 324 | * find all available languages for an app |
| 325 | 325 | * @param string $app App that needs to be translated |
| 326 | - * @return array an array of available languages |
|
| 326 | + * @return string[] an array of available languages |
|
| 327 | 327 | * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->findAvailableLanguages() instead |
| 328 | 328 | */ |
| 329 | 329 | public static function findAvailableLanguages($app=null) { |
@@ -167,12 +167,12 @@ discard block |
||
| 167 | 167 | public function n($text_singular, $text_plural, $count, $parameters = array()) { |
| 168 | 168 | $this->init(); |
| 169 | 169 | $identifier = "_${text_singular}_::_${text_plural}_"; |
| 170 | - if( array_key_exists($identifier, $this->translations)) { |
|
| 171 | - return new OC_L10N_String( $this, $identifier, $parameters, $count ); |
|
| 172 | - }else{ |
|
| 173 | - if($count === 1) { |
|
| 170 | + if (array_key_exists($identifier, $this->translations)) { |
|
| 171 | + return new OC_L10N_String($this, $identifier, $parameters, $count); |
|
| 172 | + } else { |
|
| 173 | + if ($count === 1) { |
|
| 174 | 174 | return new OC_L10N_String($this, $text_singular, $parameters, $count); |
| 175 | - }else{ |
|
| 175 | + } else { |
|
| 176 | 176 | return new OC_L10N_String($this, $text_plural, $parameters, $count); |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | $this->init(); |
| 237 | 237 | $value = new DateTime(); |
| 238 | - if($data instanceof DateTime) { |
|
| 238 | + if ($data instanceof DateTime) { |
|
| 239 | 239 | $value = $data; |
| 240 | - } elseif(is_string($data) && !is_numeric($data)) { |
|
| 240 | + } elseif (is_string($data) && !is_numeric($data)) { |
|
| 241 | 241 | $data = strtotime($data); |
| 242 | 242 | $value->setTimestamp($data); |
| 243 | 243 | } else { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | $options = array_merge(array('width' => 'long'), $options); |
| 251 | 251 | $width = $options['width']; |
| 252 | - switch($type) { |
|
| 252 | + switch ($type) { |
|
| 253 | 253 | case 'date': |
| 254 | 254 | return Punic\Calendar::formatDate($value, $width, $locale); |
| 255 | 255 | case 'datetime': |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * @return array an array of available languages |
| 328 | 328 | * @deprecated 9.0.0 Use \OC::$server->getL10NFactory()->findAvailableLanguages() instead |
| 329 | 329 | */ |
| 330 | - public static function findAvailableLanguages($app=null) { |
|
| 330 | + public static function findAvailableLanguages($app = null) { |
|
| 331 | 331 | return \OC::$server->getL10NFactory()->findAvailableLanguages($app); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -289,6 +289,9 @@ discard block |
||
| 289 | 289 | return $calendar; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | + /** |
|
| 293 | + * @param integer $calendarId |
|
| 294 | + */ |
|
| 292 | 295 | public function getCalendarById($calendarId) { |
| 293 | 296 | $fields = array_values($this->propertyMap); |
| 294 | 297 | $fields[] = 'id'; |
@@ -597,7 +600,7 @@ discard block |
||
| 597 | 600 | * calendar-data. If the result of a subsequent GET to this object is not |
| 598 | 601 | * the exact same as this request body, you should omit the ETag. |
| 599 | 602 | * |
| 600 | - * @param mixed $calendarId |
|
| 603 | + * @param integer $calendarId |
|
| 601 | 604 | * @param string $objectUri |
| 602 | 605 | * @param string $calendarData |
| 603 | 606 | * @return string |
@@ -1036,7 +1039,7 @@ discard block |
||
| 1036 | 1039 | * @param string $principalUri |
| 1037 | 1040 | * @param string $uri |
| 1038 | 1041 | * @param array $properties |
| 1039 | - * @return mixed |
|
| 1042 | + * @return integer |
|
| 1040 | 1043 | */ |
| 1041 | 1044 | function createSubscription($principalUri, $uri, array $properties) { |
| 1042 | 1045 | |
@@ -1377,6 +1380,9 @@ discard block |
||
| 1377 | 1380 | return $this->sharingBackend->applyShareAcl($resourceId, $acl); |
| 1378 | 1381 | } |
| 1379 | 1382 | |
| 1383 | + /** |
|
| 1384 | + * @param boolean $toV2 |
|
| 1385 | + */ |
|
| 1380 | 1386 | private function convertPrincipal($principalUri, $toV2) { |
| 1381 | 1387 | if ($this->principalBackend->getPrincipalPrefix() === 'principals') { |
| 1382 | 1388 | list(, $name) = URLUtil::splitPath($principalUri); |
@@ -157,24 +157,24 @@ discard block |
||
| 157 | 157 | $stmt = $query->execute(); |
| 158 | 158 | |
| 159 | 159 | $calendars = []; |
| 160 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 160 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 161 | 161 | |
| 162 | 162 | $components = []; |
| 163 | 163 | if ($row['components']) { |
| 164 | - $components = explode(',',$row['components']); |
|
| 164 | + $components = explode(',', $row['components']); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $calendar = [ |
| 168 | 168 | 'id' => $row['id'], |
| 169 | 169 | 'uri' => $row['uri'], |
| 170 | 170 | 'principaluri' => $this->convertPrincipal($row['principaluri'], false), |
| 171 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 172 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 173 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 174 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 171 | + '{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'), |
|
| 172 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 173 | + '{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 174 | + '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), |
|
| 175 | 175 | ]; |
| 176 | 176 | |
| 177 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 177 | + foreach ($this->propertyMap as $xmlName=>$dbName) { |
|
| 178 | 178 | $calendar[$xmlName] = $row[$dbName]; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // query for shared calendars |
| 189 | 189 | $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true); |
| 190 | - $principals[]= $principalUri; |
|
| 190 | + $principals[] = $principalUri; |
|
| 191 | 191 | |
| 192 | 192 | $fields = array_values($this->propertyMap); |
| 193 | 193 | $fields[] = 'a.id'; |
@@ -207,27 +207,27 @@ discard block |
||
| 207 | 207 | ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY) |
| 208 | 208 | ->execute(); |
| 209 | 209 | |
| 210 | - while($row = $result->fetch()) { |
|
| 210 | + while ($row = $result->fetch()) { |
|
| 211 | 211 | list(, $name) = URLUtil::splitPath($row['principaluri']); |
| 212 | - $uri = $row['uri'] . '_shared_by_' . $name; |
|
| 213 | - $row['displayname'] = $row['displayname'] . "($name)"; |
|
| 212 | + $uri = $row['uri'].'_shared_by_'.$name; |
|
| 213 | + $row['displayname'] = $row['displayname']."($name)"; |
|
| 214 | 214 | $components = []; |
| 215 | 215 | if ($row['components']) { |
| 216 | - $components = explode(',',$row['components']); |
|
| 216 | + $components = explode(',', $row['components']); |
|
| 217 | 217 | } |
| 218 | 218 | $calendar = [ |
| 219 | 219 | 'id' => $row['id'], |
| 220 | 220 | 'uri' => $uri, |
| 221 | 221 | 'principaluri' => $principalUri, |
| 222 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 223 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 224 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 225 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 226 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], |
|
| 227 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, |
|
| 222 | + '{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'), |
|
| 223 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 224 | + '{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 225 | + '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), |
|
| 226 | + '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'], |
|
| 227 | + '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ, |
|
| 228 | 228 | ]; |
| 229 | 229 | |
| 230 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 230 | + foreach ($this->propertyMap as $xmlName=>$dbName) { |
|
| 231 | 231 | $calendar[$xmlName] = $row[$dbName]; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -270,20 +270,20 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | $components = []; |
| 272 | 272 | if ($row['components']) { |
| 273 | - $components = explode(',',$row['components']); |
|
| 273 | + $components = explode(',', $row['components']); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | $calendar = [ |
| 277 | 277 | 'id' => $row['id'], |
| 278 | 278 | 'uri' => $row['uri'], |
| 279 | 279 | 'principaluri' => $row['principaluri'], |
| 280 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 281 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 282 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 283 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 280 | + '{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'), |
|
| 281 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 282 | + '{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 283 | + '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), |
|
| 284 | 284 | ]; |
| 285 | 285 | |
| 286 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 286 | + foreach ($this->propertyMap as $xmlName=>$dbName) { |
|
| 287 | 287 | $calendar[$xmlName] = $row[$dbName]; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -314,20 +314,20 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | $components = []; |
| 316 | 316 | if ($row['components']) { |
| 317 | - $components = explode(',',$row['components']); |
|
| 317 | + $components = explode(',', $row['components']); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $calendar = [ |
| 321 | 321 | 'id' => $row['id'], |
| 322 | 322 | 'uri' => $row['uri'], |
| 323 | 323 | 'principaluri' => $row['principaluri'], |
| 324 | - '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), |
|
| 325 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 326 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 327 | - '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), |
|
| 324 | + '{'.Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'), |
|
| 325 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 326 | + '{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), |
|
| 327 | + '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'), |
|
| 328 | 328 | ]; |
| 329 | 329 | |
| 330 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 330 | + foreach ($this->propertyMap as $xmlName=>$dbName) { |
|
| 331 | 331 | $calendar[$xmlName] = $row[$dbName]; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -359,16 +359,16 @@ discard block |
||
| 359 | 359 | $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; |
| 360 | 360 | if (isset($properties[$sccs])) { |
| 361 | 361 | if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) { |
| 362 | - throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet'); |
|
| 362 | + throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet'); |
|
| 363 | 363 | } |
| 364 | - $values['components'] = implode(',',$properties[$sccs]->getValue()); |
|
| 364 | + $values['components'] = implode(',', $properties[$sccs]->getValue()); |
|
| 365 | 365 | } |
| 366 | - $transp = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp'; |
|
| 366 | + $transp = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp'; |
|
| 367 | 367 | if (isset($properties[$transp])) { |
| 368 | - $values['transparent'] = $properties[$transp]->getValue()==='transparent'; |
|
| 368 | + $values['transparent'] = $properties[$transp]->getValue() === 'transparent'; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - foreach($this->propertyMap as $xmlName=>$dbName) { |
|
| 371 | + foreach ($this->propertyMap as $xmlName=>$dbName) { |
|
| 372 | 372 | if (isset($properties[$xmlName])) { |
| 373 | 373 | $values[$dbName] = $properties[$xmlName]; |
| 374 | 374 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | |
| 377 | 377 | $query = $this->db->getQueryBuilder(); |
| 378 | 378 | $query->insert('calendars'); |
| 379 | - foreach($values as $column => $value) { |
|
| 379 | + foreach ($values as $column => $value) { |
|
| 380 | 380 | $query->setValue($column, $query->createNamedParameter($value)); |
| 381 | 381 | } |
| 382 | 382 | $query->execute(); |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | */ |
| 401 | 401 | function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { |
| 402 | 402 | $supportedProperties = array_keys($this->propertyMap); |
| 403 | - $supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp'; |
|
| 403 | + $supportedProperties[] = '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp'; |
|
| 404 | 404 | |
| 405 | 405 | $propPatch->handle($supportedProperties, function($mutations) use ($calendarId) { |
| 406 | 406 | $newValues = []; |
| 407 | 407 | foreach ($mutations as $propertyName => $propertyValue) { |
| 408 | 408 | |
| 409 | 409 | switch ($propertyName) { |
| 410 | - case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' : |
|
| 410 | + case '{'.Plugin::NS_CALDAV.'}schedule-calendar-transp' : |
|
| 411 | 411 | $fieldName = 'transparent'; |
| 412 | 412 | $newValues[$fieldName] = $propertyValue->getValue() === 'transparent'; |
| 413 | 413 | break; |
@@ -490,14 +490,14 @@ discard block |
||
| 490 | 490 | $stmt = $query->execute(); |
| 491 | 491 | |
| 492 | 492 | $result = []; |
| 493 | - foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
|
| 493 | + foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
|
| 494 | 494 | $result[] = [ |
| 495 | 495 | 'id' => $row['id'], |
| 496 | 496 | 'uri' => $row['uri'], |
| 497 | 497 | 'lastmodified' => $row['lastmodified'], |
| 498 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 498 | + 'etag' => '"'.$row['etag'].'"', |
|
| 499 | 499 | 'calendarid' => $row['calendarid'], |
| 500 | - 'size' => (int)$row['size'], |
|
| 500 | + 'size' => (int) $row['size'], |
|
| 501 | 501 | 'component' => strtolower($row['componenttype']), |
| 502 | 502 | ]; |
| 503 | 503 | } |
@@ -531,15 +531,15 @@ discard block |
||
| 531 | 531 | $stmt = $query->execute(); |
| 532 | 532 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 533 | 533 | |
| 534 | - if(!$row) return null; |
|
| 534 | + if (!$row) return null; |
|
| 535 | 535 | |
| 536 | 536 | return [ |
| 537 | 537 | 'id' => $row['id'], |
| 538 | 538 | 'uri' => $row['uri'], |
| 539 | 539 | 'lastmodified' => $row['lastmodified'], |
| 540 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 540 | + 'etag' => '"'.$row['etag'].'"', |
|
| 541 | 541 | 'calendarid' => $row['calendarid'], |
| 542 | - 'size' => (int)$row['size'], |
|
| 542 | + 'size' => (int) $row['size'], |
|
| 543 | 543 | 'calendardata' => $this->readBlob($row['calendardata']), |
| 544 | 544 | 'component' => strtolower($row['componenttype']), |
| 545 | 545 | ]; |
@@ -568,15 +568,15 @@ discard block |
||
| 568 | 568 | $stmt = $query->execute(); |
| 569 | 569 | |
| 570 | 570 | $result = []; |
| 571 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 571 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 572 | 572 | |
| 573 | 573 | $result[] = [ |
| 574 | 574 | 'id' => $row['id'], |
| 575 | 575 | 'uri' => $row['uri'], |
| 576 | 576 | 'lastmodified' => $row['lastmodified'], |
| 577 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 577 | + 'etag' => '"'.$row['etag'].'"', |
|
| 578 | 578 | 'calendarid' => $row['calendarid'], |
| 579 | - 'size' => (int)$row['size'], |
|
| 579 | + 'size' => (int) $row['size'], |
|
| 580 | 580 | 'calendardata' => $this->readBlob($row['calendardata']), |
| 581 | 581 | 'component' => strtolower($row['componenttype']), |
| 582 | 582 | ]; |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | |
| 625 | 625 | $this->addChange($calendarId, $objectUri, 1); |
| 626 | 626 | |
| 627 | - return '"' . $extraData['etag'] . '"'; |
|
| 627 | + return '"'.$extraData['etag'].'"'; |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | /** |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | |
| 665 | 665 | $this->addChange($calendarId, $objectUri, 2); |
| 666 | 666 | |
| 667 | - return '"' . $extraData['etag'] . '"'; |
|
| 667 | + return '"'.$extraData['etag'].'"'; |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | /** |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | $stmt = $query->execute(); |
| 786 | 786 | |
| 787 | 787 | $result = []; |
| 788 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 788 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 789 | 789 | if ($requirePostFilter) { |
| 790 | 790 | if (!$this->validateFilterForObject($row, $filters)) { |
| 791 | 791 | continue; |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | $stmt = $query->execute(); |
| 829 | 829 | |
| 830 | 830 | if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
| 831 | - return $row['calendaruri'] . '/' . $row['objecturi']; |
|
| 831 | + return $row['calendaruri'].'/'.$row['objecturi']; |
|
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | return null; |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { |
| 894 | 894 | // Current synctoken |
| 895 | 895 | $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?'); |
| 896 | - $stmt->execute([ $calendarId ]); |
|
| 896 | + $stmt->execute([$calendarId]); |
|
| 897 | 897 | $currentToken = $stmt->fetchColumn(0); |
| 898 | 898 | |
| 899 | 899 | if (is_null($currentToken)) { |
@@ -910,8 +910,8 @@ discard block |
||
| 910 | 910 | if ($syncToken) { |
| 911 | 911 | |
| 912 | 912 | $query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? ORDER BY `synctoken`"; |
| 913 | - if ($limit>0) { |
|
| 914 | - $query.= " `LIMIT` " . (int)$limit; |
|
| 913 | + if ($limit > 0) { |
|
| 914 | + $query .= " `LIMIT` ".(int) $limit; |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | // Fetching all changes |
@@ -922,15 +922,15 @@ discard block |
||
| 922 | 922 | |
| 923 | 923 | // This loop ensures that any duplicates are overwritten, only the |
| 924 | 924 | // last change on a node is relevant. |
| 925 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 925 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 926 | 926 | |
| 927 | 927 | $changes[$row['uri']] = $row['operation']; |
| 928 | 928 | |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - foreach($changes as $uri => $operation) { |
|
| 931 | + foreach ($changes as $uri => $operation) { |
|
| 932 | 932 | |
| 933 | - switch($operation) { |
|
| 933 | + switch ($operation) { |
|
| 934 | 934 | case 1 : |
| 935 | 935 | $result['added'][] = $uri; |
| 936 | 936 | break; |
@@ -1000,10 +1000,10 @@ discard block |
||
| 1000 | 1000 | ->from('calendarsubscriptions') |
| 1001 | 1001 | ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) |
| 1002 | 1002 | ->orderBy('calendarorder', 'asc'); |
| 1003 | - $stmt =$query->execute(); |
|
| 1003 | + $stmt = $query->execute(); |
|
| 1004 | 1004 | |
| 1005 | 1005 | $subscriptions = []; |
| 1006 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1006 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 1007 | 1007 | |
| 1008 | 1008 | $subscription = [ |
| 1009 | 1009 | 'id' => $row['id'], |
@@ -1012,10 +1012,10 @@ discard block |
||
| 1012 | 1012 | 'source' => $row['source'], |
| 1013 | 1013 | 'lastmodified' => $row['lastmodified'], |
| 1014 | 1014 | |
| 1015 | - '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']), |
|
| 1015 | + '{'.Plugin::NS_CALDAV.'}supported-calendar-component-set' => new SupportedCalendarComponentSet(['VTODO', 'VEVENT']), |
|
| 1016 | 1016 | ]; |
| 1017 | 1017 | |
| 1018 | - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { |
|
| 1018 | + foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) { |
|
| 1019 | 1019 | if (!is_null($row[$dbName])) { |
| 1020 | 1020 | $subscription[$xmlName] = $row[$dbName]; |
| 1021 | 1021 | } |
@@ -1052,7 +1052,7 @@ discard block |
||
| 1052 | 1052 | 'lastmodified' => time(), |
| 1053 | 1053 | ]; |
| 1054 | 1054 | |
| 1055 | - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { |
|
| 1055 | + foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) { |
|
| 1056 | 1056 | if (isset($properties[$xmlName])) { |
| 1057 | 1057 | |
| 1058 | 1058 | $values[$dbName] = $properties[$xmlName]; |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | |
| 1098 | 1098 | $newValues = []; |
| 1099 | 1099 | |
| 1100 | - foreach($mutations as $propertyName=>$propertyValue) { |
|
| 1100 | + foreach ($mutations as $propertyName=>$propertyValue) { |
|
| 1101 | 1101 | if ($propertyName === '{http://calendarserver.org/ns/}source') { |
| 1102 | 1102 | $newValues['source'] = $propertyValue->getHref(); |
| 1103 | 1103 | } else { |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | $query = $this->db->getQueryBuilder(); |
| 1110 | 1110 | $query->update('calendarsubscriptions') |
| 1111 | 1111 | ->set('lastmodified', $query->createNamedParameter(time())); |
| 1112 | - foreach($newValues as $fieldName=>$value) { |
|
| 1112 | + foreach ($newValues as $fieldName=>$value) { |
|
| 1113 | 1113 | $query->set($fieldName, $query->createNamedParameter($value)); |
| 1114 | 1114 | } |
| 1115 | 1115 | $query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId))) |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | |
| 1160 | 1160 | $row = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 1161 | 1161 | |
| 1162 | - if(!$row) { |
|
| 1162 | + if (!$row) { |
|
| 1163 | 1163 | return null; |
| 1164 | 1164 | } |
| 1165 | 1165 | |
@@ -1167,8 +1167,8 @@ discard block |
||
| 1167 | 1167 | 'uri' => $row['uri'], |
| 1168 | 1168 | 'calendardata' => $row['calendardata'], |
| 1169 | 1169 | 'lastmodified' => $row['lastmodified'], |
| 1170 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 1171 | - 'size' => (int)$row['size'], |
|
| 1170 | + 'etag' => '"'.$row['etag'].'"', |
|
| 1171 | + 'size' => (int) $row['size'], |
|
| 1172 | 1172 | ]; |
| 1173 | 1173 | } |
| 1174 | 1174 | |
@@ -1191,13 +1191,13 @@ discard block |
||
| 1191 | 1191 | ->execute(); |
| 1192 | 1192 | |
| 1193 | 1193 | $result = []; |
| 1194 | - foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
|
| 1194 | + foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { |
|
| 1195 | 1195 | $result[] = [ |
| 1196 | 1196 | 'calendardata' => $row['calendardata'], |
| 1197 | 1197 | 'uri' => $row['uri'], |
| 1198 | 1198 | 'lastmodified' => $row['lastmodified'], |
| 1199 | - 'etag' => '"' . $row['etag'] . '"', |
|
| 1200 | - 'size' => (int)$row['size'], |
|
| 1199 | + 'etag' => '"'.$row['etag'].'"', |
|
| 1200 | + 'size' => (int) $row['size'], |
|
| 1201 | 1201 | ]; |
| 1202 | 1202 | } |
| 1203 | 1203 | |
@@ -1288,10 +1288,10 @@ discard block |
||
| 1288 | 1288 | $firstOccurence = null; |
| 1289 | 1289 | $lastOccurence = null; |
| 1290 | 1290 | $uid = null; |
| 1291 | - foreach($vObject->getComponents() as $component) { |
|
| 1292 | - if ($component->name!=='VTIMEZONE') { |
|
| 1291 | + foreach ($vObject->getComponents() as $component) { |
|
| 1292 | + if ($component->name !== 'VTIMEZONE') { |
|
| 1293 | 1293 | $componentType = $component->name; |
| 1294 | - $uid = (string)$component->UID; |
|
| 1294 | + $uid = (string) $component->UID; |
|
| 1295 | 1295 | break; |
| 1296 | 1296 | } |
| 1297 | 1297 | } |
@@ -1316,13 +1316,13 @@ discard block |
||
| 1316 | 1316 | $lastOccurence = $firstOccurence; |
| 1317 | 1317 | } |
| 1318 | 1318 | } else { |
| 1319 | - $it = new RecurrenceIterator($vObject, (string)$component->UID); |
|
| 1319 | + $it = new RecurrenceIterator($vObject, (string) $component->UID); |
|
| 1320 | 1320 | $maxDate = new \DateTime(self::MAX_DATE); |
| 1321 | 1321 | if ($it->isInfinite()) { |
| 1322 | 1322 | $lastOccurence = $maxDate->getTimeStamp(); |
| 1323 | 1323 | } else { |
| 1324 | 1324 | $end = $it->getDtEnd(); |
| 1325 | - while($it->valid() && $end < $maxDate) { |
|
| 1325 | + while ($it->valid() && $end < $maxDate) { |
|
| 1326 | 1326 | $end = $it->getDtEnd(); |
| 1327 | 1327 | $it->next(); |
| 1328 | 1328 | |
@@ -867,6 +867,7 @@ discard block |
||
| 867 | 867 | * * readOnly - boolean |
| 868 | 868 | * * summary - Optional, a description for the share |
| 869 | 869 | * |
| 870 | + * @param integer $addressBookId |
|
| 870 | 871 | * @return array |
| 871 | 872 | */ |
| 872 | 873 | public function getShares($addressBookId) { |
@@ -966,7 +967,7 @@ discard block |
||
| 966 | 967 | |
| 967 | 968 | /** |
| 968 | 969 | * For shared address books the sharee is set in the ACL of the address book |
| 969 | - * @param $addressBookId |
|
| 970 | + * @param integer $addressBookId |
|
| 970 | 971 | * @param $acl |
| 971 | 972 | * @return array |
| 972 | 973 | */ |
@@ -974,6 +975,9 @@ discard block |
||
| 974 | 975 | return $this->sharingBackend->applyShareAcl($addressBookId, $acl); |
| 975 | 976 | } |
| 976 | 977 | |
| 978 | + /** |
|
| 979 | + * @param boolean $toV2 |
|
| 980 | + */ |
|
| 977 | 981 | private function convertPrincipal($principalUri, $toV2) { |
| 978 | 982 | if ($this->principalBackend->getPrincipalPrefix() === 'principals') { |
| 979 | 983 | list(, $name) = URLUtil::splitPath($principalUri); |
@@ -111,22 +111,22 @@ discard block |
||
| 111 | 111 | $addressBooks = []; |
| 112 | 112 | |
| 113 | 113 | $result = $query->execute(); |
| 114 | - while($row = $result->fetch()) { |
|
| 114 | + while ($row = $result->fetch()) { |
|
| 115 | 115 | $addressBooks[$row['id']] = [ |
| 116 | 116 | 'id' => $row['id'], |
| 117 | 117 | 'uri' => $row['uri'], |
| 118 | 118 | 'principaluri' => $this->convertPrincipal($row['principaluri'], false), |
| 119 | 119 | '{DAV:}displayname' => $row['displayname'], |
| 120 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 120 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 121 | 121 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 122 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 122 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 123 | 123 | ]; |
| 124 | 124 | } |
| 125 | 125 | $result->closeCursor(); |
| 126 | 126 | |
| 127 | 127 | // query for shared calendars |
| 128 | 128 | $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true); |
| 129 | - $principals[]= $principalUri; |
|
| 129 | + $principals[] = $principalUri; |
|
| 130 | 130 | |
| 131 | 131 | $query = $this->db->getQueryBuilder(); |
| 132 | 132 | $result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access']) |
@@ -138,21 +138,21 @@ discard block |
||
| 138 | 138 | ->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY) |
| 139 | 139 | ->execute(); |
| 140 | 140 | |
| 141 | - while($row = $result->fetch()) { |
|
| 141 | + while ($row = $result->fetch()) { |
|
| 142 | 142 | list(, $name) = URLUtil::splitPath($row['principaluri']); |
| 143 | - $uri = $row['uri'] . '_shared_by_' . $name; |
|
| 144 | - $displayName = $row['displayname'] . "($name)"; |
|
| 143 | + $uri = $row['uri'].'_shared_by_'.$name; |
|
| 144 | + $displayName = $row['displayname']."($name)"; |
|
| 145 | 145 | if (!isset($addressBooks[$row['id']])) { |
| 146 | 146 | $addressBooks[$row['id']] = [ |
| 147 | 147 | 'id' => $row['id'], |
| 148 | 148 | 'uri' => $uri, |
| 149 | 149 | 'principaluri' => $principalUri, |
| 150 | 150 | '{DAV:}displayname' => $displayName, |
| 151 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 151 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 152 | 152 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 153 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 154 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], |
|
| 155 | - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, |
|
| 153 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 154 | + '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}owner-principal' => $row['principaluri'], |
|
| 155 | + '{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}read-only' => (int) $row['access'] === Backend::ACCESS_READ, |
|
| 156 | 156 | ]; |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | 'uri' => $row['uri'], |
| 183 | 183 | 'principaluri' => $row['principaluri'], |
| 184 | 184 | '{DAV:}displayname' => $row['displayname'], |
| 185 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 185 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 186 | 186 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 187 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 187 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 188 | 188 | ]; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | 'uri' => $row['uri'], |
| 213 | 213 | 'principaluri' => $row['principaluri'], |
| 214 | 214 | '{DAV:}displayname' => $row['displayname'], |
| 215 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], |
|
| 215 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'], |
|
| 216 | 216 | '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], |
| 217 | - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', |
|
| 217 | + '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', |
|
| 218 | 218 | ]; |
| 219 | 219 | } |
| 220 | 220 | |
@@ -237,19 +237,19 @@ discard block |
||
| 237 | 237 | function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { |
| 238 | 238 | $supportedProperties = [ |
| 239 | 239 | '{DAV:}displayname', |
| 240 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description', |
|
| 240 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description', |
|
| 241 | 241 | ]; |
| 242 | 242 | |
| 243 | 243 | $propPatch->handle($supportedProperties, function($mutations) use ($addressBookId) { |
| 244 | 244 | |
| 245 | 245 | $updates = []; |
| 246 | - foreach($mutations as $property=>$newValue) { |
|
| 246 | + foreach ($mutations as $property=>$newValue) { |
|
| 247 | 247 | |
| 248 | - switch($property) { |
|
| 248 | + switch ($property) { |
|
| 249 | 249 | case '{DAV:}displayname' : |
| 250 | 250 | $updates['displayname'] = $newValue; |
| 251 | 251 | break; |
| 252 | - case '{' . Plugin::NS_CARDDAV . '}addressbook-description' : |
|
| 252 | + case '{'.Plugin::NS_CARDDAV.'}addressbook-description' : |
|
| 253 | 253 | $updates['description'] = $newValue; |
| 254 | 254 | break; |
| 255 | 255 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $query = $this->db->getQueryBuilder(); |
| 258 | 258 | $query->update('addressbooks'); |
| 259 | 259 | |
| 260 | - foreach($updates as $key=>$value) { |
|
| 260 | + foreach ($updates as $key=>$value) { |
|
| 261 | 261 | $query->set($key, $query->createNamedParameter($value)); |
| 262 | 262 | } |
| 263 | 263 | $query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId))) |
@@ -288,24 +288,24 @@ discard block |
||
| 288 | 288 | 'synctoken' => 1 |
| 289 | 289 | ]; |
| 290 | 290 | |
| 291 | - foreach($properties as $property=>$newValue) { |
|
| 291 | + foreach ($properties as $property=>$newValue) { |
|
| 292 | 292 | |
| 293 | - switch($property) { |
|
| 293 | + switch ($property) { |
|
| 294 | 294 | case '{DAV:}displayname' : |
| 295 | 295 | $values['displayname'] = $newValue; |
| 296 | 296 | break; |
| 297 | - case '{' . Plugin::NS_CARDDAV . '}addressbook-description' : |
|
| 297 | + case '{'.Plugin::NS_CARDDAV.'}addressbook-description' : |
|
| 298 | 298 | $values['description'] = $newValue; |
| 299 | 299 | break; |
| 300 | 300 | default : |
| 301 | - throw new BadRequest('Unknown property: ' . $property); |
|
| 301 | + throw new BadRequest('Unknown property: '.$property); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // Fallback to make sure the displayname is set. Some clients may refuse |
| 307 | 307 | // to work with addressbooks not having a displayname. |
| 308 | - if(is_null($values['displayname'])) { |
|
| 308 | + if (is_null($values['displayname'])) { |
|
| 309 | 309 | $values['displayname'] = $url; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | $cards = []; |
| 384 | 384 | |
| 385 | 385 | $result = $query->execute(); |
| 386 | - while($row = $result->fetch()) { |
|
| 387 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 386 | + while ($row = $result->fetch()) { |
|
| 387 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 388 | 388 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 389 | 389 | $cards[] = $row; |
| 390 | 390 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | if (!$row) { |
| 419 | 419 | return false; |
| 420 | 420 | } |
| 421 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 421 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 422 | 422 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 423 | 423 | |
| 424 | 424 | return $row; |
@@ -447,8 +447,8 @@ discard block |
||
| 447 | 447 | $cards = []; |
| 448 | 448 | |
| 449 | 449 | $result = $query->execute(); |
| 450 | - while($row = $result->fetch()) { |
|
| 451 | - $row['etag'] = '"' . $row['etag'] . '"'; |
|
| 450 | + while ($row = $result->fetch()) { |
|
| 451 | + $row['etag'] = '"'.$row['etag'].'"'; |
|
| 452 | 452 | $row['carddata'] = $this->readBlob($row['carddata']); |
| 453 | 453 | $cards[] = $row; |
| 454 | 454 | } |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | 'cardData' => $cardData])); |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - return '"' . $etag . '"'; |
|
| 511 | + return '"'.$etag.'"'; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | 'cardData' => $cardData])); |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - return '"' . $etag . '"'; |
|
| 563 | + return '"'.$etag.'"'; |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /** |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null) { |
| 661 | 661 | // Current synctoken |
| 662 | 662 | $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*addressbooks` WHERE `id` = ?'); |
| 663 | - $stmt->execute([ $addressBookId ]); |
|
| 663 | + $stmt->execute([$addressBookId]); |
|
| 664 | 664 | $currentToken = $stmt->fetchColumn(0); |
| 665 | 665 | |
| 666 | 666 | if (is_null($currentToken)) return null; |
@@ -675,8 +675,8 @@ discard block |
||
| 675 | 675 | if ($syncToken) { |
| 676 | 676 | |
| 677 | 677 | $query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`"; |
| 678 | - if ($limit>0) { |
|
| 679 | - $query .= " `LIMIT` " . (int)$limit; |
|
| 678 | + if ($limit > 0) { |
|
| 679 | + $query .= " `LIMIT` ".(int) $limit; |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | // Fetching all changes |
@@ -687,15 +687,15 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | // This loop ensures that any duplicates are overwritten, only the |
| 689 | 689 | // last change on a node is relevant. |
| 690 | - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 690 | + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { |
|
| 691 | 691 | |
| 692 | 692 | $changes[$row['uri']] = $row['operation']; |
| 693 | 693 | |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - foreach($changes as $uri => $operation) { |
|
| 696 | + foreach ($changes as $uri => $operation) { |
|
| 697 | 697 | |
| 698 | - switch($operation) { |
|
| 698 | + switch ($operation) { |
|
| 699 | 699 | case 1: |
| 700 | 700 | $result['added'][] = $uri; |
| 701 | 701 | break; |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | $query2->orWhere( |
| 776 | 776 | $query2->expr()->andX( |
| 777 | 777 | $query2->expr()->eq('cp.name', $query->createNamedParameter($property)), |
| 778 | - $query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')) |
|
| 778 | + $query2->expr()->ilike('cp.value', $query->createNamedParameter('%'.$this->db->escapeLikeParameter($pattern).'%')) |
|
| 779 | 779 | ) |
| 780 | 780 | ); |
| 781 | 781 | } |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | |
| 790 | 790 | $result->closeCursor(); |
| 791 | 791 | |
| 792 | - return array_map(function($array) {return $this->readBlob($array['carddata']);}, $cards); |
|
| 792 | + return array_map(function($array) {return $this->readBlob($array['carddata']); }, $cards); |
|
| 793 | 793 | |
| 794 | 794 | } |
| 795 | 795 | |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $result->closeCursor(); |
| 830 | 830 | |
| 831 | 831 | if (!isset($uri['uri'])) { |
| 832 | - throw new \InvalidArgumentException('Card does not exists: ' . $id); |
|
| 832 | + throw new \InvalidArgumentException('Card does not exists: '.$id); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | return $uri['uri']; |
@@ -901,11 +901,11 @@ discard block |
||
| 901 | 901 | ); |
| 902 | 902 | |
| 903 | 903 | foreach ($vCard->children as $property) { |
| 904 | - if(!in_array($property->name, self::$indexProperties)) { |
|
| 904 | + if (!in_array($property->name, self::$indexProperties)) { |
|
| 905 | 905 | continue; |
| 906 | 906 | } |
| 907 | 907 | $preferred = 0; |
| 908 | - foreach($property->parameters as $parameter) { |
|
| 908 | + foreach ($property->parameters as $parameter) { |
|
| 909 | 909 | if ($parameter->name == 'TYPE' && strtoupper($parameter->getValue()) == 'PREF') { |
| 910 | 910 | $preferred = 1; |
| 911 | 911 | break; |
@@ -960,10 +960,10 @@ discard block |
||
| 960 | 960 | $result->closeCursor(); |
| 961 | 961 | |
| 962 | 962 | if (!isset($cardIds['id'])) { |
| 963 | - throw new \InvalidArgumentException('Card does not exists: ' . $uri); |
|
| 963 | + throw new \InvalidArgumentException('Card does not exists: '.$uri); |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - return (int)$cardIds['id']; |
|
| 966 | + return (int) $cardIds['id']; |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | /** |
@@ -246,7 +246,7 @@ |
||
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | - * @return array|null |
|
| 249 | + * @return string |
|
| 250 | 250 | */ |
| 251 | 251 | public function getLocalSystemAddressBook() { |
| 252 | 252 | if (is_null($this->localSystemAddressBook)) { |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
| 91 | 91 | // remote server revoked access to the address book, remove it |
| 92 | 92 | $this->backend->deleteAddressBook($addressBookId); |
| 93 | - $this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']); |
|
| 93 | + $this->logger->info('Authorization failed, remove address book: '.$url, ['app' => 'dav']); |
|
| 94 | 94 | throw $ex; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | protected function requestSyncReport($url, $userName, $sharedSecret, $syncToken) { |
| 143 | 143 | $settings = [ |
| 144 | - 'baseUri' => $url . '/', |
|
| 144 | + 'baseUri' => $url.'/', |
|
| 145 | 145 | 'userName' => $userName, |
| 146 | 146 | 'password' => $sharedSecret, |
| 147 | 147 | ]; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | public function deleteUser($userOrCardId) { |
| 256 | 256 | $systemAddressBook = $this->getLocalSystemAddressBook(); |
| 257 | - if ($userOrCardId instanceof IUser){ |
|
| 257 | + if ($userOrCardId instanceof IUser) { |
|
| 258 | 258 | $name = $userOrCardId->getBackendClassName(); |
| 259 | 259 | $userId = $userOrCardId->getUID(); |
| 260 | 260 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | if (is_null($this->localSystemAddressBook)) { |
| 271 | 271 | $systemPrincipal = "principals/system/system"; |
| 272 | 272 | $this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [ |
| 273 | - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance' |
|
| 273 | + '{'.Plugin::NS_CARDDAV.'}addressbook-description' => 'System addressbook which holds all users of this instance' |
|
| 274 | 274 | ]); |
| 275 | 275 | } |
| 276 | 276 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | // remove no longer existing |
| 290 | 290 | $allCards = $this->backend->getCards($systemAddressBook['id']); |
| 291 | - foreach($allCards as $card) { |
|
| 291 | + foreach ($allCards as $card) { |
|
| 292 | 292 | $vCard = Reader::read($card['carddata']); |
| 293 | 293 | $uid = $vCard->UID->getValue(); |
| 294 | 294 | // load backend and see if user exists |
@@ -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(); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @package OCA\DAV\Comments |
| 40 | 40 | */ |
| 41 | 41 | class EntityCollection extends RootCollection implements \Sabre\DAV\IProperties { |
| 42 | - const PROPERTY_NAME_READ_MARKER = '{http://owncloud.org/ns}readMarker'; |
|
| 42 | + const PROPERTY_NAME_READ_MARKER = '{http://owncloud.org/ns}readMarker'; |
|
| 43 | 43 | |
| 44 | 44 | /** @var Folder */ |
| 45 | 45 | protected $fileRoot; |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | IUserSession $userSession, |
| 69 | 69 | ILogger $logger |
| 70 | 70 | ) { |
| 71 | - foreach(['id', 'name'] as $property) { |
|
| 71 | + foreach (['id', 'name'] as $property) { |
|
| 72 | 72 | $$property = trim($$property); |
| 73 | - if(empty($$property) || !is_string($$property)) { |
|
| 74 | - throw new \InvalidArgumentException('"' . $property . '" parameter must be non-empty string'); |
|
| 73 | + if (empty($$property) || !is_string($$property)) { |
|
| 74 | + throw new \InvalidArgumentException('"'.$property.'" parameter must be non-empty string'); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | $this->id = $id; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | function findChildren($limit = 0, $offset = 0, \DateTime $datetime = null) { |
| 139 | 139 | $comments = $this->commentsManager->getForObject($this->name, $this->id, $limit, $offset, $datetime); |
| 140 | 140 | $result = []; |
| 141 | - foreach($comments as $comment) { |
|
| 141 | + foreach ($comments as $comment) { |
|
| 142 | 142 | $result[] = new CommentNode( |
| 143 | 143 | $this->commentsManager, |
| 144 | 144 | $comment, |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | function getProperties($properties) { |
| 192 | 192 | $marker = null; |
| 193 | 193 | $user = $this->userSession->getUser(); |
| 194 | - if(!is_null($user)) { |
|
| 194 | + if (!is_null($user)) { |
|
| 195 | 195 | $marker = $this->commentsManager->getReadMark($this->name, $this->id, $user); |
| 196 | 196 | } |
| 197 | 197 | return [self::PROPERTY_NAME_READ_MARKER => $marker]; |
@@ -146,7 +146,7 @@ |
||
| 146 | 146 | /** |
| 147 | 147 | * Returns an array with all the child nodes |
| 148 | 148 | * |
| 149 | - * @return \Sabre\DAV\INode[] |
|
| 149 | + * @return EntityTypeCollection[] |
|
| 150 | 150 | */ |
| 151 | 151 | function getChildren() { |
| 152 | 152 | $this->initCollections(); |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | * @throws NotAuthenticated |
| 87 | 87 | */ |
| 88 | 88 | protected function initCollections() { |
| 89 | - if(!empty($this->entityTypeCollections)) { |
|
| 89 | + if (!empty($this->entityTypeCollections)) { |
|
| 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 | $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
@@ -138,10 +138,10 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | function getChild($name) { |
| 140 | 140 | $this->initCollections(); |
| 141 | - if(isset($this->entityTypeCollections[$name])) { |
|
| 141 | + if (isset($this->entityTypeCollections[$name])) { |
|
| 142 | 142 | return $this->entityTypeCollections[$name]; |
| 143 | 143 | } |
| 144 | - throw new NotFound('Entity type "' . $name . '" not found."'); |
|
| 144 | + throw new NotFound('Entity type "'.$name.'" not found."'); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -64,6 +64,9 @@ |
||
| 64 | 64 | ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + /** |
|
| 68 | + * @param boolean $toV2 |
|
| 69 | + */ |
|
| 67 | 70 | private function convertPrincipal($principal, $toV2) { |
| 68 | 71 | list(, $name) = URLUtil::splitPath($principal); |
| 69 | 72 | if ($toV2) { |
@@ -75,9 +75,9 @@ |
||
| 75 | 75 | |
| 76 | 76 | function propFind(PropFind $propFind, INode $node) { |
| 77 | 77 | /* Overload current-user-principal */ |
| 78 | - $propFind->handle('{DAV:}current-user-principal', function () { |
|
| 78 | + $propFind->handle('{DAV:}current-user-principal', function() { |
|
| 79 | 79 | if ($url = parent::getCurrentUserPrincipal()) { |
| 80 | - return new Principal(Principal::HREF, $url . '/'); |
|
| 80 | + return new Principal(Principal::HREF, $url.'/'); |
|
| 81 | 81 | } else { |
| 82 | 82 | return new Principal(Principal::UNAUTHENTICATED); |
| 83 | 83 | } |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | * returns a reference to the comments node |
| 96 | 96 | * |
| 97 | 97 | * @param Node $node |
| 98 | - * @return mixed|string |
|
| 98 | + * @return null|string |
|
| 99 | 99 | */ |
| 100 | 100 | public function getCommentsLink(Node $node) { |
| 101 | 101 | $href = $this->server->getBaseUri(); |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | * @return mixed|string |
| 100 | 100 | */ |
| 101 | 101 | public function getCommentsLink(Node $node) { |
| 102 | - $href = $this->server->getBaseUri(); |
|
| 102 | + $href = $this->server->getBaseUri(); |
|
| 103 | 103 | $entryPoint = strrpos($href, '/webdav/'); |
| 104 | - if($entryPoint === false) { |
|
| 104 | + if ($entryPoint === false) { |
|
| 105 | 105 | // in case we end up somewhere else, unexpectedly. |
| 106 | 106 | return null; |
| 107 | 107 | } |
| 108 | 108 | $href = substr_replace($href, '/dav/', $entryPoint); |
| 109 | - $href .= 'comments/files/' . rawurldecode($node->getId()); |
|
| 109 | + $href .= 'comments/files/'.rawurldecode($node->getId()); |
|
| 110 | 110 | return $href; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function getUnreadCount(Node $node) { |
| 121 | 121 | $user = $this->userSession->getUser(); |
| 122 | - if(is_null($user)) { |
|
| 122 | + if (is_null($user)) { |
|
| 123 | 123 | return null; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -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 | */ |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | // we catch the exception to prevent breaking the whole list with a 404 |
| 111 | 111 | // (soft fail) |
| 112 | 112 | \OC::$server->getLogger()->warning( |
| 113 | - 'Could not get node for path: \"' . $path . '\" : ' . $e->getMessage(), |
|
| 113 | + 'Could not get node for path: \"'.$path.'\" : '.$e->getMessage(), |
|
| 114 | 114 | array('app' => 'files') |
| 115 | 115 | ); |
| 116 | 116 | return; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $statement = $this->connection->prepare( |
| 170 | 170 | 'DELETE FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?' |
| 171 | 171 | ); |
| 172 | - $statement->execute(array($this->user, '/' . $path)); |
|
| 172 | + $statement->execute(array($this->user, '/'.$path)); |
|
| 173 | 173 | $statement->closeCursor(); |
| 174 | 174 | |
| 175 | 175 | unset($this->cache[$path]); |
@@ -185,10 +185,10 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function move($source, $destination) { |
| 187 | 187 | $statement = $this->connection->prepare( |
| 188 | - 'UPDATE `*PREFIX*properties` SET `propertypath` = ?' . |
|
| 188 | + 'UPDATE `*PREFIX*properties` SET `propertypath` = ?'. |
|
| 189 | 189 | ' WHERE `userid` = ? AND `propertypath` = ?' |
| 190 | 190 | ); |
| 191 | - $statement->execute(array('/' . $destination, $this->user, '/' . $source)); |
|
| 191 | + $statement->execute(array('/'.$destination, $this->user, '/'.$source)); |
|
| 192 | 192 | $statement->closeCursor(); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -249,13 +249,13 @@ discard block |
||
| 249 | 249 | private function updateProperties($node, $properties) { |
| 250 | 250 | $path = $node->getPath(); |
| 251 | 251 | |
| 252 | - $deleteStatement = 'DELETE FROM `*PREFIX*properties`' . |
|
| 252 | + $deleteStatement = 'DELETE FROM `*PREFIX*properties`'. |
|
| 253 | 253 | ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?'; |
| 254 | 254 | |
| 255 | - $insertStatement = 'INSERT INTO `*PREFIX*properties`' . |
|
| 255 | + $insertStatement = 'INSERT INTO `*PREFIX*properties`'. |
|
| 256 | 256 | ' (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)'; |
| 257 | 257 | |
| 258 | - $updateStatement = 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ?' . |
|
| 258 | + $updateStatement = 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ?'. |
|
| 259 | 259 | ' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?'; |
| 260 | 260 | |
| 261 | 261 | // TODO: use "insert or update" strategy ? |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | $result = $this->connection->executeQuery( |
| 330 | 330 | $sql, |
| 331 | - array($this->user, rtrim($path, '/') . '/%', $requestedProperties), |
|
| 331 | + array($this->user, rtrim($path, '/').'/%', $requestedProperties), |
|
| 332 | 332 | array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY) |
| 333 | 333 | ); |
| 334 | 334 | |