mirror of https://github.com/sualko/cloud_bbb
fix: #289 admin interface displays groups gid instead of displayname
Signed-off-by: Sebastien Marinier <sebastien.marinier@arawa.fr>pull/295/head
parent
7233d21a85
commit
71fe272888
|
@ -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,10 @@ 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) {
|
||||
$this->mapper = $mapper;
|
||||
public function __construct(private RestrictionMapper $mapper, private IGroupManager $groupManager) {
|
||||
}
|
||||
|
||||
public function findAll(): array {
|
||||
|
@ -78,6 +75,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);
|
||||
}
|
||||
|
|
|
@ -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