Skip to content

Commit

Permalink
session/lincense management
Browse files Browse the repository at this point in the history
  • Loading branch information
jeph864 committed Mar 3, 2023
1 parent 98a5789 commit 5475e65
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 8 deletions.
53 changes: 51 additions & 2 deletions classes/class.ilBigBlueButtonConfigGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public function initConfigurationForm()
$values["svrsalt"] = $record["svrsalt"];
$values["choose_recording"] = $record["choose_recording"];
$values["guest_global_choose"] = $record["guestglobalchoose"];
$values["sess_enable_max_concurrent"] = $record["sess_enable_max_concurrent"];
$values["enable_userlimit"] = $record["enable_userlimit"];
$values["sess_max_concurrent"] = $record["sess_max_concurrent"];
$values["sess_msg_concurrent"] = $record["sess_msg_concurrent"];
}


Expand Down Expand Up @@ -109,6 +113,39 @@ public function initConfigurationForm()
$choose_recording->setChecked((int) $values['guest_global_choose']);
$form->addItem($choose_recording);

//Session management
$sess_header = new ilFormSectionHeaderGUI();
$sess_header->setTitle($pl->txt("sess_management_header"));

$form->addItem($sess_header);
$sess = new ilCheckboxInputGUI($pl->txt("sess_max_concurrent_sessions"), "sess_enable_max_concurrent");
$sess->setValue(1);
$sess->setChecked((int) $values["sess_enable_max_concurrent"]);
$sess->setInfo("");

$sess_userlimit = new ilCheckboxInputGUI($pl->txt("sess_enable_userlimit"), "enable_userlimit");
$sess_userlimit->setValue(1);
$sess_userlimit->setChecked((int) $values["enable_userlimit"]);
//$sess_userlimit->setInfo($pl->txt("sess_userlimit_info"));
$sess->addSubItem($sess_userlimit);


$sess_concurrent_sessions = new ilNumberInputGUI($pl->txt("sess_max_concurrent_sessions"), "sess_max_concurrent");
$sess_concurrent_sessions->setSize(30);
$sess_concurrent_sessions->setRequired(false);
$sess_concurrent_sessions->setValue($values["sess_max_concurrent"]);
$sess_concurrent_sessions->setInfo("");

$sess->addSubItem($sess_concurrent_sessions);

$sess_msg_concurrent = new ilTextAreaInputGUI($pl->txt("sess_msg_concurrent_limit_title"), "sess_msg_concurrent");
$sess_msg_concurrent->setInfo($pl->txt("sess_msg_concurrent_limit_info"));
$sess_msg_concurrent->setValue($values["sess_msg_concurrent"] ? $values["sess_msg_concurrent"]: $pl->txt("sess_msg_concurrent_limit"));
//$sess_msg_concurrent->setSize(256);

$sess->addSubItem($sess_msg_concurrent);

$form->addItem($sess);

$form->addCommandButton("save", $lng->txt("save"));

Expand All @@ -133,6 +170,10 @@ public function save()
$setSalt= $form->getInput("frmsalt");
$choose_recording = (int) $form->getInput("choose_recording");
$guest_global_choose = (int) $form->getInput("guest_global_choose");
$sess_enable_max_concurrent = (int) $form->getInput("sess_enable_max_concurrent");
$enable_userlimit = (int) $form->getInput("enable_userlimit");
$sess_max_concurrent = (int) $form->getInput("sess_max_concurrent");
$sess_msg_concurrent = $form->getInput("sess_msg_concurrent");

