diff --git a/mod/bigbluebuttonbn/classes/instance.php b/mod/bigbluebuttonbn/classes/instance.php index cc798294c2ed8..9eeff97f504c0 100644 --- a/mod/bigbluebuttonbn/classes/instance.php +++ b/mod/bigbluebuttonbn/classes/instance.php @@ -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'); + } } diff --git a/mod/bigbluebuttonbn/classes/local/config.php b/mod/bigbluebuttonbn/classes/local/config.php index 5b4edfa0414e2..2a9047b0480ff 100644 --- a/mod/bigbluebuttonbn/classes/local/config.php +++ b/mod/bigbluebuttonbn/classes/local/config.php @@ -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, diff --git a/mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php b/mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php index 03e6afa8495f4..1bb065b8c68fd 100644 --- a/mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php +++ b/mod/bigbluebuttonbn/classes/local/proxy/bigbluebutton_proxy.php @@ -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. @@ -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. * diff --git a/mod/bigbluebuttonbn/classes/settings.php b/mod/bigbluebuttonbn/classes/settings.php index 284e2d579913a..49cf9ba6bff18 100644 --- a/mod/bigbluebuttonbn/classes/settings.php +++ b/mod/bigbluebuttonbn/classes/settings.php @@ -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. diff --git a/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php b/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php index 1492ff4691beb..2665329fcc415 100644 --- a/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php +++ b/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php @@ -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 free BigBlueButton service for Moodle (opens in new window) provided by Blindside Networks with restrictions as follows: