migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,124 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Exceptions\CalendarDataNotFoundException;
use OCA\RelatedResources\Model\Calendar;
use OCA\RelatedResources\Model\CalendarShare;
class CalendarShareRequest extends CalendarShareRequestBuilder {
/**
* @param string $principalUri
* @param string $uri
*
* @return Calendar
* @throws CalendarDataNotFoundException
*/
public function getCalendarByUri(string $principalUri, string $uri): Calendar {
$qb = $this->getCalendarSelectSql();
$qb->limit('principaluri', $principalUri);
$qb->limit('uri', $uri);
return $this->getCalendarFromRequest($qb);
}
/**
* @param int $calendarId
*
* @return CalendarShare[]
*/
public function getSharesByCalendarId(int $calendarId): array {
$qb = $this->getCalendarShareSelectSql();
$qb->limit('type', 'calendar');
$qb->limitInt('resourceid', $calendarId);
return $this->getSharesFromRequest($qb);
}
/**
* @param string $singleId
*
* @return Calendar[]
*/
public function getCalendarAvailableToCircle(string $singleId): array {
$qb = $this->getCalendarSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_DAV_SHARE, 'ds',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ds.resourceid')
);
$qb->limit('type', 'calendar', 'ds');
$qb->limit('principaluri', 'principals/circles/' . $singleId, 'ds');
return $this->getCalendarsFromRequest($qb);
}
/**
* @param string $groupName
*
* @return Calendar[]
*/
public function getCalendarAvailableToGroup(string $groupName): array {
$qb = $this->getCalendarSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_DAV_SHARE, 'ds',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ds.resourceid')
);
$qb->limit('type', 'calendar', 'ds');
$qb->limit('principaluri', 'principals/groups/' . $groupName, 'ds');
return $this->getCalendarsFromRequest($qb);
}
/**
* @param string $userName
*
* @return Calendar[]
*/
public function getCalendarAvailableToUser(string $userName): array {
$qb = $this->getCalendarSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_DAV_SHARE, 'ds',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ds.resourceid')
);
$qb->limit('type', 'calendar', 'ds');
$qb->limit('principaluri', 'principals/users/' . $userName, 'ds');
return $this->getCalendarsFromRequest($qb);
}
}
@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Exceptions\CalendarDataNotFoundException;
use OCA\RelatedResources\Model\Calendar;
use OCA\RelatedResources\Model\CalendarShare;
use OCA\RelatedResources\Tools\Exceptions\InvalidItemException;
use OCA\RelatedResources\Tools\Exceptions\RowNotFoundException;
class CalendarShareRequestBuilder extends CoreQueryBuilder {
/**
* @return CoreRequestBuilder
*/
protected function getCalendarSelectSql(): CoreRequestBuilder {
$qb = $this->getQueryBuilder();
$qb->generateSelect(self::TABLE_CALENDARS, self::$externalTables[self::TABLE_CALENDARS]);
return $qb;
}
/**
* @return CoreRequestBuilder
*/
protected function getCalendarShareSelectSql(): CoreRequestBuilder {
$qb = $this->getQueryBuilder();
$qb->generateSelect(self::TABLE_DAV_SHARE, self::$externalTables[self::TABLE_DAV_SHARE]);
return $qb;
}
/**
* @param CoreRequestBuilder $qb
*
* @return Calendar
* @throws CalendarDataNotFoundException
*/
public function getCalendarFromRequest(CoreRequestBuilder $qb): Calendar {
/** @var Calendar $calendar */
try {
$calendar = $qb->asItem(Calendar::class);
} catch (InvalidItemException | RowNotFoundException $e) {
throw new CalendarDataNotFoundException();
}
return $calendar;
}
/**
* @param CoreRequestBuilder $qb
*
* @return Calendar[]
*/
public function getCalendarsFromRequest(CoreRequestBuilder $qb): array {
return $qb->asItems(Calendar::class);
}
/**
* @param CoreRequestBuilder $qb
*
* @return CalendarShare[]
*/
public function getSharesFromRequest(CoreRequestBuilder $qb): array {
return $qb->asItems(CalendarShare::class);
}
}
@@ -0,0 +1,120 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Service\ConfigService;
/**
*
*/
class CoreQueryBuilder {
public const TABLE_FILES_SHARE = 'share';
public const TABLE_DECK_SHARE = 'deck_board_acl';
public const TABLE_DECK_BOARD = 'deck_boards';
public const TABLE_TALK_ATTENDEE = 'talk_attendees';
public const TABLE_TALK_ROOM = 'talk_rooms';
public const TABLE_DAV_SHARE = 'dav_shares';
public const TABLE_CALENDARS = 'calendars';
public const TABLE_CAL_OBJECTS = 'calendarobjects';
public const TABLE_CAL_OBJ_PROPS = 'calendarobjects_props';
protected ConfigService $configService;
public static array $externalTables = [
self::TABLE_FILES_SHARE => [
'share_type',
'share_with',
'uid_owner',
'uid_initiator',
'file_source',
'file_target',
'stime'
],
self::TABLE_DECK_SHARE => [
'board_id',
'type',
'participant'
],
self::TABLE_DECK_BOARD => [
'id',
'title',
'owner',
'last_modified'
],
self::TABLE_TALK_ATTENDEE => [
'room_id',
'actor_type',
'actor_id'
],
self::TABLE_TALK_ROOM => [
'name',
'type',
'token'
],
self::TABLE_DAV_SHARE => [
'principaluri',
'resourceid'
],
self::TABLE_CALENDARS => [
'id',
'principaluri',
'uri',
'displayname'
],
self::TABLE_CAL_OBJECTS => [
'firstoccurence',
'lastoccurence'
],
self::TABLE_CAL_OBJ_PROPS => [
'value'
]
];
/**
* @param ConfigService $configService
*/
public function __construct(ConfigService $configService) {
$this->configService = $configService;
}
/**
* @return CoreRequestBuilder
*/
public function getQueryBuilder(): CoreRequestBuilder {
return new CoreRequestBuilder();
}
}
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@pontapreta.net>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Tools\Db\ExtendedQueryBuilder;
class CoreRequestBuilder extends ExtendedQueryBuilder {
public function __construct() {
parent::__construct();
}
}
@@ -0,0 +1,122 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Exceptions\DeckDataNotFoundException;
use OCA\RelatedResources\Model\DeckBoard;
use OCA\RelatedResources\Model\DeckShare;
use OCP\Share\IShare;
class DeckRequest extends DeckRequestBuilder {
/**
* @param int $itemId
*
* @return DeckBoard
* @throws DeckDataNotFoundException
*/
public function getBoardById(int $itemId): DeckBoard {
$qb = $this->getDeckBoardSelectSql();
$qb->limitInt('id', $itemId);
return $this->getDeckFromRequest($qb);
}
/**
* @param int $boardId
*
* @return DeckShare[]
*/
public function getSharesByBoardId(int $boardId): array {
$qb = $this->getDeckShareSelectSql();
$qb->limitInt('board_id', $boardId);
return $this->getSharesFromRequest($qb);
}
/**
* @param string $singleId
*
* @return DeckBoard[]
*/
public function getDeckAvailableToCircle(string $singleId): array {
$qb = $this->getDeckBoardSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_DECK_SHARE, 'ds',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ds.board_id')
);
$qb->limitInt('type', IShare::TYPE_CIRCLE, 'ds');
$qb->limit('participant', $singleId, 'ds');
return $this->getDecksFromRequest($qb);
}
/**
* @param string $groupName
*
* @return DeckBoard[]
*/
public function getDeckAvailableToGroup(string $groupName): array {
$qb = $this->getDeckBoardSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_DECK_SHARE, 'ds',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ds.board_id')
);
$qb->limitInt('type', IShare::TYPE_GROUP, 'ds');
$qb->limit('participant', $groupName, 'ds');
return $this->getDecksFromRequest($qb);
}
/**
* @param string $userName
*
* @return DeckBoard[]
*/
public function getDeckAvailableToUser(string $userName): array {
$qb = $this->getDeckBoardSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_DECK_SHARE, 'ds',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ds.board_id')
);
$qb->limitInt('type', IShare::TYPE_USER, 'ds');
$qb->limit('participant', $userName, 'ds');
return $this->getDecksFromRequest($qb);
}
}
@@ -0,0 +1,90 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Exceptions\DeckDataNotFoundException;
use OCA\RelatedResources\Model\DeckBoard;
use OCA\RelatedResources\Model\DeckShare;
use OCA\RelatedResources\Tools\Exceptions\InvalidItemException;
use OCA\RelatedResources\Tools\Exceptions\RowNotFoundException;
class DeckRequestBuilder extends CoreQueryBuilder {
/**
* @return CoreRequestBuilder
*/
protected function getDeckBoardSelectSql(): CoreRequestBuilder {
$qb = $this->getQueryBuilder();
$qb->generateSelect(self::TABLE_DECK_BOARD, self::$externalTables[self::TABLE_DECK_BOARD]);
return $qb;
}
protected function getDeckShareSelectSql(): CoreRequestBuilder {
$qb = $this->getQueryBuilder();
$qb->generateSelect(self::TABLE_DECK_SHARE, self::$externalTables[self::TABLE_DECK_SHARE]);
return $qb;
}
/**
* @param CoreRequestBuilder $qb
*
* @return DeckBoard
* @throws DeckDataNotFoundException
*/
public function getDeckFromRequest(CoreRequestBuilder $qb): DeckBoard {
/** @var DeckBoard $deck */
try {
$deck = $qb->asItem(DeckBoard::class);
} catch (InvalidItemException | RowNotFoundException $e) {
throw new DeckDataNotFoundException();
}
return $deck;
}
/**
* @param CoreRequestBuilder $qb
*
* @return DeckBoard[]
*/
public function getDecksFromRequest(CoreRequestBuilder $qb): array {
return $qb->asItems(DeckBoard::class);
}
/**
* @param CoreRequestBuilder $qb
*
* @return DeckShare[]
*/
public function getSharesFromRequest(CoreRequestBuilder $qb): array {
return $qb->asItems(DeckShare::class);
}
}
@@ -0,0 +1,103 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Model\FilesShare;
use OCP\Share\IShare;
class FilesShareRequest extends FilesShareRequestBuilder {
/**
* @param int $itemId
*
* @return FilesShare[]
*/
public function getSharesByItemId(int $itemId): array {
$qb = $this->getFilesShareSelectSql();
$qb->limitInt('file_source', $itemId);
return $this->getItemsFromRequest($qb);
}
/**
* @param array $itemIds
*
* @return FilesShare[]
*/
public function getSharesByItemIds(array $itemIds): array {
$qb = $this->getFilesShareSelectSql();
$qb->limitInArray('file_source', $itemIds);
return $this->getItemsFromRequest($qb);
}
/**
* @param string $singleId
*
* @return FilesShare[]
*/
public function getSharesToCircle(string $singleId): array {
$qb = $this->getFilesShareSelectSql();
$qb->limitInt('share_type', IShare::TYPE_CIRCLE);
$qb->limit('share_with', $singleId);
return $this->getItemsFromRequest($qb);
}
/**
* @param string $groupName
*
* @return FilesShare[]
*/
public function getSharesToGroup(string $groupName): array {
$qb = $this->getFilesShareSelectSql();
$qb->limitInt('share_type', IShare::TYPE_GROUP);
$qb->limit('share_with', $groupName);
return $this->getItemsFromRequest($qb);
}
/**
* @param string $userId
*
* @return FilesShare[]
*/
public function getSharesToUser(string $userId): array {
$qb = $this->getFilesShareSelectSql();
$qb->limitInt('share_type', IShare::TYPE_USER);
$qb->limit('share_with', $userId);
return $this->getItemsFromRequest($qb);
}
}
@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Exceptions\FilesShareNotFoundException;
use OCA\RelatedResources\Model\FilesShare;
use OCA\RelatedResources\Tools\Exceptions\InvalidItemException;
use OCA\RelatedResources\Tools\Exceptions\RowNotFoundException;
class FilesShareRequestBuilder extends CoreQueryBuilder {
/**
* @return CoreRequestBuilder
*/
protected function getFilesShareSelectSql(): CoreRequestBuilder {
$qb = $this->getQueryBuilder();
$qb->generateSelect(self::TABLE_FILES_SHARE, self::$externalTables[self::TABLE_FILES_SHARE]);
return $qb;
}
/**
* @param CoreRequestBuilder $qb
*
* @return FilesShare
* @throws FilesShareNotFoundException
*/
public function getItemFromRequest(CoreRequestBuilder $qb): FilesShare {
/** @var FilesShare $share */
try {
$share = $qb->asItem(FilesShare::class);
} catch (InvalidItemException | RowNotFoundException $e) {
throw new FilesShareNotFoundException();
}
return $share;
}
/**
* @param CoreRequestBuilder $qb
*
* @return FilesShare[]
*/
public function getItemsFromRequest(CoreRequestBuilder $qb): array {
return $qb->asItems(FilesShare::class);
}
}
@@ -0,0 +1,125 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Exceptions\TalkDataNotFoundException;
use OCA\RelatedResources\Model\TalkActor;
use OCA\RelatedResources\Model\TalkRoom;
class TalkRoomRequest extends TalkRoomRequestBuilder {
/**
* @param string $token
*
* @return TalkRoom
* @throws TalkDataNotFoundException
*/
public function getRoomByToken(string $token): TalkRoom {
$qb = $this->getTalkRoomSelectSql();
$qb->limit('token', $token);
return $this->getRoomFromRequest($qb);
}
/**
* @param string $token
*
* @return TalkActor[]
*/
public function getActorsByToken(string $token): array {
$qb = $this->getActorSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_TALK_ROOM, 'tr',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.room_id', 'tr.id')
);
$qb->limit('token', $token, 'tr');
return $this->getActorsFromRequest($qb);
}
/**
* @param string $singleId
*
* @return TalkRoom[]
*/
public function getRoomsAvailableToCircle(string $singleId): array {
$qb = $this->getTalkRoomSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_TALK_ATTENDEE, 'ta',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ta.room_id')
);
$qb->limit('actor_type', 'circles', 'ta');
$qb->limit('actor_id', $singleId, 'ta');
return $this->getRoomsFromRequest($qb);
}
/**
* @param string $groupName
*
* @return TalkRoom[]
*/
public function getRoomsAvailableToGroup(string $groupName): array {
$qb = $this->getTalkRoomSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_TALK_ATTENDEE, 'ta',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ta.room_id')
);
$qb->limit('actor_type', 'groups', 'ta');
$qb->limit('actor_id', $groupName, 'ta');
return $this->getRoomsFromRequest($qb);
}
/**
* @param string $userName
*
* @return TalkRoom[]
*/
public function getRoomsAvailableToUser(string $userName): array {
$qb = $this->getTalkRoomSelectSql();
$qb->innerJoin(
$qb->getDefaultSelectAlias(), self::TABLE_TALK_ATTENDEE, 'ta',
$qb->expr()->eq($qb->getDefaultSelectAlias() . '.id', 'ta.room_id')
);
$qb->limit('actor_type', 'users', 'ta');
$qb->limit('actor_id', $userName, 'ta');
return $this->getRoomsFromRequest($qb);
}
}
@@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Related Resources
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2022
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\RelatedResources\Db;
use OCA\RelatedResources\Exceptions\TalkDataNotFoundException;
use OCA\RelatedResources\Model\TalkActor;
use OCA\RelatedResources\Model\TalkRoom;
use OCA\RelatedResources\Tools\Exceptions\InvalidItemException;
use OCA\RelatedResources\Tools\Exceptions\RowNotFoundException;
class TalkRoomRequestBuilder extends CoreQueryBuilder {
/**
* @return CoreRequestBuilder
*/
protected function getTalkRoomSelectSql(): CoreRequestBuilder {
$qb = $this->getQueryBuilder();
$qb->generateSelect(self::TABLE_TALK_ROOM, self::$externalTables[self::TABLE_TALK_ROOM]);
return $qb;
}
protected function getActorSelectSql(): CoreRequestBuilder {
$qb = $this->getQueryBuilder();
$qb->generateSelect(self::TABLE_TALK_ATTENDEE, self::$externalTables[self::TABLE_TALK_ATTENDEE]);
return $qb;
}
/**
* @param CoreRequestBuilder $qb
*
* @return TalkRoom
* @throws TalkDataNotFoundException
*/
public function getRoomFromRequest(CoreRequestBuilder $qb): TalkRoom {
/** @var TalkRoom $room */
try {
$room = $qb->asItem(TalkRoom::class);
} catch (InvalidItemException | RowNotFoundException $e) {
throw new TalkDataNotFoundException();
}
return $room;
}
/**
* @param CoreRequestBuilder $qb
*
* @return TalkRoom[]
*/
public function getRoomsFromRequest(CoreRequestBuilder $qb): array {
return $qb->asItems(TalkRoom::class);
}
/**
* @param CoreRequestBuilder $qb
*
* @return TalkActor[]
*/
public function getActorsFromRequest(CoreRequestBuilder $qb): array {
return $qb->asItems(TalkActor::class);
}
}