// check if data exisits decide to update or insert
$result = $ilDB->query("SELECT * FROM rep_robj_xbbb_conf");
Expand All @@ -144,15 +185,23 @@ public function save()
$ilDB->quote($setPublicURL, "text").",". //public url
$ilDB->quote($setSalt, "text").",". //salt
$ilDB->quote($choose_recording, "integer").",".
$ilDB->quote($guest_global_choose, "integer").
$ilDB->quote($guest_global_choose, "integer"). ", ".
$ilDB->quote($sess_enable_max_concurrent, "integer"). ", ".
$ilDB->quote($enable_userlimit, "integer"). ", ".
$ilDB->quote($sess_max_concurrent, "integer"). ", ".
$ilDB->quote($sess_msg_concurrent, "text").
")");
} else {
$ilDB->manipulate(
$up = "UPDATE rep_robj_xbbb_conf SET ".
" svrpublicurl = ".$ilDB->quote($setPublicURL, "text").",".
" svrsalt = ".$ilDB->quote($setSalt, "text"). ",".
" choose_recording = ".$ilDB->quote($choose_recording, "integer"). ",".
"guestglobalchoose = ". $ilDB->quote($guest_global_choose, "integer").
"guestglobalchoose = ". $ilDB->quote($guest_global_choose, "integer"). ", ".
"sess_enable_max_concurrent = ". $ilDB->quote($sess_enable_max_concurrent, "integer"). ", ".
"enable_userlimit = ". $ilDB->quote($enable_userlimit, "integer"). ", ".
"sess_max_concurrent = ". $ilDB->quote($sess_max_concurrent, "integer"). ", ".
"sess_msg_concurrent = ". $ilDB->quote($sess_msg_concurrent, "text").
" WHERE id = ".$ilDB->quote(1, "integer")
);
}
Expand Down
33 changes: 33 additions & 0 deletions classes/class.ilBigBlueButtonProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class ilBigBlueButtonProtocol
private $createMeetingParam;
private $avatar;
private $user;
private $meetings;

public function __construct($object)
{
$this->object = $object;
$this->bbb = new BBB($this->object->getSvrSalt(), $this->object->getSvrPublicURL());
$this->meetings = $this->bbb->getMeetings();
}
public function getAvatar()
{
Expand Down Expand Up @@ -221,6 +223,37 @@ private function isPDFValid(string $pdf){

return filter_var($pdf, FILTER_VALIDATE_URL) ? true : false;
}


public function getMaximumSessionsAvailable($meeting_id = null)
{
$participants_count = 0;
$sessions_available = array(
"current_meeting_userlimit" => false,
"max_sessions" => false,
);
$available = array();
foreach($this->meetings->getMeetings() as $meeting){
$participants_count = $participants_count + $meeting->getParticipantCount();
$userlimit_exceeded = ($meeting->getMaxUsers() - $meeting->getParticipantCount() -1 <= 0);
$available[$meeting->getMeetingId()] = [

'participants' => $meeting->getParticipantCount(),
'max_users' => $meeting->getMaxUsers(),
'userlimit' => $userlimit_exceeded

];
if($meeting_id && $meeting->getMeetingId() == $meeting_id && $userlimit_exceeded){
$sessions_available['current_meeting_userlimit'] = true;
}
}
$sessions_available['meetings'] = $available;
if ($this->object->getMaxConcurrentSessions() > 0 && $participants_count >= $this->object->getMaxConcurrentSessions() - 1){
$sessions_available["max_sessions"] = true;
}
return $sessions_available;

}
}

