2020-06-15 17:23:53 +02:00
|
|
|
<?php
|
2020-06-19 09:28:58 +02:00
|
|
|
|
2020-06-15 17:23:53 +02:00
|
|
|
namespace OCA\BigBlueButton\Db;
|
|
|
|
|
|
|
|
use OCP\AppFramework\Db\DoesNotExistException;
|
|
|
|
use OCP\AppFramework\Db\QBMapper;
|
|
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
|
|
|
use OCP\IDBConnection;
|
|
|
|
|
2024-10-25 16:57:57 +02:00
|
|
|
/**
|
|
|
|
* @template-extends QBMapper<RoomShare>
|
|
|
|
*/
|
2020-06-19 09:28:58 +02:00
|
|
|
class RoomShareMapper extends QBMapper {
|
|
|
|
public function __construct(IDBConnection $db) {
|
2020-06-15 17:23:53 +02:00
|
|
|
parent::__construct($db, 'bbb_room_shares', RoomShare::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
|
|
|
* @throws DoesNotExistException
|
|
|
|
*/
|
2020-06-19 09:28:58 +02:00
|
|
|
public function find(int $id): RoomShare {
|
2020-06-15 17:23:53 +02:00
|
|
|
/* @var $qb IQueryBuilder */
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
$qb->select('*')
|
|
|
|
->from('bbb_room_shares')
|
|
|
|
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
|
2020-06-19 10:49:40 +02:00
|
|
|
|
|
|
|
/** @var RoomShare */
|
2020-06-15 17:23:53 +02:00
|
|
|
return $this->findEntity($qb);
|
|
|
|
}
|
|
|
|
|
2020-06-19 10:49:40 +02:00
|
|
|
/**
|
|
|
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
|
|
|
* @throws DoesNotExistException
|
|
|
|
*/
|
2020-06-19 09:28:58 +02:00
|
|
|
public function findByRoomAndEntity(int $roomId, string $shareWith, int $shareType): RoomShare {
|
2020-06-16 16:54:50 +02:00
|
|
|
/* @var $qb IQueryBuilder */
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
$qb->select('*')
|
|
|
|
->from('bbb_room_shares')
|
|
|
|
->where($qb->expr()->eq('room_id', $qb->createNamedParameter($roomId, IQueryBuilder::PARAM_INT)))
|
|
|
|
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($shareWith)))
|
|
|
|
->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter($shareType, IQueryBuilder::PARAM_INT)));
|
|
|
|
|
2020-06-19 10:49:40 +02:00
|
|
|
/** @var RoomShare */
|
2020-06-16 16:54:50 +02:00
|
|
|
return $this->findEntity($qb);
|
|
|
|
}
|
|
|
|
|
2020-09-24 11:05:51 +02:00
|
|
|
public function findByUserId(string $userId): array {
|
|
|
|
/* @var $qb IQueryBuilder */
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
$qb->select('*')
|
|
|
|
->from('bbb_room_shares')
|
|
|
|
->where($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)))
|
|
|
|
->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_USER, IQueryBuilder::PARAM_INT)));
|
|
|
|
|
|
|
|
/** @var array<RoomShare> */
|
|
|
|
return $this->findEntities($qb);
|
|
|
|
}
|
|
|
|
|
2020-06-19 10:49:40 +02:00
|
|
|
/**
|
|
|
|
* @return array<RoomShare>
|
|
|
|
*/
|
2020-06-19 09:28:58 +02:00
|
|
|
public function findAll(int $roomId): array {
|
2020-06-15 17:23:53 +02:00
|
|
|
/* @var $qb IQueryBuilder */
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
$qb->select('*')
|
|
|
|
->from('bbb_room_shares')
|
|
|
|
->where($qb->expr()->eq('room_id', $qb->createNamedParameter($roomId, IQueryBuilder::PARAM_INT)));
|
2020-06-19 10:49:40 +02:00
|
|
|
|
|
|
|
/** @var array<RoomShare> */
|
2020-06-15 17:23:53 +02:00
|
|
|
return $this->findEntities($qb);
|
|
|
|
}
|
|
|
|
}
|