Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #273 #312

Merged
merged 4 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Driver/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ public function createMeeting(MeetingParameters $parameters)
$features['meta_opencast-add-webcams'] = $opencast_webcam_record;
}

if (intval($features['maxParticipants']) == 0) {
$servers = Driver::getConfigValueByDriver((new \ReflectionClass(self::class))->getShortName(), 'servers');
if ($servers && isset($servers[$parameters->getMeetingServerIndex()]) && $servers[$parameters->getMeetingServerIndex()]['maxParticipants']) {
$features['maxParticipants'] = intval($servers[$parameters->getMeetingServerIndex()]['maxParticipants']);
} else {
unset($features['maxParticipants']);
}
}

$params = array_merge($params, $features);
}

Expand Down Expand Up @@ -427,7 +436,7 @@ public static function getCreateFeatures()
240,
_('Die maximale Länge (in Minuten) für das Meeting. Nach Ablauf der eingestellen Dauer wird das Meeting automatisch beendet, d.h. der Raum wird geschlossen. Falls bereits vor Ablauf der Zeit alle Teilnehmenden das Meeting verlassen haben, oder ein Moderator das Meeting aktiv beendet wird der Raum ebenfalls geschlossen.'));

$res['maxParticipants'] = new ConfigOption('maxParticipants', dgettext(MeetingPlugin::GETTEXT_DOMAIN, 'Maximale Teilnehmerzahl'), 50, self::getFeatureInfo('maxParticipants'));
$res['maxParticipants'] = new ConfigOption('maxParticipants', dgettext(MeetingPlugin::GETTEXT_DOMAIN, 'Maximale Teilnehmerzahl'), 0, self::getFeatureInfo('maxParticipants'));

$res['invite_moderator'] = new ConfigOption('invite_moderator', dgettext(MeetingPlugin::GETTEXT_DOMAIN, 'Moderatorenzugang via Link'), false,
_('Legen Sie fest, ob externe Gäste mit Einladungslink als Moderator an der Besprechung teilnehmen dürfen.'));
Expand Down
16 changes: 15 additions & 1 deletion Driver/MeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ class MeetingParameters extends Parameters
*/
private $attendeePassword;


/**
* @var Array features that can be added to create the room (always optional)
*/
private $meetingFeatures;

/**
* @var int the server index of the meeting
*/
private $meetingServerIndex;

public function setMeetingName($meetingName)
{
$this->meetingName = $meetingName;
Expand Down Expand Up @@ -70,6 +74,16 @@ public function getMeetingFeatures()
return $this->meetingFeatures;
}

public function setMeetingServerIndex($index)
{
$this->meetingServerIndex = $index;
}

public function getMeetingServerIndex()
{
return $this->meetingServerIndex;
}

public function toArray() {
return [
'meetingName' => self::getMeetingName(),
Expand Down
1 change: 1 addition & 0 deletions app/models/Meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function getMeetingParameters()
$parameters->setAttendeePassword($this->attendee_password);
$parameters->setModeratorPassword($this->moderator_password);
$parameters->setMeetingFeatures($this->features);
$parameters->setMeetingServerIndex($this->server_index);

return $parameters;
}
Expand Down
15 changes: 15 additions & 0 deletions assets/css/meetings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ fieldset {
}
}
}

input.inline-block, span.inline-block {
display: inline-block !important;
}
}
}

Expand Down Expand Up @@ -330,3 +334,14 @@ span.meeting-badge {
cursor: default;
}
}

.ui-dialog-titlebar-close:focus-visible {
outline: none;
}

