Skip to content

Commit

Permalink
MDL-76551 mod_bigbluebuttonbn: Add user picture
Browse files Browse the repository at this point in the history
* Add user picture with token
* Add a new global setting to enable or disable avatar for users in meeting.
  • Loading branch information
laurentdavid committed Mar 22, 2023
1 parent ba81f72 commit aa9c5cf
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mod/bigbluebuttonbn/classes/instance.php
Expand Up @@ -1227,4 +1227,15 @@ private function generate_guest_credentials():void {
\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');
}
}
1 change: 1 addition & 0 deletions mod/bigbluebuttonbn/classes/local/config.php
Expand Up @@ -83,6 +83,7 @@ protected static function defaultvalues(): array {
'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,
Expand Down
21 changes: 21 additions & 0 deletions mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php
Expand Up @@ -26,6 +26,7 @@
use mod_bigbluebuttonbn\local\exceptions\server_not_available_exception;
use moodle_url;
use stdClass;
use user_picture;

/**
* The bigbluebutton proxy class.
Expand Down Expand Up @@ -120,9 +121,29 @@ private static function internal_get_join_url(
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.
*
Expand Down
11 changes: 11 additions & 0 deletions mod/bigbluebuttonbn/classes/settings.php
Expand Up @@ -914,6 +914,17 @@ protected function add_extended_settings(): void {
$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.
Expand Down
2 changes: 2 additions & 0 deletions mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php
Expand Up @@ -137,6 +137,8 @@

$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>
Expand Down

0 comments on commit aa9c5cf

Please sign in to comment.