mirror of https://github.com/sualko/cloud_bbb
Merge pull request #295 from arawa/fix/289/admin_interface_displays_gid
fix: #289 admin interface displays groups gid instead of displaynamepull/298/head
commit
dede2b2857
|
@ -16,11 +16,13 @@ use OCP\AppFramework\Db\Entity;
|
|||
* @method void setMaxRooms(int $number)
|
||||
* @method void setMaxParticipants(int $number)
|
||||
* @method void setAllowRecording(bool $allow)
|
||||
* @method void setGroupName(string $groupName)
|
||||
*/
|
||||
class Restriction extends Entity implements JsonSerializable {
|
||||
public const ALL_ID = '';
|
||||
|
||||
protected $groupId;
|
||||
protected $groupName;
|
||||
protected $maxRooms = -1;
|
||||
protected $roomTypes = '[]';
|
||||
protected $maxParticipants = -1;
|
||||
|
@ -32,10 +34,15 @@ class Restriction extends Entity implements JsonSerializable {
|
|||
$this->addType('allowRecording', 'boolean');
|
||||
}
|
||||
|
||||
public function setGroupName(string $groupName) {
|
||||
$this->groupName = $groupName;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'groupId' => $this->groupId,
|
||||
'groupName' => $this->groupName,
|
||||
'maxRooms' => (int) $this->maxRooms,
|
||||
'roomTypes' => \json_decode($this->roomTypes),
|
||||
'maxParticipants' => (int) $this->maxParticipants,
|
||||
|
|
|
@ -19,8 +19,9 @@ class RestrictionMapper extends QBMapper {
|
|||
public function find(int $id): Restriction {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from($this->tableName)
|
||||
$qb->select('r.*', 'g.displayname as groupName')
|
||||
->from($this->tableName, 'r')
|
||||
->leftJoin('r', 'groups', 'g', $qb->expr()->eq('r.group_id', 'g.gid'))
|
||||
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
|
||||
|
||||
return $this->findEntity($qb);
|
||||
|
@ -33,8 +34,9 @@ class RestrictionMapper extends QBMapper {
|
|||
public function findByGroupId(string $groupId): Restriction {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from($this->tableName)
|
||||
$qb->select('r.*', 'g.displayname as groupName')
|
||||
->from($this->tableName, 'r')
|
||||
->leftJoin('r', 'groups', 'g', $qb->expr()->eq('r.group_id', 'g.gid'))
|
||||
->where($qb->expr()->eq('group_id', $qb->createNamedParameter($groupId)));
|
||||
|
||||
return $this->findEntity($qb);
|
||||
|
@ -46,8 +48,9 @@ class RestrictionMapper extends QBMapper {
|
|||
public function findByGroupIds(array $groupIds): array {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from($this->tableName)
|
||||
$qb->select('r.*', 'g.displayname as groupName')
|
||||
->from($this->tableName, 'r')
|
||||
->leftJoin('r', 'groups', 'g', $qb->expr()->eq('r.group_id', 'g.gid'))
|
||||
->where($qb->expr()->in('group_id', $qb->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY)));
|
||||
|
||||
/** @var array<Restriction> */
|
||||
|
@ -60,8 +63,9 @@ class RestrictionMapper extends QBMapper {
|
|||
public function findAll(): array {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from($this->tableName);
|
||||
$qb->select('r.*', 'g.displayname as groupName')
|
||||
->from($this->tableName, 'r')
|
||||
->leftJoin('r', 'groups', 'g', $qb->expr()->eq('r.group_id', 'g.gid'));
|
||||
|
||||
/** @var array<Restriction> */
|
||||
return $this->findEntities($qb);
|
||||
|
|
|
@ -9,13 +9,18 @@ use OCA\BigBlueButton\Db\RestrictionMapper;
|
|||
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\IGroupManager;
|
||||
|
||||
class RestrictionService {
|
||||
/** @var RestrictionMapper */
|
||||
private $mapper;
|
||||
|
||||
public function __construct(RestrictionMapper $mapper) {
|
||||
/** @var IGroupManager */
|
||||
private $groupManager;
|
||||
|
||||
public function __construct(RestrictionMapper $mapper, IGroupManager $groupManager) {
|
||||
$this->mapper = $mapper;
|
||||
$this->groupManager = $groupManager;
|
||||
}
|
||||
|
||||
public function findAll(): array {
|
||||
|
@ -78,6 +83,10 @@ class RestrictionService {
|
|||
$restriction = new Restriction();
|
||||
|
||||
$restriction->setGroupId($groupId);
|
||||
$group = $this->groupManager->get($groupId);
|
||||
if ($group) {
|
||||
$restriction->setGroupName($group->getDisplayName());
|
||||
}
|
||||
|
||||
return $this->mapper->insert($restriction);
|
||||
}
|
||||
|
|
|
@ -8,16 +8,19 @@ use OCA\BigBlueButton\Db\Restriction;
|
|||
use OCA\BigBlueButton\Db\RestrictionMapper;
|
||||
use OCA\BigBlueButton\Db\Room;
|
||||
use OCA\BigBlueButton\Service\RestrictionService;
|
||||
use OCP\IGroupManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RestrictionServiceTest extends TestCase {
|
||||
protected $mapper;
|
||||
protected $groupManager;
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void {
|
||||
$this->mapper = $this->createMock(RestrictionMapper::class);
|
||||
$this->groupManager = $this->createMock(IGroupManager::class);
|
||||
|
||||
$this->service = new RestrictionService($this->mapper);
|
||||
$this->service = new RestrictionService($this->mapper, $this->groupManager);
|
||||
}
|
||||
|
||||
public function testFindByGroupIds() {
|
||||
|
|
|
@ -20,6 +20,7 @@ export enum Access {
|
|||
export interface Restriction {
|
||||
id: number;
|
||||
groupId: string;
|
||||
groupName: string;
|
||||
maxRooms: number;
|
||||
roomTypes: string[];
|
||||
maxParticipants: number;
|
||||
|
|
|
@ -23,10 +23,10 @@ const RestrictionRoom: React.FC<Props> = (props) => {
|
|||
|
||||
function deleteRow(ev: MouseEvent) {
|
||||
ev.preventDefault();
|
||||
|
||||
const groupName = restriction.groupName || restriction.groupId;
|
||||
OC.dialogs.confirm(
|
||||
t('bbb', 'Are you sure you want to delete the restrictions for group "{name}"? This operation cannot be undone.', { name: restriction.groupId }),
|
||||
t('bbb', 'Delete restrictions for "{name}"?', { name: restriction.groupId }),
|
||||
t('bbb', 'Are you sure you want to delete the restrictions for group "{name}"? This operation cannot be undone.', { name: groupName }),
|
||||
t('bbb', 'Delete restrictions for "{name}"?', { name: groupName}),
|
||||
confirmed => {
|
||||
if (confirmed) {
|
||||
props.deleteRestriction(restriction.id);
|
||||
|
@ -42,7 +42,7 @@ const RestrictionRoom: React.FC<Props> = (props) => {
|
|||
|
||||
return (
|
||||
<tr>
|
||||
<td className="name">{restriction.groupId || t('bbb', 'All users')}</td>
|
||||
<td className="name">{restriction.groupName || restriction.groupId || t('bbb', 'All users')}</td>
|
||||
<td className="max-rooms bbb-shrink">
|
||||
{edit('maxRooms', 'number')}
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue