Skip to content

Commit

Permalink
Merge pull request #859 from hanazarraa/guest-policy-layout-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
GhaziTriki authored Aug 3, 2023
2 parents 87ad5dd + 3025f31 commit c70db95
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 9 deletions.
7 changes: 6 additions & 1 deletion bbbeasy-backend/app/src/Actions/PresetSettings/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use Actions\Base as BaseAction;
use Actions\RequirePrivilegeTrait;
use Enum\GuestPolicy;
use Enum\ResponseCode;
use Models\Preset;
use Models\PresetSetting;
Expand Down Expand Up @@ -75,7 +76,11 @@ public function save($f3, $params): void
}
// add enabled category from userSubCategories
if ($editedSubCategory['enabled'] && !property_exists($userSubCategories, $subCategoryName)) {
$userSubCategories->{$subCategoryName} = '';
if (\Enum\Presets\GuestPolicy::POLICY === $subCategoryName) {
$userSubCategories->{$subCategoryName} = GuestPolicy::ALWAYS_ACCEPT;
} else {
$userSubCategories->{$subCategoryName} = '';
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion bbbeasy-backend/app/src/Actions/Rooms/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class View extends BaseAction

public function beforeroute(): void
{
$link = $this->f3->get('PARAMS.link');
$link = $this->f3->get('PARAMS.link');

$room = new Room();
$room = $room->getByLink($link);
$preset = new Preset();
Expand Down
30 changes: 30 additions & 0 deletions bbbeasy-backend/app/src/Enum/GuestPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/*
* BBBEasy open source platform - https://riadvice.tn/
*
* Copyright (c) 2022-2023 RIADVICE SUARL and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BBBEasy 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BBBEasy; if not, see <http://www.gnu.org/licenses/>.
*/

namespace Enum;

class GuestPolicy extends Enum
{
public const ALWAYS_ACCEPT = 'ALWAYS_ACCEPT';
public const ALWAYS_DENY = 'ALWAYS_DENY';
public const ASK_MODERATOR = 'ASK_MODERATOR';
}
2 changes: 1 addition & 1 deletion bbbeasy-backend/app/src/Enum/Presets/GuestPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

class GuestPolicy extends Enum
{
public const GROUP_NAME = 'GuestPolicy';
public const GROUP_NAME = 'Guest Policy';
public const CONFIGURABLE = 'configurable';
public const POLICY = 'policy';

Expand Down
23 changes: 20 additions & 3 deletions bbbeasy-backend/app/src/Models/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

namespace Models;

use Enum\Presets\GuestPolicy;
use Enum\Presets\Layout;
use Models\Base as BaseModel;

/**
Expand Down Expand Up @@ -183,7 +185,8 @@ public function getByName($name): self
public function addDefaultSettings($successMessage, $errorMessage): bool|string
{
try {
$settings = $this->getPresetSettings();
$settings = $this->getPresetSettings();

$this->settings = json_encode($settings);
$this->save();
} catch (\Exception $e) {
Expand All @@ -206,6 +209,7 @@ public function getPresetSettings(): array
$categories = $preset->getPresetCategories();
$presetSettings = [];
$settings = [];

if ($categories) {
foreach ($categories as $category) {
// get category name
Expand All @@ -221,12 +225,25 @@ public function getPresetSettings(): array

if (!$presetSettings->dry() && $presetSettings->enabled) {
if (!$settings[$categoryName]) {
$settings += [$categoryName => [$presetSettings->name => '']];
if (GuestPolicy::GROUP_NAME === $categoryName && GuestPolicy::POLICY === $presetSettings->name) {
$settings += [$categoryName => [$presetSettings->name => \Enum\GuestPolicy::ALWAYS_ACCEPT]];
} elseif (Layout::GROUP_NAME === $categoryName) {
$settings += [$categoryName => [$presetSettings->name => true]];
} else {
$settings += [$categoryName => [$presetSettings->name => '']];
}
} else {
$settings[$categoryName] += [$presetSettings->name => ''];
if (GuestPolicy::GROUP_NAME === $categoryName && GuestPolicy::POLICY === $presetSettings->name) {
$settings[$categoryName] += [$presetSettings->name => \Enum\GuestPolicy::ALWAYS_ACCEPT];
} elseif (Layout::GROUP_NAME === $categoryName) {
$settings[$categoryName] += [$presetSettings->name => true];
} else {
$settings[$categoryName] += [$presetSettings->name => ''];
}
}
}
}

$settings[$categoryName] = json_encode($settings[$categoryName]);
}
}
Expand Down
18 changes: 17 additions & 1 deletion bbbeasy-backend/app/src/Utils/PresetProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Enum\Presets\BreakoutRooms;
use Enum\Presets\General;
use Enum\Presets\GuestPolicy;
use Enum\Presets\Layout;
use Enum\Presets\LearningDashboard;
use Enum\Presets\LockSettings;
use Enum\Presets\Presentation;
Expand Down Expand Up @@ -158,12 +159,27 @@ public function toJoinParameters($preset, $joinParams)
$preparePresetData = $this->preparePresetData($preset);

// Set the preset data
$presetsData->setData(Audio::GROUP_NAME, Audio::AUTO_JOIN, $preparePresetData[Audio::GROUP_NAME][Audio::AUTO_JOIN]);
$presetsData->setData(Audio::GROUP_NAME, Audio::LISTEN_ONLY_ENABLED, $preparePresetData[Audio::GROUP_NAME][Audio::LISTEN_ONLY_ENABLED]);
$presetsData->setData(Audio::GROUP_NAME, Audio::SKIP_ECHO_TEST, $preparePresetData[Audio::GROUP_NAME][Audio::SKIP_ECHO_TEST]);

$presetsData->setData(Layout::GROUP_NAME, Layout::PRESENTATION, $preparePresetData[Layout::GROUP_NAME][Layout::PRESENTATION]);
$presetsData->setData(Layout::GROUP_NAME, Layout::PARTICIPANTS, $preparePresetData[Layout::GROUP_NAME][Layout::PARTICIPANTS]);
$presetsData->setData(Layout::GROUP_NAME, Layout::CHAT, $preparePresetData[Layout::GROUP_NAME][Layout::CHAT]);
$presetsData->setData(Layout::GROUP_NAME, Layout::NAVIGATION_BAR, $preparePresetData[Layout::GROUP_NAME][Layout::NAVIGATION_BAR]);
$presetsData->setData(Layout::GROUP_NAME, Layout::ACTIONS_BAR, $preparePresetData[Layout::GROUP_NAME][Layout::ACTIONS_BAR]);

$joinParams->addUserData('bbb_listen_only_mode', !$presetsData->getData(Audio::GROUP_NAME, Audio::AUTO_JOIN));
$joinParams->addUserData('bbb_force_listen_only', $presetsData->getData(Audio::GROUP_NAME, Audio::LISTEN_ONLY_ENABLED));

$joinParams->addUserData('bbb_skip_check_audio', $presetsData->getData(Audio::GROUP_NAME, Audio::SKIP_ECHO_TEST));
$joinParams->addUserData('bbb_skip_check_audio', $presetsData->getData(Audio::GROUP_NAME, Audio::SKIP_ECHO_TEST) || $presetsData->getData(Audio::GROUP_NAME, Audio::AUTO_JOIN));

$joinParams->addUserData('bbb_hide_presentation_on_join', !$presetsData->getData(Layout::GROUP_NAME, Layout::PRESENTATION));
$joinParams->addUserData('bbb_show_participants_on_login', $presetsData->getData(Layout::GROUP_NAME, Layout::PARTICIPANTS));
$joinParams->addUserData('bbb_show_public_chat_on_login', $presetsData->getData(Layout::GROUP_NAME, Layout::CHAT));
$joinParams->addUserData('bbb_hide_nav_bar', !$presetsData->getData(Layout::GROUP_NAME, Layout::NAVIGATION_BAR));
$joinParams->addUserData('bbb_hide_actions_bar', !$presetsData->getData(Layout::GROUP_NAME, Layout::ACTIONS_BAR));

$joinParams->setRedirect(false);

return $joinParams;
Expand Down
2 changes: 2 additions & 0 deletions bbbeasy-frontend/src/locale/ar-TN.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@
"record": "سجل",
"askModerator": "اسأل المشرف",
"alwaysAccept": "تقبل دائما",

"alwaysDeny": "ينفي دائما",

"email-not-exist": "المستخدم غير موجود مع هذا البريد الإلكتروني"
}
2 changes: 2 additions & 0 deletions bbbeasy-frontend/src/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@

"askModerator": "Ask moderator",
"alwaysAccept": "Always accept",

"alwaysDeny": "Always deny",

"email-not-exist": "User does not exist with this email"
}
3 changes: 1 addition & 2 deletions bbbeasy-frontend/src/locale/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,5 @@

"askModerator": "Demander au modérateur",
"alwaysAccept": "Toujours accepter",
"alwaysDeny": "Toujours refuser",
"email-not-exist": "L'utilisateur n'existe pas avec cette adresse email"
"alwaysDeny": "Toujours refuser"
}

0 comments on commit c70db95

Please sign in to comment.