/** * @param ICalendar $calendar */ public function __construct(ICalendar $calendar) { $this->calendar = $calendar; $backend = $this->calendar->getBackend(); if (!$backend instanceof IBackend) { $identifier = implode('::', [$this->calendar->getUserId(), '?', $this->calendar->getPrivateUri()]); $this->logger->error('Backend of calendar \'' . $identifier . '\' not found'); } else { $this->cache = $backend->getObjectCache($calendar); try { $this->objectAPI = $backend->getObjectAPI($calendar); } catch (BackendUtils\Exception $ex) { //TODO } } }
/** * @param IDBConnection $db * @param ICalendar $calendar * @param ObjectFactory $factory * @param string $calendarTableName * @param string $objectTableName */ public function __construct(IDBConnection $db, ICalendar $calendar, ObjectFactory $factory, $calendarTableName = 'clndr_calendars', $objectTableName = 'clndr_objects') { parent::__construct($db, $calendarTableName, $objectTableName); $this->calendar = $calendar; $this->calendarId = parent::getCalendarId($calendar->getPrivateUri(), $calendar->getUserId()); $this->factory = $factory; }
/** * rescan objects that changed and update the corresponding cached calendars */ public function propagateChanges() { $changes = $this->getChanges(); $this->resetChanges(); if (empty($changes)) { return; } $backend = $this->calendar->getBackend(); $scanner = $backend->getObjectScanner($this->calendar); foreach ($changes as $objectUri) { $scanner->scanObject($objectUri); } $calendarScanner = $backend->getBackendCollection()->getScanner(); $backendId = $this->calendar->getBackend()->getId(); $privateUri = $this->calendar->getPrivateUri(); $userId = $this->calendar->getUserId(); $calendarScanner->scanCalendar($backendId, $privateUri, $userId); }
/** * @param IManager $contactsManager * @param ICalendar $calendar * @param IL10N $l10n * @param ObjectFactory $objectFactory */ public function __construct(IManager $contactsManager, ICalendar $calendar, IL10N $l10n, ObjectFactory $objectFactory) { parent::__construct($contactsManager); $this->calendar = $calendar; $this->l10n = $l10n; $this->factory = $objectFactory; $this->uri = $calendar->getPrivateUri(); $this->userId = $calendar->getUserId(); }
/** * {@inheritDoc} */ public function hasUpdated(ICalendar $calendar) { $privateUri = $calendar->getPrivateUri(); $userId = $calendar->getUserId(); $oldCalendar = $this->find($privateUri, $userId); return $calendar->getCtag() !== $oldCalendar->getCtag(); }
/** * Reset values that shall not be updated by the user directly * @param \OCA\Calendar\ICalendar &$new * @param \OCA\Calendar\ICalendar $old */ private function resetReadOnlyProperties(ICalendar &$new, ICalendar $old) { $new->setUserId($old->getUserId()); $new->setOwnerId($old->getOwnerId()); $new->setCruds($old->getCruds()); $new->setCtag($old->getCtag()); }
/** * @param ICalendar $n * @param ICalendar $o * @throws Exception */ private function checkForIllegalChanges(ICalendar $n, ICalendar $o) { if ($n->getUserId() !== $o->getUserId()) { throw new Exception('Not allowed to transfer calendar to another user!'); } if ($n->getBackend()->getId() !== $o->getBackend()->getId()) { throw new Exception('Not allowed to transfer calendar to another backend!'); } if ($n->getPublicUri() !== $o->getPublicUri()) { if ($this->cache->doesExist($n->getPublicUri(), $n->getUserId())) { throw new Exception('New URI is already assigned to another calendar!'); } } }
/** * @param ICalendar $calendar * @return array */ private function getCalendarSqlParams(ICalendar $calendar) { return [$calendar->getUserId(), $calendar->getDisplayname(), $calendar->getPrivateUri(), $calendar->getEnabled(), $calendar->getCtag(), $calendar->getOrder(), $calendar->getColor(), $this->getTypes($calendar->getComponents(), 'string')]; }
/** * @param ICalendar $calendar */ public function __construct(ICalendar $calendar) { $this->uri = $calendar->getPrivateUri(); $this->userId = $calendar->getUserId(); }