|
|
|
@ -50,33 +50,19 @@ class Manager implements IManager {
|
|
|
|
|
/**
|
|
|
|
|
* @var ICalendar[] holds all registered calendars
|
|
|
|
|
*/
|
|
|
|
|
private $calendars = [];
|
|
|
|
|
private array $calendars = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var \Closure[] to call to load/register calendar providers
|
|
|
|
|
*/
|
|
|
|
|
private $calendarLoaders = [];
|
|
|
|
|
|
|
|
|
|
/** @var Coordinator */
|
|
|
|
|
private $coordinator;
|
|
|
|
|
|
|
|
|
|
/** @var ContainerInterface */
|
|
|
|
|
private $container;
|
|
|
|
|
|
|
|
|
|
/** @var LoggerInterface */
|
|
|
|
|
private $logger;
|
|
|
|
|
|
|
|
|
|
private ITimeFactory $timeFactory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(Coordinator $coordinator,
|
|
|
|
|
ContainerInterface $container,
|
|
|
|
|
LoggerInterface $logger,
|
|
|
|
|
ITimeFactory $timeFactory) {
|
|
|
|
|
$this->coordinator = $coordinator;
|
|
|
|
|
$this->container = $container;
|
|
|
|
|
$this->logger = $logger;
|
|
|
|
|
$this->timeFactory = $timeFactory;
|
|
|
|
|
private array $calendarLoaders = [];
|
|
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
|
private Coordinator $coordinator,
|
|
|
|
|
private ContainerInterface $container,
|
|
|
|
|
private LoggerInterface $logger,
|
|
|
|
|
private ITimeFactory $timeFactory,
|
|
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -92,7 +78,13 @@ class Manager implements IManager {
|
|
|
|
|
* @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs
|
|
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function search($pattern, array $searchProperties = [], array $options = [], $limit = null, $offset = null) {
|
|
|
|
|
public function search(
|
|
|
|
|
$pattern,
|
|
|
|
|
array $searchProperties = [],
|
|
|
|
|
array $options = [],
|
|
|
|
|
$limit = null,
|
|
|
|
|
$offset = null,
|
|
|
|
|
): array {
|
|
|
|
|
$this->loadCalendars();
|
|
|
|
|
$result = [];
|
|
|
|
|
foreach ($this->calendars as $calendar) {
|
|
|
|
@ -112,29 +104,25 @@ class Manager implements IManager {
|
|
|
|
|
* @return bool true if enabled, false if not
|
|
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function isEnabled() {
|
|
|
|
|
public function isEnabled(): bool {
|
|
|
|
|
return !empty($this->calendars) || !empty($this->calendarLoaders);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registers a calendar
|
|
|
|
|
*
|
|
|
|
|
* @param ICalendar $calendar
|
|
|
|
|
* @return void
|
|
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function registerCalendar(ICalendar $calendar) {
|
|
|
|
|
public function registerCalendar(ICalendar $calendar): void {
|
|
|
|
|
$this->calendars[$calendar->getKey()] = $calendar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unregisters a calendar
|
|
|
|
|
*
|
|
|
|
|
* @param ICalendar $calendar
|
|
|
|
|
* @return void
|
|
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function unregisterCalendar(ICalendar $calendar) {
|
|
|
|
|
public function unregisterCalendar(ICalendar $calendar): void {
|
|
|
|
|
unset($this->calendars[$calendar->getKey()]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -142,19 +130,18 @@ class Manager implements IManager {
|
|
|
|
|
* In order to improve lazy loading a closure can be registered which will be called in case
|
|
|
|
|
* calendars are actually requested
|
|
|
|
|
*
|
|
|
|
|
* @param \Closure $callable
|
|
|
|
|
* @return void
|
|
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function register(\Closure $callable) {
|
|
|
|
|
public function register(\Closure $callable): void {
|
|
|
|
|
$this->calendarLoaders[] = $callable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return ICalendar[]
|
|
|
|
|
*
|
|
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getCalendars() {
|
|
|
|
|
public function getCalendars(): array {
|
|
|
|
|
$this->loadCalendars();
|
|
|
|
|
|
|
|
|
|
return array_values($this->calendars);
|
|
|
|
@ -162,10 +149,10 @@ class Manager implements IManager {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* removes all registered calendar instances
|
|
|
|
|
* @return void
|
|
|
|
|
*
|
|
|
|
|
* @since 13.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function clear() {
|
|
|
|
|
public function clear(): void {
|
|
|
|
|
$this->calendars = [];
|
|
|
|
|
$this->calendarLoaders = [];
|
|
|
|
|
}
|
|
|
|
@ -173,7 +160,7 @@ class Manager implements IManager {
|
|
|
|
|
/**
|
|
|
|
|
* loads all calendars
|
|
|
|
|
*/
|
|
|
|
|
private function loadCalendars() {
|
|
|
|
|
private function loadCalendars(): void {
|
|
|
|
|
foreach ($this->calendarLoaders as $callable) {
|
|
|
|
|
$callable($this);
|
|
|
|
|
}
|
|
|
|
@ -181,8 +168,6 @@ class Manager implements IManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $principalUri
|
|
|
|
|
* @param array $calendarUris
|
|
|
|
|
* @return ICreateFromString[]
|
|
|
|
|
*/
|
|
|
|
|
public function getCalendarsForPrincipal(string $principalUri, array $calendarUris = []): array {
|
|
|
|
@ -240,7 +225,12 @@ class Manager implements IManager {
|
|
|
|
|
/**
|
|
|
|
|
* @throws \OCP\DB\Exception
|
|
|
|
|
*/
|
|
|
|
|
public function handleIMipReply(string $principalUri, string $sender, string $recipient, string $calendarData): bool {
|
|
|
|
|
public function handleIMipReply(
|
|
|
|
|
string $principalUri,
|
|
|
|
|
string $sender,
|
|
|
|
|
string $recipient,
|
|
|
|
|
string $calendarData,
|
|
|
|
|
): bool {
|
|
|
|
|
/** @var VCalendar $vObject */
|
|
|
|
|
$vObject = Reader::read($calendarData);
|
|
|
|
|
/** @var VEvent $vEvent */
|
|
|
|
@ -309,7 +299,13 @@ class Manager implements IManager {
|
|
|
|
|
* @since 25.0.0
|
|
|
|
|
* @throws \OCP\DB\Exception
|
|
|
|
|
*/
|
|
|
|
|
public function handleIMipCancel(string $principalUri, string $sender, ?string $replyTo, string $recipient, string $calendarData): bool {
|
|
|
|
|
public function handleIMipCancel(
|
|
|
|
|
string $principalUri,
|
|
|
|
|
string $sender,
|
|
|
|
|
?string $replyTo,
|
|
|
|
|
string $recipient,
|
|
|
|
|
string $calendarData,
|
|
|
|
|
): bool {
|
|
|
|
|
$vObject = Reader::read($calendarData);
|
|
|
|
|
/** @var VEvent $vEvent */
|
|
|
|
|
$vEvent = $vObject->{'VEVENT'};
|
|
|
|
|