Skip to content

Commit

Permalink
MDL-74638 mod_bigbluebuttonbn: Allow logged-in users to join as guest
Browse files Browse the repository at this point in the history
Logged in users should also be able to join as guest. They may not
normally have access to the meeting maybe because not enrolled to the
course.
  • Loading branch information
rezaies committed Nov 11, 2022
1 parent dcbf1de commit 6225af4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 0 additions & 2 deletions mod/bigbluebuttonbn/classes/form/guest_add.php
Expand Up @@ -90,8 +90,6 @@ public function validation($formdata, $files): array {
$email = trim($email);
if (!validate_email($email)) {
$emailserrors[] .= get_string('guestaccess_emails_invalidemail', 'mod_bigbluebuttonbn', $email);
} else if (!empty(\core_user::get_user_by_email($email))) {
$emailserrors[] .= get_string('guestaccess_emails_existinguser', 'mod_bigbluebuttonbn', $email);
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions mod/bigbluebuttonbn/classes/form/guest_login.php
Expand Up @@ -33,12 +33,20 @@ class guest_login extends \moodleform {
* Form definition
*/
protected function definition() {
global $USER;

$mform = $this->_form;
$mform->addElement('text', 'username',
get_string('guestaccess_username', 'mod_bigbluebuttonbn'));
$mform->setType('username', PARAM_NOTAGS);
$mform->addRule('username',
get_string('required'), 'required', null, 'client');

if (isloggedin() && !isguestuser()) {
$mform->setConstant('username', fullname($USER));
$mform->freeze('username');
}

$mform->addElement('password', 'password',
get_string('guestaccess_password', 'mod_bigbluebuttonbn'));
$mform->setType('password', PARAM_RAW);
Expand Down
7 changes: 1 addition & 6 deletions mod/bigbluebuttonbn/guest.php
Expand Up @@ -44,12 +44,7 @@
if (!$instance->is_guest_allowed()) {
throw new moodle_exception('guestaccess_feature_disabled', 'mod_bigbluebuttonbn');
}
// Same if we are logged in, then we should not really have guest access. This will be confusing.
if (isloggedin() && !isguestuser()) {
// We then redirect to the right page.
\core\notification::warning(get_string('guestaccess_should_not_be_loggedin', 'mod_bigbluebuttonbn'));
redirect(new moodle_url('/mod/bigbluebuttonbn/view.php', ['id' => $instance->get_cm_id()]));
}

// Get the guest matching guest access link.
$PAGE->set_url('/mod/bigbluebuttonbn/guest.php', ['uid' => $uid]);
$title = $instance->get_course()->shortname . ': ' . format_string($instance->get_meeting_name());
Expand Down
4 changes: 0 additions & 4 deletions mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php
Expand Up @@ -309,8 +309,6 @@
$string['guestaccess_add_no_id'] = 'No bigbluebutton instance ID provided.';
$string['guestaccess_emails'] = 'Add guests emails';
$string['guestaccess_emails_help'] = 'Emails of users you want to invite, separated by commas';
$string['guestaccess_emails_existinguser'] = 'The email {$a} belongs to a user who is already registered in this site and cannot
join as a guest!';
$string['guestaccess_emails_invalidemail'] = 'The email {$a} is invalid, please correct it.';
$string['guestaccess_username'] = 'Guest username';
$string['guestaccess_meeting_link'] = 'Meeting link';
Expand All @@ -320,8 +318,6 @@
$string['guestaccess_meeting_invalid_password'] = 'Incorrect password.';
$string['guestaccess_activitynotfound'] = 'The BigblueButton activity is not found for this access as guest. Contact your
support.';
$string['guestaccess_should_not_be_loggedin'] = 'The guest access page is only available for users who are not registered into
this site. You have been automatically redirected.';
$string['guestaccess_feature_disabled'] = 'Guest access: feature is disabled.';
$string['guestaccess_title'] = 'Add guests to this meeting';
$string['guestaccess_copy_link'] = 'Copy link';
Expand Down

0 comments on commit 6225af4

Please sign in to comment.