diff options
Diffstat (limited to 'apps/dav/lib/CalDAV')
33 files changed, 107 insertions, 165 deletions
diff --git a/apps/dav/lib/CalDAV/Activity/Backend.php b/apps/dav/lib/CalDAV/Activity/Backend.php index 804b88d0322..4ca5ad17aeb 100644 --- a/apps/dav/lib/CalDAV/Activity/Backend.php +++ b/apps/dav/lib/CalDAV/Activity/Backend.php @@ -469,7 +469,7 @@ class Backend { protected function getObjectNameAndType(array $objectData) { $vObject = Reader::read($objectData['calendardata']); $component = $componentType = null; - foreach($vObject->getComponents() as $component) { + foreach ($vObject->getComponents() as $component) { if (in_array($component->name, ['VEVENT', 'VTODO'])) { $componentType = $component->name; break; diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php index 0a070810bdb..42b70f0a928 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php @@ -36,7 +36,6 @@ use OCP\IUserManager; use OCP\L10N\IFactory; class Calendar extends Base { - const SUBJECT_ADD = 'calendar_add'; const SUBJECT_UPDATE = 'calendar_update'; const SUBJECT_DELETE = 'calendar_delete'; @@ -111,12 +110,10 @@ class Calendar extends Base { $subject = $this->l->t('{actor} updated calendar {calendar}'); } elseif ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { $subject = $this->l->t('You updated calendar {calendar}'); - } elseif ($event->getSubject() === self::SUBJECT_PUBLISH . '_self') { $subject = $this->l->t('You shared calendar {calendar} as public link'); } elseif ($event->getSubject() === self::SUBJECT_UNPUBLISH . '_self') { $subject = $this->l->t('You removed public link for calendar {calendar}'); - } elseif ($event->getSubject() === self::SUBJECT_SHARE_USER) { $subject = $this->l->t('{actor} shared calendar {calendar} with you'); } elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') { @@ -131,7 +128,6 @@ class Calendar extends Base { $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}'); } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') { $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves'); - } elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') { $subject = $this->l->t('You shared calendar {calendar} with group {group}'); } elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') { diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Event.php b/apps/dav/lib/CalDAV/Activity/Provider/Event.php index 9a71553fd31..f044c2f8208 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Event.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Event.php @@ -34,7 +34,6 @@ use OCP\IUserManager; use OCP\L10N\IFactory; class Event extends Base { - const SUBJECT_OBJECT_ADD = 'object_add'; const SUBJECT_OBJECT_UPDATE = 'object_update'; const SUBJECT_OBJECT_DELETE = 'object_delete'; diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Todo.php b/apps/dav/lib/CalDAV/Activity/Provider/Todo.php index 54339566823..dcdc3577233 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Todo.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Todo.php @@ -60,7 +60,6 @@ class Todo extends Event { $subject = $this->l->t('{actor} updated todo {todo} in list {calendar}'); } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_self') { $subject = $this->l->t('You updated todo {todo} in list {calendar}'); - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed') { $subject = $this->l->t('{actor} solved todo {todo} in list {calendar}'); } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self') { diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php index 208b923f531..2969e5f3ead 100644 --- a/apps/dav/lib/CalDAV/BirthdayService.php +++ b/apps/dav/lib/CalDAV/BirthdayService.php @@ -49,7 +49,6 @@ use Sabre\VObject\Reader; * @package OCA\DAV\CalDAV */ class BirthdayService { - const BIRTHDAY_CALENDAR_URI = 'contact_birthdays'; /** @var GroupPrincipalBackend */ @@ -298,7 +297,7 @@ class BirthdayService { $calendar = $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI); $calendarObjects = $this->calDavBackEnd->getCalendarObjects($calendar['id'], CalDavBackend::CALENDAR_TYPE_CALENDAR); - foreach($calendarObjects as $calendarObject) { + foreach ($calendarObjects as $calendarObject) { $this->calDavBackEnd->deleteCalendarObject($calendar['id'], $calendarObject['uri'], CalDavBackend::CALENDAR_TYPE_CALENDAR); } } @@ -311,9 +310,9 @@ class BirthdayService { $principal = 'principals/users/'.$user; $this->ensureCalendarExists($principal); $books = $this->cardDavBackEnd->getAddressBooksForUser($principal); - foreach($books as $book) { + foreach ($books as $book) { $cards = $this->cardDavBackEnd->getCards($book['id']); - foreach($cards as $card) { + foreach ($cards as $card) { $this->onCardChanged((int) $book['id'], $card['uri'], $card['carddata']); } } @@ -455,7 +454,7 @@ class BirthdayService { return ''; } } else { - switch($field) { + switch ($field) { case 'BDAY': return implode('', [ $name, diff --git a/apps/dav/lib/CalDAV/CachedSubscription.php b/apps/dav/lib/CalDAV/CachedSubscription.php index 093a86dcad0..7f81617b9a4 100644 --- a/apps/dav/lib/CalDAV/CachedSubscription.php +++ b/apps/dav/lib/CalDAV/CachedSubscription.php @@ -136,7 +136,6 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar { $obj['acl'] = $this->getChildACL(); return new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj); - } /** @@ -146,7 +145,7 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar { $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION); $children = []; - foreach($objs as $obj) { + foreach ($objs as $obj) { $children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj); } @@ -161,7 +160,7 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar { $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION); $children = []; - foreach($objs as $obj) { + foreach ($objs as $obj) { $children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj); } diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 9b96a4cfaaa..dd3cb048483 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -77,7 +77,6 @@ use Symfony\Component\EventDispatcher\GenericEvent; * @package OCA\DAV\CalDAV */ class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport { - const CALENDAR_TYPE_CALENDAR = 0; const CALENDAR_TYPE_SUBSCRIPTION = 1; @@ -273,8 +272,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt = $query->execute(); $calendars = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $components = []; if ($row['components']) { $components = explode(',',$row['components']); @@ -291,7 +289,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint), ]; - foreach($this->propertyMap as $xmlName=>$dbName) { + foreach ($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } @@ -332,7 +330,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->execute(); $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; - while($row = $result->fetch()) { + while ($row = $result->fetch()) { if ($row['principaluri'] === $principalUri) { continue; } @@ -369,7 +367,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $readOnlyPropertyName => $readOnly, ]; - foreach($this->propertyMap as $xmlName=>$dbName) { + foreach ($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } @@ -402,7 +400,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->orderBy('calendarorder', 'ASC'); $stmt = $query->execute(); $calendars = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $components = []; if ($row['components']) { $components = explode(',',$row['components']); @@ -416,7 +414,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), ]; - foreach($this->propertyMap as $xmlName=>$dbName) { + foreach ($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } @@ -471,7 +469,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar'))) ->execute(); - while($row = $result->fetch()) { + while ($row = $result->fetch()) { list(, $name) = Uri\split($row['principaluri']); $row['displayname'] = $row['displayname'] . "($name)"; $components = []; @@ -491,7 +489,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC, ]; - foreach($this->propertyMap as $xmlName=>$dbName) { + foreach ($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } @@ -557,14 +555,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC, ]; - foreach($this->propertyMap as $xmlName=>$dbName) { + foreach ($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } $this->addOwnerPrincipal($calendar); return $calendar; - } /** @@ -610,7 +607,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), ]; - foreach($this->propertyMap as $xmlName=>$dbName) { + foreach ($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } @@ -660,7 +657,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), ]; - foreach($this->propertyMap as $xmlName=>$dbName) { + foreach ($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } @@ -704,7 +701,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', ]; - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { + foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) { if (!is_null($row[$dbName])) { $subscription[$xmlName] = $row[$dbName]; } @@ -753,7 +750,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent'); } - foreach($this->propertyMap as $xmlName=>$dbName) { + foreach ($this->propertyMap as $xmlName=>$dbName) { if (isset($properties[$xmlName])) { $values[$dbName] = $properties[$xmlName]; } @@ -761,7 +758,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $query = $this->db->getQueryBuilder(); $query->insert('calendars'); - foreach($values as $column => $value) { + foreach ($values as $column => $value) { $query->setValue($column, $query->createNamedParameter($value)); } $query->execute(); @@ -803,7 +800,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) { $newValues = []; foreach ($mutations as $propertyName => $propertyValue) { - switch ($propertyName) { case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp': $fieldName = 'transparent'; @@ -814,7 +810,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $newValues[$fieldName] = $propertyValue; break; } - } $query = $this->db->getQueryBuilder(); $query->update('calendars'); @@ -923,7 +918,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt = $query->execute(); $result = []; - foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -966,7 +961,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt = $query->execute(); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if(!$row) { + if (!$row) { return null; } @@ -1326,7 +1321,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $requirePostFilter = false; } } - } $columns = ['uri']; if ($requirePostFilter) { @@ -1352,13 +1346,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt = $query->execute(); $result = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { if ($requirePostFilter) { // validateFilterForObject will parse the calendar data // catch parsing errors try { $matches = $this->validateFilterForObject($row, $filters); - } catch(ParseException $ex) { + } catch (ParseException $ex) { $this->logger->logException($ex, [ 'app' => 'dav', 'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$id.' uri:'.$row['uri'] @@ -1400,7 +1394,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $uriMapper = []; - foreach($calendars as $calendar) { + foreach ($calendars as $calendar) { if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) { $ownCalendars[] = $calendar['id']; } else { @@ -1415,14 +1409,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $query = $this->db->getQueryBuilder(); // Calendar id expressions $calendarExpressions = []; - foreach($ownCalendars as $id) { + foreach ($ownCalendars as $id) { $calendarExpressions[] = $query->expr()->andX( $query->expr()->eq('c.calendarid', $query->createNamedParameter($id)), $query->expr()->eq('c.calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR))); } - foreach($sharedCalendars as $id) { + foreach ($sharedCalendars as $id) { $calendarExpressions[] = $query->expr()->andX( $query->expr()->eq('c.calendarid', $query->createNamedParameter($id)), @@ -1440,7 +1434,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription // Component expressions $compExpressions = []; - foreach($filters['comps'] as $comp) { + foreach ($filters['comps'] as $comp) { $compExpressions[] = $query->expr() ->eq('c.componenttype', $query->createNamedParameter($comp)); } @@ -1459,13 +1453,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription } $propParamExpressions = []; - foreach($filters['props'] as $prop) { + foreach ($filters['props'] as $prop) { $propParamExpressions[] = $query->expr()->andX( $query->expr()->eq('i.name', $query->createNamedParameter($prop)), $query->expr()->isNull('i.parameter') ); } - foreach($filters['params'] as $param) { + foreach ($filters['params'] as $param) { $propParamExpressions[] = $query->expr()->andX( $query->expr()->eq('i.name', $query->createNamedParameter($param['property'])), $query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter'])) @@ -1497,7 +1491,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt = $query->execute(); $result = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $path = $uriMapper[$row['calendarid']] . '/' . $row['uri']; if (!in_array($path, $result)) { $result[] = $path; @@ -1538,7 +1532,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription } $or = $innerQuery->expr()->orX(); - foreach($searchProperties as $searchProperty) { + foreach ($searchProperties as $searchProperty) { $or->add($innerQuery->expr()->eq('op.name', $outerQuery->createNamedParameter($searchProperty))); } @@ -1557,7 +1551,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription if (isset($options['timerange']['start']) && $options['timerange']['start'] instanceof DateTime) { $outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence', $outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp()))); - } if (isset($options['timerange']['end']) && $options['timerange']['end'] instanceof DateTime) { $outerQuery->andWhere($outerQuery->expr()->lt('firstoccurence', @@ -1567,7 +1560,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription if (isset($options['types'])) { $or = $outerQuery->expr()->orX(); - foreach($options['types'] as $type) { + foreach ($options['types'] as $type) { $or->add($outerQuery->expr()->eq('componenttype', $outerQuery->createNamedParameter($type))); } @@ -1592,7 +1585,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $comps = $calendarData->getComponents(); $objects = []; $timezones = []; - foreach($comps as $comp) { + foreach ($comps as $comp) { if ($comp instanceof VTimeZone) { $timezones[] = $comp; } else { @@ -1629,7 +1622,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription }); $validationRules = $comp->getValidationRules(); - foreach($subComponents as $subComponent) { + foreach ($subComponents as $subComponent) { $name = $subComponent->name; if (!isset($data[$name])) { $data[$name] = []; @@ -1637,7 +1630,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $data[$name][] = $this->transformSearchData($subComponent); } - foreach($properties as $property) { + foreach ($properties as $property) { $name = $property->name; if (!isset($validationRules[$name])) { $validationRules[$name] = '*'; @@ -1696,7 +1689,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return string|null */ function getCalendarObjectByUID($principalUri, $uid) { - $query = $this->db->getQueryBuilder(); $query->selectAlias('c.uri', 'calendaruri')->selectAlias('co.uri', 'objecturi') ->from('calendarobjects', 'co') @@ -1789,7 +1781,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ]; if ($syncToken) { - $query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? AND `calendartype` = ? ORDER BY `synctoken`"; if ($limit>0) { $query.= " LIMIT " . (int)$limit; @@ -1803,15 +1794,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription // This loop ensures that any duplicates are overwritten, only the // last change on a node is relevant. - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $changes[$row['uri']] = $row['operation']; - } - foreach($changes as $uri => $operation) { - - switch($operation) { + foreach ($changes as $uri => $operation) { + switch ($operation) { case 1: $result['added'][] = $uri; break; @@ -1822,7 +1810,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $result['deleted'][] = $uri; break; } - } } else { // No synctoken supplied, this is the initial sync. @@ -1833,7 +1820,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN); } return $result; - } /** @@ -1885,8 +1871,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt =$query->execute(); $subscriptions = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $subscription = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -1898,14 +1883,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', ]; - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { + foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) { if (!is_null($row[$dbName])) { $subscription[$xmlName] = $row[$dbName]; } } $subscriptions[] = $subscription; - } return $subscriptions; @@ -1923,7 +1907,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return mixed */ function createSubscription($principalUri, $uri, array $properties) { - if (!isset($properties['{http://calendarserver.org/ns/}source'])) { throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions'); } @@ -1937,11 +1920,11 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments']; - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { + foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) { if (array_key_exists($xmlName, $properties)) { - $values[$dbName] = $properties[$xmlName]; - if (in_array($dbName, $propertiesBoolean)) { - $values[$dbName] = true; + $values[$dbName] = $properties[$xmlName]; + if (in_array($dbName, $propertiesBoolean)) { + $values[$dbName] = true; } } } @@ -1994,10 +1977,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @suppress SqlInjectionChecker */ $propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) { - $newValues = []; - foreach($mutations as $propertyName=>$propertyValue) { + foreach ($mutations as $propertyName=>$propertyValue) { if ($propertyName === '{http://calendarserver.org/ns/}source') { $newValues['source'] = $propertyValue->getHref(); } else { @@ -2009,7 +1991,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $query = $this->db->getQueryBuilder(); $query->update('calendarsubscriptions') ->set('lastmodified', $query->createNamedParameter(time())); - foreach($newValues as $fieldName=>$value) { + foreach ($newValues as $fieldName=>$value) { $query->set($fieldName, $query->createNamedParameter($value)); } $query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId))) @@ -2024,7 +2006,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ])); return true; - }); } @@ -2090,7 +2071,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if(!$row) { + if (!$row) { return null; } @@ -2122,7 +2103,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->execute(); $result = []; - foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = [ 'calendardata' => $row['calendardata'], 'uri' => $row['uri'], @@ -2205,7 +2186,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt->execute([ $calendarId ]); - } /** @@ -2224,7 +2204,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return array */ public function getDenormalizedData($calendarData) { - $vObject = Reader::read($calendarData); $componentType = null; $component = null; @@ -2232,7 +2211,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $lastOccurrence = null; $uid = null; $classification = self::CLASSIFICATION_PUBLIC; - foreach($vObject->getComponents() as $component) { + foreach ($vObject->getComponents() as $component) { if ($component->name!=='VTIMEZONE') { $componentType = $component->name; $uid = (string)$component->UID; @@ -2266,14 +2245,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $lastOccurrence = $maxDate->getTimestamp(); } else { $end = $it->getDtEnd(); - while($it->valid() && $end < $maxDate) { + while ($it->valid() && $end < $maxDate) { $end = $it->getDtEnd(); $it->next(); - } $lastOccurrence = $end->getTimestamp(); } - } } @@ -2297,7 +2274,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription 'uid' => $uid, 'classification' => $classification ]; - } /** @@ -2346,7 +2322,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return string|null */ public function setPublishStatus($value, $calendar) { - $calendarId = $calendar->getResourceId(); $this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent( '\OCA\DAV\CalDAV\CalDavBackend::updateShares', @@ -2490,7 +2465,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->execute(); $ids = $result->fetchAll(); - foreach($ids as $id) { + foreach ($ids as $id) { $this->deleteCalendar($id['id']); } } @@ -2507,7 +2482,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt = $query->execute(); $uris = []; - foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $uris[] = $row['uri']; } $stmt->closeCursor(); @@ -2528,7 +2503,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION))) ->execute(); - foreach($uris as $uri) { + foreach ($uris as $uri) { $this->addChange($subscriptionId, $uri, 3, self::CALENDAR_TYPE_SUBSCRIPTION); } } @@ -2540,8 +2515,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @param string $uriOrigin * @param string $uriDestination */ - public function moveCalendar($uriName, $uriOrigin, $uriDestination) - { + public function moveCalendar($uriName, $uriOrigin, $uriDestination) { $query = $this->db->getQueryBuilder(); $query->update('calendars') ->set('principaluri', $query->createNamedParameter($uriDestination)) diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php index 1c7e0106fb6..11b4bfe2c1d 100644 --- a/apps/dav/lib/CalDAV/Calendar.php +++ b/apps/dav/lib/CalDAV/Calendar.php @@ -280,7 +280,6 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { } public function getChild($name) { - $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name); if (!$obj) { @@ -294,11 +293,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { $obj['acl'] = $this->getChildACL(); return new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj); - } public function getChildren() { - $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); $children = []; foreach ($objs as $obj) { @@ -309,11 +306,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { $children[] = new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj); } return $children; - } public function getMultipleChildren(array $paths) { - $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths); $children = []; foreach ($objs as $obj) { @@ -324,7 +319,6 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { $children[] = new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj); } return $children; - } public function childExists($name) { @@ -340,7 +334,6 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { } public function calendarQuery(array $filters) { - $uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); if ($this->isShared()) { return array_filter($uris, function ($uri) { diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index 24121e4fff5..9c7521cb6ba 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -101,7 +101,7 @@ class CalendarImpl implements ICalendar { $permissions = $this->calendar->getACL(); $result = 0; foreach ($permissions as $permission) { - switch($permission['privilege']) { + switch ($permission['privilege']) { case '{DAV:}read': $result |= Constants::PERMISSION_READ; break; diff --git a/apps/dav/lib/CalDAV/CalendarManager.php b/apps/dav/lib/CalDAV/CalendarManager.php index b7fff47347f..5b237b0f060 100644 --- a/apps/dav/lib/CalDAV/CalendarManager.php +++ b/apps/dav/lib/CalDAV/CalendarManager.php @@ -66,7 +66,7 @@ class CalendarManager { * @param array $calendars */ private function register(IManager $cm, array $calendars) { - foreach($calendars as $calendarInfo) { + foreach ($calendars as $calendarInfo) { $calendar = new Calendar($this->backend, $calendarInfo, $this->l10n, $this->config); $cm->registerCalendar(new CalendarImpl( $calendar, diff --git a/apps/dav/lib/CalDAV/CalendarObject.php b/apps/dav/lib/CalDAV/CalendarObject.php index 9a402d3bf2c..8bdde256628 100644 --- a/apps/dav/lib/CalDAV/CalendarObject.php +++ b/apps/dav/lib/CalDAV/CalendarObject.php @@ -96,19 +96,19 @@ class CalendarObject extends \Sabre\CalDAV\CalendarObject { private function createConfidentialObject(Component\VCalendar $vObject) { /** @var Component $vElement */ $vElement = null; - if(isset($vObject->VEVENT)) { + if (isset($vObject->VEVENT)) { $vElement = $vObject->VEVENT; } - if(isset($vObject->VJOURNAL)) { + if (isset($vObject->VJOURNAL)) { $vElement = $vObject->VJOURNAL; } - if(isset($vObject->VTODO)) { + if (isset($vObject->VTODO)) { $vElement = $vObject->VTODO; } - if(!is_null($vElement)) { + if (!is_null($vElement)) { foreach ($vElement->children() as &$property) { /** @var Property $property */ - switch($property->name) { + switch ($property->name) { case 'CREATED': case 'DTSTART': case 'RRULE': @@ -136,7 +136,7 @@ class CalendarObject extends \Sabre\CalDAV\CalendarObject { private function removeVAlarms(Component\VCalendar $vObject) { $subcomponents = $vObject->getComponents(); - foreach($subcomponents as $subcomponent) { + foreach ($subcomponents as $subcomponent) { unset($subcomponent->VALARM); } } diff --git a/apps/dav/lib/CalDAV/CalendarRoot.php b/apps/dav/lib/CalDAV/CalendarRoot.php index b7cceec5bd1..ace8482d9c7 100644 --- a/apps/dav/lib/CalDAV/CalendarRoot.php +++ b/apps/dav/lib/CalDAV/CalendarRoot.php @@ -26,7 +26,6 @@ namespace OCA\DAV\CalDAV; class CalendarRoot extends \Sabre\CalDAV\CalendarRoot { - function getChildForPrincipal(array $principal) { return new CalendarHome($this->caldavBackend, $principal); } diff --git a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php index 9f4a84e24c5..52e9c330b2f 100644 --- a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php +++ b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php @@ -93,5 +93,4 @@ class ICSExportPlugin extends \Sabre\CalDAV\ICSExportPlugin { return $vcalendar; } - } diff --git a/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php b/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php index 88d43f0bb55..a42c704f53c 100644 --- a/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php +++ b/apps/dav/lib/CalDAV/Integration/ExternalCalendar.php @@ -89,7 +89,6 @@ abstract class ExternalCalendar implements CalDAV\ICalendar, DAV\IProperties { */ final public function createDirectory($name) { throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed'); - } /** diff --git a/apps/dav/lib/CalDAV/Integration/ICalendarProvider.php b/apps/dav/lib/CalDAV/Integration/ICalendarProvider.php index b15468e460d..298d877f5da 100644 --- a/apps/dav/lib/CalDAV/Integration/ICalendarProvider.php +++ b/apps/dav/lib/CalDAV/Integration/ICalendarProvider.php @@ -67,5 +67,4 @@ interface ICalendarProvider { * @return ExternalCalendar|null Calendar if it exists, null otherwise */ public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar; - } diff --git a/apps/dav/lib/CalDAV/Plugin.php b/apps/dav/lib/CalDAV/Plugin.php index b7569cac8a4..6d88244bbf1 100644 --- a/apps/dav/lib/CalDAV/Plugin.php +++ b/apps/dav/lib/CalDAV/Plugin.php @@ -25,7 +25,6 @@ namespace OCA\DAV\CalDAV; class Plugin extends \Sabre\CalDAV\Plugin { - const SYSTEM_CALENDAR_ROOT = 'system-calendars'; /** @@ -52,5 +51,4 @@ class Plugin extends \Sabre\CalDAV\Plugin { return self::SYSTEM_CALENDAR_ROOT . '/calendar-rooms/' . $principalId; } } - } diff --git a/apps/dav/lib/CalDAV/Principal/Collection.php b/apps/dav/lib/CalDAV/Principal/Collection.php index fe345d24801..6e7e20223c8 100644 --- a/apps/dav/lib/CalDAV/Principal/Collection.php +++ b/apps/dav/lib/CalDAV/Principal/Collection.php @@ -39,5 +39,4 @@ class Collection extends \Sabre\CalDAV\Principal\Collection { function getChildForPrincipal(array $principalInfo) { return new User($this->principalBackend, $principalInfo); } - } diff --git a/apps/dav/lib/CalDAV/Principal/User.php b/apps/dav/lib/CalDAV/Principal/User.php index 916dc17ec61..f10773769ca 100644 --- a/apps/dav/lib/CalDAV/Principal/User.php +++ b/apps/dav/lib/CalDAV/Principal/User.php @@ -51,5 +51,4 @@ class User extends \Sabre\CalDAV\Principal\User { ]; return $acl; } - } diff --git a/apps/dav/lib/CalDAV/Proxy/ProxyMapper.php b/apps/dav/lib/CalDAV/Proxy/ProxyMapper.php index df48b9127cc..bc13efc1e5a 100644 --- a/apps/dav/lib/CalDAV/Proxy/ProxyMapper.php +++ b/apps/dav/lib/CalDAV/Proxy/ProxyMapper.php @@ -36,7 +36,6 @@ use OCP\IDBConnection; * @package OCA\DAV\CalDAV\Proxy */ class ProxyMapper extends QBMapper { - const PERMISSION_READ = 1; const PERMISSION_WRITE = 2; diff --git a/apps/dav/lib/CalDAV/PublicCalendarRoot.php b/apps/dav/lib/CalDAV/PublicCalendarRoot.php index 17d0d06711c..a79fffa598a 100644 --- a/apps/dav/lib/CalDAV/PublicCalendarRoot.php +++ b/apps/dav/lib/CalDAV/PublicCalendarRoot.php @@ -53,7 +53,6 @@ class PublicCalendarRoot extends Collection { $this->caldavBackend = $caldavBackend; $this->l10n = $l10n; $this->config = $config; - } /** diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php index 61373327c6c..00dee6b0907 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php @@ -44,7 +44,7 @@ use Sabre\VObject\Property; * * @package OCA\DAV\CalDAV\Reminder\NotificationProvider */ -abstract class AbstractProvider implements INotificationProvider { +abstract class AbstractProvider implements INotificationProvider { /** @var string */ public const NOTIFICATION_TYPE = ''; diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php index 3893d24d802..b675b09e427 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php @@ -99,7 +99,7 @@ class EmailProvider extends AbstractProvider { $sortedByLanguage = $this->sortEMailAddressesByLanguage($emailAddresses, $fallbackLanguage); $organizer = $this->getOrganizerEMailAndNameFromEvent($vevent); - foreach($sortedByLanguage as $lang => $emailAddresses) { + foreach ($sortedByLanguage as $lang => $emailAddresses) { if (!$this->hasL10NForLang($lang)) { $lang = $fallbackLanguage; } @@ -212,7 +212,7 @@ class EmailProvider extends AbstractProvider { string $defaultLanguage):array { $sortedByLanguage = []; - foreach($emails as $emailAddress => $parameters) { + foreach ($emails as $emailAddress => $parameters) { if (isset($parameters['LANG'])) { $lang = $parameters['LANG']; } else { @@ -260,7 +260,7 @@ class EmailProvider extends AbstractProvider { } $emailAddressesOfDelegates = $delegates->getParts(); - foreach($emailAddressesOfDelegates as $addressesOfDelegate) { + foreach ($emailAddressesOfDelegates as $addressesOfDelegate) { if (strcasecmp($addressesOfDelegate, 'mailto:') === 0) { $emailAddresses[substr($addressesOfDelegate, 7)] = []; } @@ -345,7 +345,7 @@ class EmailProvider extends AbstractProvider { private function getEMailAddressesOfAllUsersWithWriteAccessToCalendar(array $users):array { $emailAddresses = []; - foreach($users as $user) { + foreach ($users as $user) { $emailAddress = $user->getEMailAddress(); if ($emailAddress) { $lang = $this->getLangForUser($user); diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php index c83865d1eea..e6c41d02ac4 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php @@ -39,5 +39,4 @@ class ProviderNotAvailableException extends \Exception { public function __construct(string $type) { parent::__construct("No notification provider for type $type available"); } - } diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php index 0074b5c201c..f3da0c03a68 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php @@ -97,7 +97,7 @@ class PushProvider extends AbstractProvider { // Empty Notification ObjectId will be catched by OC\Notification\Notification $eventUUIDHash = $eventUUID ? hash('sha256', $eventUUID, false) : ''; - foreach($users as $user) { + foreach ($users as $user) { /** @var INotification $notification */ $notification = $this->manager->createNotification(); $notification->setApp(Application::APP_ID) diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php b/apps/dav/lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php index 2f182937a93..1b144fdbbf0 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationTypeDoesNotExistException.php @@ -38,5 +38,4 @@ class NotificationTypeDoesNotExistException extends \Exception { public function __construct(string $type) { parent::__construct("Type $type is not an accepted type of notification"); } - } diff --git a/apps/dav/lib/CalDAV/Reminder/Notifier.php b/apps/dav/lib/CalDAV/Reminder/Notifier.php index c436d4fc329..93390f537ef 100644 --- a/apps/dav/lib/CalDAV/Reminder/Notifier.php +++ b/apps/dav/lib/CalDAV/Reminder/Notifier.php @@ -110,7 +110,7 @@ class Notifier implements INotifier { $this->l10n = $this->l10nFactory->get('dav', $languageCode); // Handle notifier subjects - switch($notification->getSubject()) { + switch ($notification->getSubject()) { case 'calendar_reminder': return $this->prepareReminderNotification($notification); diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index 48feaa0c589..7cf2d52768d 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -111,7 +111,7 @@ class ReminderService { public function processReminders():void { $reminders = $this->backend->getRemindersToProcess(); - foreach($reminders as $reminder) { + foreach ($reminders as $reminder) { $calendarData = is_resource($reminder['calendardata']) ? stream_get_contents($reminder['calendardata']) : $reminder['calendardata']; @@ -163,7 +163,7 @@ class ReminderService { return; } - switch($action) { + switch ($action) { case '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject': $this->onCalendarObjectCreate($objectData); break; @@ -206,14 +206,14 @@ class ReminderService { $now = $this->timeFactory->getDateTime(); $isRecurring = $masterItem ? $this->isRecurring($masterItem) : false; - foreach($recurrenceExceptions as $recurrenceException) { + foreach ($recurrenceExceptions as $recurrenceException) { $eventHash = $this->getEventHash($recurrenceException); if (!isset($recurrenceException->VALARM)) { continue; } - foreach($recurrenceException->VALARM as $valarm) { + foreach ($recurrenceException->VALARM as $valarm) { /** @var VAlarm $valarm */ $alarmHash = $this->getAlarmHash($valarm); $triggerTime = $valarm->getEffectiveTriggerTime(); @@ -237,7 +237,7 @@ class ReminderService { return; } - foreach($masterItem->VALARM as $valarm) { + foreach ($masterItem->VALARM as $valarm) { $masterAlarms[] = $this->getAlarmHash($valarm); } @@ -250,7 +250,7 @@ class ReminderService { return; } - while($iterator->valid() && count($processedAlarms) < count($masterAlarms)) { + while ($iterator->valid() && count($processedAlarms) < count($masterAlarms)) { $event = $iterator->getEventObject(); // Recurrence-exceptions are handled separately, so just ignore them here @@ -259,7 +259,7 @@ class ReminderService { continue; } - foreach($event->VALARM as $valarm) { + foreach ($event->VALARM as $valarm) { /** @var VAlarm $valarm */ $alarmHash = $this->getAlarmHash($valarm); if (\in_array($alarmHash, $processedAlarms, true)) { @@ -365,7 +365,7 @@ class ReminderService { ]; $repeat = isset($valarm->REPEAT) ? (int) $valarm->REPEAT->getValue() : 0; - for($i = 0; $i < $repeat; $i++) { + for ($i = 0; $i < $repeat; $i++) { if ($valarm->DURATION === null) { continue; } @@ -394,7 +394,7 @@ class ReminderService { * @param array $reminders */ private function writeRemindersToDatabase(array $reminders): void { - foreach($reminders as $reminder) { + foreach ($reminders as $reminder) { $this->backend->insertReminder( (int) $reminder['calendar_id'], (int) $reminder['object_id'], @@ -422,7 +422,6 @@ class ReminderService { !$reminder['is_recurring'] || !$reminder['is_relative'] || $reminder['is_recurrence_exception']) { - $this->backend->removeReminder($reminder['id']); return; } @@ -440,7 +439,7 @@ class ReminderService { return; } - while($iterator->valid()) { + while ($iterator->valid()) { $event = $iterator->getEventObject(); // Recurrence-exceptions are handled separately, so just ignore them here @@ -455,7 +454,7 @@ class ReminderService { continue; } - foreach($event->VALARM as $valarm) { + foreach ($event->VALARM as $valarm) { /** @var VAlarm $valarm */ $alarmHash = $this->getAlarmHash($valarm); if ($alarmHash !== $reminder['alarm_hash']) { @@ -608,7 +607,7 @@ class ReminderService { // Handle recurrence-exceptions first, because recurrence-expansion is expensive if ($isRecurrenceException) { - foreach($recurrenceExceptions as $recurrenceException) { + foreach ($recurrenceExceptions as $recurrenceException) { if ($this->getEffectiveRecurrenceIdOfVEvent($recurrenceException) === $recurrenceId) { return $recurrenceException; } @@ -678,7 +677,7 @@ class ReminderService { try { return VObject\Reader::read($calendarData, VObject\Reader::OPTION_FORGIVING); - } catch(ParseException $ex) { + } catch (ParseException $ex) { return null; } } @@ -707,7 +706,7 @@ class ReminderService { private function getAllVEventsFromVCalendar(VObject\Component\VCalendar $vcalendar):array { $vevents = []; - foreach($vcalendar->children() as $child) { + foreach ($vcalendar->children() as $child) { if (!($child instanceof VObject\Component)) { continue; } diff --git a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php index 96b4371bd7c..2a28c9fc02c 100644 --- a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php +++ b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php @@ -125,7 +125,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); $metaDataById = []; - foreach($metaDataRows as $metaDataRow) { + foreach ($metaDataRows as $metaDataRow) { if (!isset($metaDataById[$metaDataRow[$this->dbForeignKeyName]])) { $metaDataById[$metaDataRow[$this->dbForeignKeyName]] = []; } @@ -134,7 +134,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $metaDataRow['value']; } - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $id = $row['id']; if (isset($metaDataById[$id])) { @@ -142,7 +142,6 @@ abstract class AbstractPrincipalBackend implements BackendInterface { } else { $principals[] = $this->rowToPrincipal($row); } - } $stmt->closeCursor(); @@ -175,7 +174,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $stmt = $query->execute(); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if(!$row) { + if (!$row) { return null; } @@ -187,7 +186,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); $metadata = []; - foreach($metaDataRows as $metaDataRow) { + foreach ($metaDataRows as $metaDataRow) { $metadata[$metaDataRow['key']] = $metaDataRow['value']; } @@ -206,7 +205,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $stmt = $query->execute(); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if(!$row) { + if (!$row) { return null; } @@ -218,7 +217,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC); $metadata = []; - foreach($metaDataRows as $metaDataRow) { + foreach ($metaDataRows as $metaDataRow) { $metadata[$metaDataRow['key']] = $metaDataRow['value']; } @@ -265,7 +264,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $stmt = $query->execute(); $principals = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { if (!$this->isAllowedToAccessResource($row, $usersGroups)) { continue; } @@ -284,7 +283,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $stmt = $query->execute(); $principals = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { if (!$this->isAllowedToAccessResource($row, $usersGroups)) { continue; } @@ -352,7 +351,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $stmt = $query->execute(); $rows = []; - while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $id = $row[$this->dbForeignKeyName]; $principalRow = $this->getPrincipalById($id); @@ -388,7 +387,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $stmt = $query->execute(); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if(!$row) { + if (!$row) { return null; } if (!$this->isAllowedToAccessResource($row, $usersGroups)) { @@ -415,7 +414,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { $stmt = $query->execute(); $row = $stmt->fetch(\PDO::FETCH_ASSOC); - if(!$row) { + if (!$row) { return null; } if (!$this->isAllowedToAccessResource($row, $usersGroups)) { diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 1e7d66d0772..15228f9bc3d 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -316,7 +316,7 @@ class IMipPlugin extends SabreIMipPlugin { $this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]); $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; } - } catch(\Exception $ex) { + } catch (\Exception $ex) { $this->logger->logException($ex, ['app' => 'dav']); $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; } @@ -358,10 +358,9 @@ class IMipPlugin extends SabreIMipPlugin { $lastOccurrence = $maxDate->getTimestamp(); } else { $end = $it->getDtEnd(); - while($it->valid() && $end < $maxDate) { + while ($it->valid() && $end < $maxDate) { $end = $it->getDtEnd(); $it->next(); - } $lastOccurrence = $end->getTimestamp(); } diff --git a/apps/dav/lib/CalDAV/Search/SearchPlugin.php b/apps/dav/lib/CalDAV/Search/SearchPlugin.php index 86aef36482b..dc3cbdf06ba 100644 --- a/apps/dav/lib/CalDAV/Search/SearchPlugin.php +++ b/apps/dav/lib/CalDAV/Search/SearchPlugin.php @@ -142,7 +142,6 @@ class SearchPlugin extends ServerPlugin { // If we're dealing with the calendar home, the calendar home itself is // responsible for the calendar-query if ($node instanceof CalendarHome && $depth === 2) { - $nodePaths = $node->calendarSearch($report->filters, $report->limit, $report->offset); foreach ($nodePaths as $path) { diff --git a/apps/dav/lib/CalDAV/Search/Xml/Filter/ParamFilter.php b/apps/dav/lib/CalDAV/Search/Xml/Filter/ParamFilter.php index ac26e9f94c8..10b065fc426 100644 --- a/apps/dav/lib/CalDAV/Search/Xml/Filter/ParamFilter.php +++ b/apps/dav/lib/CalDAV/Search/Xml/Filter/ParamFilter.php @@ -45,7 +45,6 @@ class ParamFilter implements XmlDeserializable { if (!is_string($property)) { throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); - } if (!is_string($parameter)) { throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); diff --git a/apps/dav/lib/CalDAV/WebcalCaching/Plugin.php b/apps/dav/lib/CalDAV/WebcalCaching/Plugin.php index 783c73968be..2cfeb1108f1 100644 --- a/apps/dav/lib/CalDAV/WebcalCaching/Plugin.php +++ b/apps/dav/lib/CalDAV/WebcalCaching/Plugin.php @@ -111,7 +111,7 @@ class Plugin extends ServerPlugin { } $calendarHome->enableCachedSubscriptionsForThisRequest(); - } catch(NotFound $ex) { + } catch (NotFound $ex) { return; } } diff --git a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php index d00e0886b61..fadf61fd7de 100644 --- a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php +++ b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php @@ -137,7 +137,7 @@ class RefreshWebcalService { $calendarData = $vObject->serialize(); try { $this->calDavBackend->createCalendarObject($subscription['id'], $uri, $calendarData, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION); - } catch(BadRequest $ex) { + } catch (BadRequest $ex) { $this->logger->logException($ex); } } @@ -148,7 +148,7 @@ class RefreshWebcalService { } $this->updateSubscription($subscription, $mutations); - } catch(ParseException $ex) { + } catch (ParseException $ex) { $subscriptionId = $subscription['id']; $this->logger->logException($ex); @@ -274,11 +274,11 @@ class RefreshWebcalService { $contentType = $response->getHeader('Content-Type'); $contentType = explode(';', $contentType, 2)[0]; - switch($contentType) { + switch ($contentType) { case 'application/calendar+json': try { $jCalendar = Reader::readJson($body, Reader::OPTION_FORGIVING); - } catch(Exception $ex) { + } catch (Exception $ex) { // In case of a parsing error return null $this->logger->debug("Subscription $subscriptionId could not be parsed"); return null; @@ -288,7 +288,7 @@ class RefreshWebcalService { case 'application/calendar+xml': try { $xCalendar = Reader::readXML($body); - } catch(Exception $ex) { + } catch (Exception $ex) { // In case of a parsing error return null $this->logger->debug("Subscription $subscriptionId could not be parsed"); return null; @@ -299,14 +299,14 @@ class RefreshWebcalService { default: try { $vCalendar = Reader::read($body); - } catch(Exception $ex) { + } catch (Exception $ex) { // In case of a parsing error return null $this->logger->debug("Subscription $subscriptionId could not be parsed"); return null; } return $vCalendar->serialize(); } - } catch(Exception $ex) { + } catch (Exception $ex) { $this->logger->logException($ex); $this->logger->warning("Subscription $subscriptionId could not be refreshed due to a network error"); @@ -349,7 +349,7 @@ class RefreshWebcalService { // check if new refresh rate is even valid try { DateTimeParser::parseDuration($newRefreshRate); - } catch(InvalidDataException $ex) { + } catch (InvalidDataException $ex) { return null; } |