Merge branch 'MDL-76551-master' of https://github.com/call-learning/moodle

This commit is contained in:
Paul Holden 2023-03-22 17:08:04 +00:00
commit 0444b91148
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
7 changed files with 100 additions and 52 deletions

View File

@ -1227,4 +1227,15 @@ EOF;
\mod_bigbluebuttonbn\plugin::generate_guest_meeting_credentials();
$DB->update_record('bigbluebuttonbn', $this->instancedata);
}
/**
* Is this meeting configured to display avatars of the users ?
*
* Note: this is for now a global setting.
*
* @return bool
*/
public function is_profile_picture_enabled(): bool {
return (bool) config::get('profile_picture_enabled');
}
}

View File

@ -83,6 +83,7 @@ class config {
'recordingstatus_enabled' => false,
'meetingevents_enabled' => false,
'participant_moderator_default' => '0',
'profile_picture_enabled' => false,
'scheduled_pre_opening' => '10',
'recordings_enabled' => true,
'recordings_deleted_default' => false,

View File

@ -26,6 +26,7 @@ use mod_bigbluebuttonbn\local\exceptions\bigbluebutton_exception;
use mod_bigbluebuttonbn\local\exceptions\server_not_available_exception;
use moodle_url;
use stdClass;
use user_picture;
/**
* The bigbluebutton proxy class.
@ -51,58 +52,98 @@ class bigbluebutton_proxy extends proxy_base {
const DEFAULT_POLL_INTERVAL = 5;
/**
* Builds and returns a url for joining a bigbluebutton meeting.
* Builds and returns a url for joining a BigBlueButton meeting.
*
* @param string $meetingid
* @param string $username
* @param string $pw
* @param string $logouturl
* @param string $role
* @param string|null $configtoken
* @param int $userid
* @param instance $instance
* @param string|null $createtime
*
* @return string
*/
public static function get_join_url(
string $meetingid,
string $username,
string $pw,
string $logouturl,
string $role,
string $configtoken = null,
int $userid = 0,
string $createtime = null
instance $instance,
?string $createtime
): string {
return self::internal_get_join_url($instance, $createtime);
}
/**
* Builds and returns a url for joining a BigBlueButton meeting.
*
* @param instance $instance
* @param string|null $createtime
* @param string $username
* @return string
*/
public static function get_guest_join_url(
instance $instance,
?string $createtime,
string $username
): string {
return self::internal_get_join_url($instance, $createtime, $username, true);
}
/**
* Internal helper method to builds and returns a url for joining a BigBlueButton meeting.
*
*
* @param instance $instance
* @param string|null $jointime = null
* @param string|null $userfullname
* @param bool $isguestjoin
* @return string
* @throws \coding_exception
*/
private static function internal_get_join_url(
instance $instance,
?string $jointime,
string $userfullname = null,
bool $isguestjoin = false
): string {
$data = [
'meetingID' => $meetingid,
'fullName' => $username,
'password' => $pw,
'logoutURL' => $logouturl,
'role' => $role
'meetingID' => $instance->get_meeting_id(),
'fullName' => $userfullname ?? $instance->get_user_fullname(),
'password' => $instance->get_current_user_password(),
'logoutURL' => $isguestjoin ? $instance->get_guest_access_url()->out(false) : $instance->get_logout_url()->out(false),
'role' => $instance->get_current_user_role()
];
if (!is_null($configtoken)) {
$data['configToken'] = $configtoken;
}
if (!empty($userid)) {
$data['userID'] = $userid;
if (!$isguestjoin) {
$data['userID'] = $instance->get_user_id();
$data['guest'] = "false";
} else {
$data['guest'] = "true";
}
if (!is_null($createtime)) {
$data['createTime'] = $createtime;
if (!is_null($jointime)) {
$data['createTime'] = $jointime;
}
$currentlang = current_language();
if (!empty(trim($currentlang))) {
$data['userdata-bbb_override_default_locale'] = $currentlang;
}
if ($instance->is_profile_picture_enabled()) {
$user = $instance->get_user();
if (!empty($user->picture)) {
$data['avatarURL'] = self::get_avatar_url($user)->out(false);
}
}
return self::action_url('join', $data);
}
/**
* Get user avatar URL
*
* @param object $user
* @return moodle_url
*/
private static function get_avatar_url(object $user): moodle_url {
global $PAGE;
$userpicture = new user_picture($user);
$userpicture->includetoken = true;
$userpicture->size = 3; // Size f3.
return $userpicture->get_url($PAGE);
}
/**
* Perform api request on BBB.
*

View File

@ -193,35 +193,17 @@ class meeting {
* @return string
*/
public function get_join_url(): string {
return bigbluebutton_proxy::get_join_url(
$this->instance->get_meeting_id(),
$this->instance->get_user_fullname(),
$this->instance->get_current_user_password(),
$this->instance->get_logout_url()->out(false),
$this->instance->get_current_user_role(),
null,
$this->instance->get_user_id(),
$this->get_meeting_info()->createtime
);
return bigbluebutton_proxy::get_join_url($this->instance, $this->get_meeting_info()->createtime);
}
/**
* Get meeting join URL for guest
*
* @param string $fullname
* @param string $userfullname
* @return string
*/
public function get_guest_join_url(string $fullname): string {
return bigbluebutton_proxy::get_join_url(
$this->instance->get_meeting_id(),
$fullname,
$this->instance->get_current_user_password(),
$this->instance->get_guest_access_url()->out(false),
$this->instance->get_current_user_role(),
null,
0,
$this->get_meeting_info()->createtime
);
public function get_guest_join_url(string $userfullname): string {
return bigbluebutton_proxy::get_guest_join_url($this->instance, $this->get_meeting_info()->createtime, $userfullname);
}

View File

@ -914,6 +914,17 @@ class settings {
$item,
$extendedcapabilitiessetting
);
$item = new admin_setting_configcheckbox(
'bigbluebuttonbn_profile_picture_enabled',
get_string('config_profile_picture_enabled', 'bigbluebuttonbn'),
get_string('config_profile_picture_enabled_description', 'bigbluebuttonbn'),
false
);
$this->add_conditional_element(
'profile_picture_enabled',
$item,
$extendedcapabilitiessetting
);
}
$this->admin->add($this->parent, $extendedcapabilitiessetting);
// Configuration for extended BN capabilities should go here.

View File

@ -137,6 +137,8 @@ $string['config_guestaccess_enabled_description'] = 'Allow users without an acco
$string['config_general'] = 'General settings';
$string['config_general_description'] = 'These settings are always used.';
$string['config_profile_picture_enabled'] = 'Show profile pictures';
$string['config_profile_picture_enabled_description'] = 'Should profile pictures of participants be shown in BigBlueButton sessions?';
$string['config_server_url'] = 'BigBlueButton server URL';
$string['config_server_url_description'] = 'The default credentials are for a <a href="https://bigbluebutton.org/free-bigbluebutton-service-for-moodle/" target="_blank">free BigBlueButton service for Moodle (opens in new window)</a> provided by Blindside Networks with restrictions as follows:
<ol>

View File

@ -1,6 +1,6 @@
This files describes API changes in the bigbluebuttonbn code.
=== 4.2 ===
* Simplify bigbluebutton_proxy get_join_url so to pass only parameters that cannot be deduced from the instance.
* Add a new parameter for mod_bigbluebuttonbn\recording::sync_pending_recordings_from_server so sync only 'dismissed' recordings
(This was fixed in 4.2, 4.1.3 and 4.0.8).