@@ -28,6 +28,7 @@ use OCA\Deck\Db\Acl;
|
|||||||
use OCA\Deck\Db\Board;
|
use OCA\Deck\Db\Board;
|
||||||
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
|
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
|
||||||
use Sabre\DAV\Exception\Forbidden;
|
use Sabre\DAV\Exception\Forbidden;
|
||||||
|
use Sabre\DAV\Exception\NotFound;
|
||||||
use Sabre\DAV\PropPatch;
|
use Sabre\DAV\PropPatch;
|
||||||
|
|
||||||
class Calendar extends ExternalCalendar {
|
class Calendar extends ExternalCalendar {
|
||||||
@@ -66,24 +67,9 @@ class Calendar extends ExternalCalendar {
|
|||||||
'privilege' => '{DAV:}read',
|
'privilege' => '{DAV:}read',
|
||||||
'principal' => $this->getOwner(),
|
'principal' => $this->getOwner(),
|
||||||
'protected' => true,
|
'protected' => true,
|
||||||
],
|
]
|
||||||
[
|
|
||||||
'privilege' => '{DAV:}read',
|
|
||||||
'principal' => $this->getOwner() . '/calendar-proxy-write',
|
|
||||||
'protected' => true,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'privilege' => '{DAV:}read',
|
|
||||||
'principal' => $this->getOwner() . '/calendar-proxy-read',
|
|
||||||
'protected' => true,
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
if ($this->backend->checkBoardPermission($this->board->getId(), Acl::PERMISSION_EDIT)) {
|
if ($this->backend->checkBoardPermission($this->board->getId(), Acl::PERMISSION_MANAGE)) {
|
||||||
$acl[] = [
|
|
||||||
'privilege' => '{DAV:}write',
|
|
||||||
'principal' => $this->getOwner(),
|
|
||||||
'protected' => true,
|
|
||||||
];
|
|
||||||
$acl[] = [
|
$acl[] = [
|
||||||
'privilege' => '{DAV:}write-properties',
|
'privilege' => '{DAV:}write-properties',
|
||||||
'principal' => $this->getOwner(),
|
'principal' => $this->getOwner(),
|
||||||
@@ -109,7 +95,7 @@ class Calendar extends ExternalCalendar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function createFile($name, $data = null) {
|
public function createFile($name, $data = null) {
|
||||||
throw new \Sabre\DAV\Exception\Forbidden('Creating a new entry is not implemented');
|
throw new Forbidden('Creating a new entry is not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getChild($name) {
|
public function getChild($name) {
|
||||||
@@ -121,9 +107,10 @@ class Calendar extends ExternalCalendar {
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
if (count($card) > 0) {
|
if (count($card) > 0) {
|
||||||
return new CalendarObject($this, $name, $card[0], $this->backend);
|
return new CalendarObject($this, $name, $this->backend, $card[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw new NotFound('Node not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getChildren() {
|
public function getChildren() {
|
||||||
@@ -151,7 +138,7 @@ class Calendar extends ExternalCalendar {
|
|||||||
|
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
return null;
|
throw new Forbidden('Deleting an entry is not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastModified() {
|
public function getLastModified() {
|
||||||
@@ -171,7 +158,7 @@ class Calendar extends ExternalCalendar {
|
|||||||
foreach ($properties as $key => $value) {
|
foreach ($properties as $key => $value) {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case '{DAV:}displayname':
|
case '{DAV:}displayname':
|
||||||
if (mb_substr($value, 0, strlen('Deck: '))) {
|
if (mb_strpos($value, 'Deck: ') === 0) {
|
||||||
$value = mb_substr($value, strlen('Deck: '));
|
$value = mb_substr($value, strlen('Deck: '));
|
||||||
}
|
}
|
||||||
$this->board->setTitle($value);
|
$this->board->setTitle($value);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class CalendarObject implements ICalendarObject, IACL {
|
|||||||
/** @var VCalendar */
|
/** @var VCalendar */
|
||||||
private $calendarObject;
|
private $calendarObject;
|
||||||
|
|
||||||
public function __construct(Calendar $calendar, string $name, $sourceItem = null, DeckCalendarBackend $backend) {
|
public function __construct(Calendar $calendar, string $name, DeckCalendarBackend $backend, $sourceItem) {
|
||||||
$this->calendar = $calendar;
|
$this->calendar = $calendar;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->sourceItem = $sourceItem;
|
$this->sourceItem = $sourceItem;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace OCA\Deck\DAV;
|
|||||||
use OCA\DAV\CalDAV\Integration\ExternalCalendar;
|
use OCA\DAV\CalDAV\Integration\ExternalCalendar;
|
||||||
use OCA\DAV\CalDAV\Integration\ICalendarProvider;
|
use OCA\DAV\CalDAV\Integration\ICalendarProvider;
|
||||||
use OCA\Deck\Db\Board;
|
use OCA\Deck\Db\Board;
|
||||||
|
use Sabre\DAV\Exception\NotFound;
|
||||||
|
|
||||||
class CalendarPlugin implements ICalendarProvider {
|
class CalendarPlugin implements ICalendarProvider {
|
||||||
|
|
||||||
@@ -55,10 +56,13 @@ class CalendarPlugin implements ICalendarProvider {
|
|||||||
|
|
||||||
public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar {
|
public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar {
|
||||||
if ($this->hasCalendarInCalendarHome($principalUri, $calendarUri)) {
|
if ($this->hasCalendarInCalendarHome($principalUri, $calendarUri)) {
|
||||||
$board = $this->backend->getBoard((int)str_replace('board-', '', $calendarUri));
|
try {
|
||||||
return new Calendar($principalUri, $calendarUri, $board, $this->backend);
|
$board = $this->backend->getBoard((int)str_replace('board-', '', $calendarUri));
|
||||||
|
return new Calendar($principalUri, $calendarUri, $board, $this->backend);
|
||||||
|
} catch (NotFound $e) {
|
||||||
|
// We can just return null if we have no matching board
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ use OCA\Deck\Service\BoardService;
|
|||||||
use OCA\Deck\Service\CardService;
|
use OCA\Deck\Service\CardService;
|
||||||
use OCA\Deck\Service\PermissionService;
|
use OCA\Deck\Service\PermissionService;
|
||||||
use OCA\Deck\Service\StackService;
|
use OCA\Deck\Service\StackService;
|
||||||
|
use Sabre\DAV\Exception\NotFound;
|
||||||
|
|
||||||
class DeckCalendarBackend {
|
class DeckCalendarBackend {
|
||||||
|
|
||||||
@@ -62,7 +63,11 @@ class DeckCalendarBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getBoard(int $id): Board {
|
public function getBoard(int $id): Board {
|
||||||
return $this->boardService->find($id);
|
try {
|
||||||
|
return $this->boardService->find($id);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new NotFound('Board with id ' . $id . ' not found');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkBoardPermission(int $id, int $permission): bool {
|
public function checkBoardPermission(int $id, int $permission): bool {
|
||||||
|
|||||||
@@ -144,14 +144,9 @@ class Card extends RelationalEntity {
|
|||||||
return $label->getTitle();
|
return $label->getTitle();
|
||||||
}, $this->getLabels());
|
}, $this->getLabels());
|
||||||
}
|
}
|
||||||
foreach ($this->getAssignedUsers() as $user) {
|
|
||||||
$participant = $user->resolveParticipant();
|
|
||||||
// FIXME use proper uri
|
|
||||||
$event->add('ATTENDEE', 'https://localhost/remote.php/dav/principals/users/:' . $participant->getUID(), [ 'CN' => $participant->getDisplayName()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$event->SUMMARY = $this->getTitle();
|
$event->SUMMARY = $this->getTitle();
|
||||||
|
$event->DESCRIPTION = $this->getDescription();
|
||||||
$calendar->add($event);
|
$calendar->add($event);
|
||||||
return $calendar;
|
return $calendar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Stack extends RelationalEntity {
|
|||||||
$calendar = new VCalendar();
|
$calendar = new VCalendar();
|
||||||
$event = $calendar->createComponent('VTODO');
|
$event = $calendar->createComponent('VTODO');
|
||||||
$event->UID = 'deck-stack-' . $this->getId();
|
$event->UID = 'deck-stack-' . $this->getId();
|
||||||
$event->SUMMARY = '[Stack]: ' . $this->getTitle();
|
$event->SUMMARY = 'List : ' . $this->getTitle();
|
||||||
$calendar->add($event);
|
$calendar->add($event);
|
||||||
return $calendar;
|
return $calendar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ class BoardService {
|
|||||||
throw new BadRequestException('board id must be a number');
|
throw new BadRequestException('board id must be a number');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id);
|
||||||
if ($board->getDeletedAt() > 0) {
|
if ($board->getDeletedAt() > 0) {
|
||||||
throw new BadRequestException('This board has already been deleted');
|
throw new BadRequestException('This board has already been deleted');
|
||||||
@@ -377,7 +377,7 @@ class BoardService {
|
|||||||
throw new BadRequestException('board id must be a number');
|
throw new BadRequestException('board id must be a number');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id);
|
||||||
$board->setDeletedAt(0);
|
$board->setDeletedAt(0);
|
||||||
$board = $this->boardMapper->update($board);
|
$board = $this->boardMapper->update($board);
|
||||||
@@ -404,7 +404,7 @@ class BoardService {
|
|||||||
throw new BadRequestException('id must be a number');
|
throw new BadRequestException('id must be a number');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id);
|
||||||
$delete = $this->boardMapper->delete($board);
|
$delete = $this->boardMapper->delete($board);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user