/**
  * {@inheritDoc}
  */
 public function findAll($userId, $limit = null, $offset = null)
 {
     $calendars = [];
     foreach ($this->uris as $uri => $property) {
         $calendars[] = $this->find($uri, $userId);
     }
     return $this->factory->createCollectionFromEntities($calendars)->subset($limit, $offset);
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function formatItems($items, $format, $parameters = null)
 {
     $entities = [];
     foreach ($items as $item) {
         if (substr_count($item['item_source'], '::') === 0) {
             return false;
         }
         list($calendarId, $objectUri) = explode('::', $item['item_source'], 1);
         $ownerId = $item['uid_owner'];
         if ($format === Types::GROUPED) {
             if (!isset($entities[$ownerId])) {
                 $calendar = $this->factory->createEntity(['backend' => $this->sharingBackend, 'cruds' => Permissions::READ, 'privateUri' => 'objects::' . $ownerId, 'userId' => $item['share_with'], 'ownerId' => $ownerId, 'displayname' => strval($this->l10n->t('%s\'s events', [$ownerId])), 'color' => 'rgb(107, 107, 107)', 'components' => ObjectType::EVENT, 'enabled' => false, 'ctag' => 0], CalendarFactory::FORMAT_PARAM);
                 $entities[$ownerId] = ['calendar' => $calendar, 'ctag' => 0, 'objects' => []];
             }
             /** @var \OCA\Calendar\ICalendar $calendar */
             $calendar = $entities[$ownerId]['calendar'];
             $calendar->setCtag(max($calendar->getCtag(), $item['stime']));
             $entities[$ownerId]['objects'] = ['calendarId' => $calendarId, 'objectUri' => $objectUri, 'shareItem' => $item];
         } elseif ($format === Types::GROUPEDLIST) {
             $privateUri = 'object::' . $ownerId;
             if (!in_array($privateUri, $entities)) {
                 $entities[] = $privateUri;
             }
         }
     }
     return $entities;
 }
 /**
  * {@inheritDoc}
  */
 public function formatItems($items, $format, $parameters = null)
 {
     $entities = [];
     if ($format === Types::ENTITY) {
         foreach ($items as $item) {
             try {
                 $calendar = $this->calendars->find($item['item_source'], $item['uid_owner']);
             } catch (BusinessLayer\Exception $ex) {
                 $this->logger->debug($ex->getMessage());
                 continue;
             }
             $calendar->setId(null);
             $calendar->setBackend($this->sharingBackend);
             $calendar->setCruds($item['permissions']);
             $calendar->setPrivateUri('calendar::' . $item['item_source']);
             $calendar->setUserId($item['share_with']);
             $entities[] = $calendar;
         }
         return $this->factory->createCollectionFromEntities($entities);
     } elseif ($format === Types::ENTITYLIST) {
         foreach ($items as $item) {
             $entities[] = $item['item_source'];
         }
         return $entities;
     } else {
         return null;
     }
 }
 /**
  * @param \PDOStatement $result
  * @return \OCA\Calendar\ICalendarCollection
  */
 private function resultToCollection(\PDOStatement $result)
 {
     $entities = [];
     while ($row = $result->fetch()) {
         try {
             $entities[] = $this->rowToEntity($row);
         } catch (CorruptDataException $ex) {
             continue;
         }
     }
     return $this->factory->createCollectionFromEntities($entities);
 }