class BBB extends \BigBlueButton\BigBlueButton
Expand Down
50 changes: 50 additions & 0 deletions classes/class.ilObjBigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class ilObjBigBlueButton extends ilObjectPlugin
private $refreshToken;
private $publish = true;
private $allow_download = false;
private $enable_userlimit = false;
private $enable_max_concurrent = false;
private $max_concurrent_sessions = 0;
private $max_concurrent_sessions_msg;
/**
* Constructor
*
Expand Down Expand Up @@ -102,6 +106,10 @@ public function doCreate()
$this->setSvrPublicURL($record["svrpublicurl"]);
$this->setSvrSalt($record["svrsalt"]);
$this->setGuestGlobalEnabled((bool)$record["guestglobalchoose"]);
$this->enableUserLimit((bool) $record['enable_userlimit']);
$this->enableMaxConcurrentSession((bool) $record['sess_enable_max_concurrent']);
$this->setMaxConcurrentSessions((int) $record['sess_max_concurrent']);
$this->setMaxConcurrentSessionsMsg($record['sess_msg_concurrent']);
}
}

Expand Down Expand Up @@ -138,6 +146,10 @@ public function doRead()
$this->setSvrPublicURL($record["svrpublicurl"]);
$this->setSvrSalt($record["svrsalt"]);
$this->setGuestGlobalEnabled((bool)$record["guestglobalchoose"]);
$this->enableUserLimit((bool) $record['enable_userlimit']);
$this->enableMaxConcurrentSession((bool) $record['sess_enable_max_concurrent']);
$this->setMaxConcurrentSessions((int) $record['sess_max_concurrent']);
$this->setMaxConcurrentSessionsMsg($record['sess_msg_concurrent']);
}
}

Expand Down Expand Up @@ -195,6 +207,10 @@ public function doClone($a_target_id, $a_copy_id, $new_obj)
$new_obj->setGuestLinkAllowed($this->isGuestLinkAllowed());
$new_obj->setPublish($this->getPublish());
$new_obj->setDownloadAllowed($this->isDownloadAllowed());
$new_obj->enableMaxConcurrentSession($this->isMaxConcurrentSessionEnabled());
$new_obj->enableUserLimit($this->isUserLimitEnabled());
$new_obj->setMaxConcurrentSession($this->getMaxConcurrentSessions());
$new_obj->setMaxConcurrentSessionsMsg($this->getMaxConcurrentSessionsMsg());

$new_obj->update();
}
Expand Down Expand Up @@ -400,5 +416,39 @@ public function setDownloadAllowed($allow_download)
{
$this->allow_download = $allow_download;
}
public function isMaxConcurrentSessionEnabled()
{
return $this->enable_max_concurrent;

}
public function enableMaxConcurrentSession($enabled = false)
{
$this->enable_max_concurrent = $enabled;

}
public function getMaxConcurrentSessions()
{
return $this->max_concurrent_sessions;
}
public function setMaxConcurrentSessions($max_concurrent_sess = 0)
{
$this->max_concurrent_sessions = $max_concurrent_sess;
}
public function isUserLimitEnabled()
{
return $this->enable_userlimit;
}
public function enableUserLimit( $enabled = false)
{
$this->enable_userlimit = $enabled;
}
public function setMaxConcurrentSessionsMsg($message = "")
{
$this->max_concurrent_sessions_msg = $message;
}
public function getMaxConcurrentSessionsMsg()
{
return $this->max_concurrent_sessions_msg;
}

}
11 changes: 11 additions & 0 deletions classes/class.ilObjBigBlueButtonGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ public function showContent()
include_once("./Customizing/global/plugins/Services/Repository/RepositoryObject/BigBlueButton/classes/class.ilBigBlueButtonProtocol.php");
$BBBHelper=new ilBigBlueButtonProtocol($this->object);

$available_sessions = $BBBHelper->getMaximumSessionsAvailable();
//$BBBHelper->getMeetings();

if ($isModerator) {
$my_tpl = new ilTemplate("./Customizing/global/plugins/Services/Repository/RepositoryObject/BigBlueButton/templates/tpl.BigBlueButtonModeratorClient.html", true, true);

Expand Down Expand Up @@ -358,6 +361,14 @@ public function showContent()
$bbbURL=$BBBHelper->joinURL($this->object);
}

$my_tpl->setVariable('isMaxNumberOfSessionsExceeded', 'false');
if($this->object->isMaxConcurrentSessionEnabled()){
if($available_sessions['max_sessions'] || ( key_exists($this->object->getBBBId(), $available_sessions['meetings']) && $available_sessions['meetings'][$this->object->getBBBId()]['userlimit'])){
$my_tpl->setVariable('isMaxNumberOfSessionsExceeded', 'true');
$my_tpl->setVariable('maxNumberofSessionsExceededText', $this->object->getMaxConcurrentSessionsMsg());
}
}

$my_tpl->setVariable("clickToOpenClass", $this->txt("click_to_open_class"));
$isMeetingRunning=$BBBHelper->isMeetingRunning($this->object);
$my_tpl->setVariable("isMeetingRunning", $isMeetingRunning ? "true" : "false");
Expand Down
16 changes: 14 additions & 2 deletions guest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class GuestLink

/** @var ilObjBigBlueButton $object */
private $pluginObject;
/** @var ilBigBlueButtonProtocol $object */
private $pluginHelper;