.meeting-confirmation {
img {
vertical-align:middle;
margin-right: 9px;
}
}
60 changes: 59 additions & 1 deletion lib/MeetingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function validateFeatureInputs($features, $driver_name) {
break;
case "integer":
$value = filter_var((int)$features[$create_feature_name], FILTER_VALIDATE_INT);
if (!$value || $value < 1 || ($create_feature_name == 'duration' && $value > 1440)) {
$value_range = ($create_feature_name == 'maxParticipants') ? -1 : 1;
if ($value === false || $value < $value_range || ($create_feature_name == 'duration' && $value > 1440)) {
$is_valid = false;
} else {
$features[$create_feature_name] = $value;
Expand Down Expand Up @@ -219,4 +220,61 @@ public function autoSelectCourseDefaultRoom(MeetingCourse $meetingCourse) {
$meetingCourse->is_default = 1;
$meetingCourse->store();
}

/**
* Adjust the room size settings based on current number of course participants for created room.
*
* @param array $meeting_course_list a list of meeting courses
*/
public function adjustMaxParticipants($meeting_course_list) {
// Loop through the meeting course list.
foreach ($meeting_course_list as $meetingCourse) {
$members_count = ($meetingCourse->course->members) + 5;
$features = json_decode($meetingCourse->meeting->features, true);
// In case the maxParticipants could not be read, or is set to zero (0), we reject the adjustment process.
if (!$features || !isset($features['maxParticipants']) || $features['maxParticipants'] == 0) {
continue;
}

// In case the count of course members is greater than the features setting (maxParicipants), we adjust the feature settings.
if ($members_count > $features['maxParticipants']) {
// Try to get driver server config.
$servers = Driver::getConfigValueByDriver($meetingCourse->meeting->driver, 'servers');
$server_config = [];
if ($servers && isset($servers[$meetingCourse->meeting->server_index])) {
$server_config = $servers[$meetingCourse->meeting->server_index];
}

$max_allowed_participants = $members_count;
// Check if the server has maxParticipant and if member count is greater than it.
if (isset($server_config['maxParticipants']) && $members_count > intval($server_config['maxParticipants'])) {
$max_allowed_participants = intval($server_config['maxParticipants']);
}

$features['maxParticipants'] = $max_allowed_participants;

// Take care of server presets.
if (isset($server_config['roomsize-presets']) && count($server_config['roomsize-presets']) > 0) {
foreach ($server_config['roomsize-presets'] as $size => $values) {
if ($features['maxParticipants'] >= intval($values['minParticipants'])) {
unset($values['minParticipants']);
foreach ($values as $feature_name => $feature_value) {
$value = $feature_value;
if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)) {
$value = filter_var($feature_value, FILTER_VALIDATE_BOOLEAN);
}
if (isset($features[$feature_name])) {
$features[$feature_name] = $value;
}
}
}
}
}

// Finally, we store the features back!
$meetingCourse->meeting->features = json_encode($features);
$meetingCourse->meeting->store();
}
}
}
}
7 changes: 4 additions & 3 deletions vueapp/components/MeetingAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ export default {
Object.keys(this.config[this.room['driver']]['server_defaults']).length &&
Object.keys(this.config[this.room['driver']]['server_defaults']).includes(this.room['server_index'])) {
for (const [feature_name, feature_value] of Object.entries(this.config[this.room['driver']]['server_defaults'][this.room['server_index']])) {
if (feature_name != 'maxAllowedParticipants') {
this.$set(this.room['features'], ((feature_name == 'totalMembers') ? 'maxParticipants' : feature_name ), feature_value);
if (feature_name != 'maxAllowedParticipants' && feature_name != 'totalMembers') {
this.$set(this.room['features'], feature_name , feature_value);
}
}
}
Expand Down Expand Up @@ -655,7 +655,8 @@ export default {
break;
case 'number':
var value = parseInt(this.room['features'][config_feature.name]);
if (Number.isInteger(value) && value > 0) {
var range_value = (config_feature.name == 'maxParticipants') ? -1 : 0;
if (Number.isInteger(value) && value > range_value) {
this.$set(this.room['features'], config_feature.name, value);
} else {
invalidInputs.push(config_feature.display_name)
Expand Down
28 changes: 16 additions & 12 deletions vueapp/components/MeetingAddLabelItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,22 @@
:text="feature['info']">
</StudipTooltipIcon>

<input :type="(feature['name'] == 'duration' || feature['name'] == 'maxParticipants') ? 'number' : 'text'"
:max="(
(feature['name'] == 'maxParticipants') ?
(maxAllowedParticipants != 0) ? maxAllowedParticipants : ''
: (feature['name'] == 'duration') ? maxDuration : ''
)"
:min="(feature['name'] == 'maxParticipants') ? minParticipants : ((feature['name'] == 'duration') ? 1 : '')"
@change="(feature['name'] == 'maxParticipants') ? checkPresets() : ''"
v-model.trim="room['features'][feature['name']]"
:placeholder="feature['value'] ? feature['value'] : ''"
:id="feature['name']">

<div>
<input :class="{'inline-block' : feature['name'] == 'maxParticipants'}" :type="(feature['name'] == 'duration' || feature['name'] == 'maxParticipants') ? 'number' : 'text'"
:max="(
(feature['name'] == 'maxParticipants') ?
(maxAllowedParticipants != 0) ? maxAllowedParticipants : ''
: (feature['name'] == 'duration') ? maxDuration : ''
)"
:min="(feature['name'] == 'maxParticipants') ? minParticipants : ((feature['name'] == 'duration') ? 1 : '')"
@change="(feature['name'] == 'maxParticipants') ? checkPresets() : ''"
v-model.trim="room['features'][feature['name']]"
:placeholder="feature['value'] ? feature['value'] : ''"
:id="feature['name']">
<span v-if="feature['name'] == 'maxParticipants'" v-translate>
&nbsp;(0 = unbegrenzt)
</span>
</div>
</template>
</label>
</template>
Expand Down
Loading