315f4f2bd4
* Provide a way for external participants to be invited to a meeting by giving them an url/password for external users (not registered in Moodle) * Add guest access page with username and password prompt * Add form and modify API calls to take into account guest login * Add a form modal to add guest users emails * Allow copy of link and password in both popup form and module form * The guest should be approved by default. It should be intentional to let them in without checks. * Guest access URL and password should not be copied when duplicating or backing up the activity. * The mod_bigbluebuttonbn_meeting_info web service function now returns guestjoinurl and guestpassword only for moderators. * Redirect if user already logged in Note: this will allow guest to connect to an existing and running meeting. The moderator will then be able to adjust the guest user's right. For security reasons we do not yet allow moderators to join the meeting directly (or start a meeting)
110 lines
3.5 KiB
PHP
110 lines
3.5 KiB
PHP
<?php
|
|
// This file is part of Moodle - http://moodle.org/
|
|
//
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
namespace mod_bigbluebuttonbn\task;
|
|
use core_user;
|
|
use html_writer;
|
|
|
|
/**
|
|
* This adhoc task will send emails to guest users with the meeting's details
|
|
*
|
|
* @package mod_bigbluebuttonbn
|
|
* @copyright 2022 onwards, Blindside Networks Inc
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
* @author Laurent David (laurent [at] call-learning [dt] fr)
|
|
*/
|
|
class send_guest_emails extends send_notification {
|
|
|
|
/**
|
|
* Get the notification type.
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function get_notification_type(): string {
|
|
return 'guest_invited';
|
|
}
|
|
|
|
/**
|
|
* Send all the emails
|
|
*/
|
|
protected function send_all_notifications(): void {
|
|
$customdata = $this->get_custom_data();
|
|
if (!empty($customdata->emails)) {
|
|
foreach ($customdata->emails as $email) {
|
|
$user = core_user::get_noreply_user();
|
|
$user->email = $email;
|
|
$user->mailformat = 1; // HTML format.
|
|
|
|
email_to_user(
|
|
$user,
|
|
core_user::get_noreply_user(),
|
|
$this->get_subject(),
|
|
$this->get_small_message(),
|
|
$this->get_html_message()
|
|
);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Get the subject of the notification.
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function get_subject(): string {
|
|
return get_string('guest_invitation_subject', 'mod_bigbluebuttonbn', $this->get_string_vars());
|
|
}
|
|
|
|
/**
|
|
* Get variables to make available to strings.
|
|
*
|
|
* @return array
|
|
*/
|
|
protected function get_string_vars(): array {
|
|
$customdata = $this->get_custom_data();
|
|
$sender = core_user::get_user($customdata->useridfrom);
|
|
return [
|
|
'course_fullname' => $this->get_instance()->get_course()->fullname,
|
|
'course_shortname' => $this->get_instance()->get_course()->shortname,
|
|
'name' => $this->get_instance()->get_cm()->name,
|
|
'guestjoinurl' => $this->get_instance()->get_guest_access_url()->out(false),
|
|
'guestpassword' => $this->get_instance()->get_guest_access_password(),
|
|
'sender' => fullname($sender)
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the short summary message.
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function get_small_message(): string {
|
|
return get_string('guest_invitation_small_message', 'mod_bigbluebuttonbn', $this->get_string_vars());
|
|
}
|
|
|
|
/**
|
|
* Get the HTML message content.
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function get_html_message(): string {
|
|
return html_writer::tag(
|
|
'p',
|
|
get_string('guest_invitation_full_message', 'mod_bigbluebuttonbn', $this->get_string_vars())
|
|
);
|
|
}
|
|
}
|