/** @var ilBigBlueButtonConfig $settings */
private $pluginConfig;
Expand Down Expand Up @@ -180,7 +182,8 @@ class GuestLink
private $errState = [
'displayname' => false,
'termsOfUse' => false,
'moderator' => false
'moderator' => false,
'userLimit' => false
];

/** @var string $userLang */
Expand Down Expand Up @@ -287,6 +290,8 @@ private function setHtmlDocument()
$this->htmlTpl->setVariable('INFO_TOP_MODERATED_M', $this->getLangVar('top_moderated_m'));
$this->htmlTpl->setVariable('ERR_STATE_INPUT_FIELD', (int)$this->errState['displayname']);
$this->htmlTpl->setVariable('ERR_MSG_INPUT_FIELD', !$this->errState['displayname'] ? '' : $this->getLangVar('err_msg_displayname'));
$this->htmlTpl->setVariable('ERR_STATE_USER_LIMIT', (int)$this->errState['userLimit'] );
$this->htmlTpl->setVariable('ERR_MSG_USER_LIMIT', !$this->errState['userLimit'] ? '': $this->pluginConfig->getMaxConcurrentSessionsMsg());
$this->htmlTpl->setVariable('ERR_STATE_TERMSOFUSE', (int)$this->errState['termsOfUse']);
$this->htmlTpl->setVariable('VAL_TERMSOFUSE', (int)$this->userAccept['termsOfUse']);
$this->htmlTpl->setVariable('TXT_ACCEPT_TERMSOFUSE', $this->getLangVar('terms_of_use') );
Expand Down Expand Up @@ -468,6 +473,7 @@ private function __construct()
$this->httpExit(404);
}
$this->pluginConfig = $this->pluginObject;
$this->pluginHelper = new ilBigBlueButtonProtocol($this->pluginObject);

