39 lines
1.7 KiB
PHP
39 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\NuqloudMasterCalendar\DAV;
|
|
|
|
use Sabre\CalDAV\ICalendarObject;
|
|
use Sabre\DAV\Exception\Forbidden;
|
|
use Sabre\DAV\Exception\NotFound;
|
|
use Sabre\DAVACL\IACL;
|
|
use Sabre\VObject\Component\VCalendar;
|
|
|
|
class MasterCalendarObject implements ICalendarObject, IACL {
|
|
public function __construct(private MasterCalendar $calendar, private VCalendar $calendarData) {
|
|
}
|
|
|
|
public function getOwner(): string { return $this->calendar->getOwner(); }
|
|
public function getGroup(): ?string { return null; }
|
|
public function getACL(): array { return $this->calendar->getACL(); }
|
|
public function setACL(array $acl): void { throw new Forbidden('Setting ACL is not supported'); }
|
|
public function getSupportedPrivilegeSet(): ?array { return null; }
|
|
public function put($data): void { throw new Forbidden('Updating events is not supported'); }
|
|
public function get(): string { return $this->calendarData->serialize(); }
|
|
public function getContentType(): string { return 'text/calendar; charset=utf-8'; }
|
|
public function getETag(): string { return '"' . sha1($this->get()) . '"'; }
|
|
public function getSize(): int { return strlen($this->get()); }
|
|
public function delete(): void { throw new Forbidden('Deleting events is not supported'); }
|
|
public function setName($name): void { throw new Forbidden('Renaming events is not supported'); }
|
|
public function getLastModified(): ?int { return null; }
|
|
|
|
public function getName(): string {
|
|
$base = $this->calendarData->getBaseComponent();
|
|
if ($base === null || !isset($base->UID)) {
|
|
throw new NotFound('Calendar event is missing a UID');
|
|
}
|
|
return isset($base->{'X-FILENAME'}) ? (string)$base->{'X-FILENAME'} : (string)$base->UID . '.ics';
|
|
}
|
|
}
|