// exit if not valid
$this->validateInvitation();
Expand All @@ -477,7 +483,12 @@ private function __construct()
$this->setUserLangBySvrParam();
// redirect to BBB if valid
if( $this->checkPostRequest() ) {
if( !$this->errState['displayname'] ) {
if($this->pluginObject->isMaxConcurrentSessionEnabled()){
$available_sessions = $this->pluginHelper->getMaximumSessionsAvailable();
if($available_sessions['max_sessions'] || ( key_exists($this->pluginObject->getBBBId(), $available_sessions['meetings']) && $available_sessions['meetings'][$this->pluginObject->getBBBId()]['userlimit'])){
$this->errState['userLimit'] = true;
}
}else if( !$this->errState['displayname'] ) {
$this->bbb = new BBB($this->pluginConfig->getSvrSalt(), $this->pluginConfig->getSvrPublicUrl());
$this->attendeePwd = $this->pluginObject->getAttendeePwd();
$this->setMeetingId();
Expand All @@ -488,6 +499,7 @@ private function __construct()
}
}


$this->setFormElements();
$this->setHtmlDocument();

Expand Down
7 changes: 7 additions & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ guest_displayname_input#:#Geben Sie Ihren Namen ein!
btntext_join_meeting#:#Meeting beitreten
top_moderated_m#:#Willkommen im Meetingraum!<br/>&nbsp;<br/>Dies ist ein moderierter Raum und Sie können stets erst dann in den Meetingraum gelangen, wenn eine Person mit Moderatorfunktion im Raum ist.
guest_invite_info#:#Mit dem folgenden Link k&ouml;nnen Sie G&auml;ste zum Meeting einladen:
sess_max_concurrent_sessions#:#Begrenzte Anzahl gleichzeitiger Sitzungen
sess_enable_userlimit#:#Benutzerlimit in den Sitzungseinstellungen festlegen
sess_msg_userlimit#:# Die Anzahl der für eine Sitzung zulässigen Benutzer wurde erreicht.
sess_msg_concurrent_limit#:#Die zulässige Anzahl der gleichzeitigen Sitzungen wurde überschritten
sess_msg_concurrent_limit_title#:#Error-Message
sess_msg_concurrent_limit_info#:#Diese Textnachricht wird bei überschrittener Anzahl von Sitzungen angezeigt
sess_management_header#:#Sitzungsmanagement (experimentell)
dialnumber#:# Telefonnummer
accesscode#:# Zugangscode
guestchoose#:# Einladen von Gästen zulassen
Expand Down
7 changes: 7 additions & 0 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ top_moderator#:#Welcome to the meeting room!<br/>&nbsp;<br/><b>This is a moderat
guest_displayname_input#:#Enter your name!
btntext_join_meeting#:#join meeting
top_moderated_m#:#Welcome to the meeting room!<br/>&nbsp;<br/>This is a moderated room and you can always join the meeting room only when a moderator person is in the room.
sess_max_concurrent_sessions#:#Limited number of concurrent sessions
sess_enable_userlimit#:# Allow to set user limit in session settings
sess_msg_userlimit#:#The number of users allowed per session has been reached.
sess_msg_concurrent_limit#:#The allowed number of simultaneous sessions was exceeded
sess_msg_concurrent_limit_title#:#Error message
sess_msg_concurrent_limit_info#:#This text message is displayed when the number of sessions is exceeded
sess_management_header#:#Session management (Experimental)
dialnumber#:# phone number
accesscode#:# access code
guestchoose#:# Allow inviting guests
Expand Down
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$id = "xbbb";

// code version; must be changed for all code changes
$version = "2.0.1";
$version = "2.0.2";

// ilias min and max version; must always reflect the versions that should
// run with the plugin
Expand Down
33 changes: 33 additions & 0 deletions sql/dbupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,36 @@
$ilDB->dropTableColumn('rep_robj_xbbb_conf','svrprivateurl');
}
?>
<#10>
<?php
if (!$ilDB->tableColumnExists("rep_robj_xbbb_conf", "sess_msg_concurrent")
&& !$ilDB->tableColumnExists("rep_robj_xbbb_conf", "sess_max_concurrent")
&& !$ilDB->tableColumnExists("rep_robj_xbbb_conf", "sess_enable_max_concurrent")
&& !$ilDB->tableColumnExists("rep_robj_xbbb_conf", "enable_userlimit")
){
$ilDB->addTableColumn('rep_robj_xbbb_conf','sess_enable_max_concurrent', array(
'type' => 'integer',
'length' => 2,
'notnull' => false,
'default' => 0
));
$ilDB->addTableColumn('rep_robj_xbbb_conf','enable_userlimit', array(
'type' => 'integer',
'length' => 2,
'notnull' => false,
'default' => 0
));
$ilDB->addTableColumn('rep_robj_xbbb_conf','sess_max_concurrent', array(
'type' => 'integer',
'length' => 2,
'notnull' => false,
'default' => 0
));
$ilDB->addTableColumn('rep_robj_xbbb_conf','sess_msg_concurrent', array(
'type' => 'text',
'length' => 1000,
'notnull' => false
));

}
?>
6 changes: 6 additions & 0 deletions templates/bbb.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@
.ilInfoScreenSec.form-horizontal.hide{
display: none;
}

.bbb_error_msg{
padding-top: 10px;
color: red;
font-weight: 700;
}
Loading

0 comments on commit 5475e65

Please sign in to comment.