MDL-74654 mod_bigbluebuttonbn: Add role parameter

This commit is contained in:
Shamiso.Jaravaza
2022-10-18 08:23:54 -06:00
parent 00ad2a14da
commit afd07d1e42
4 changed files with 59 additions and 0 deletions
+13
View File
@@ -725,6 +725,19 @@ EOF;
return $this->get_viewer_password();
}
/**
* Get the appropriate designated role for the current user.
*
* @return string
*/
public function get_current_user_role(): string {
if ($this->is_admin() || $this->is_moderator()) {
return 'MODERATOR';
}
return 'VIEWER';
}
/**
* Whether to show the recording button
*
@@ -47,6 +47,7 @@ class bigbluebutton_proxy extends proxy_base {
* @param string $username
* @param string $pw
* @param string $logouturl
* @param string $role
* @param string|null $configtoken
* @param string|null $userid
* @param string|null $createtime
@@ -58,6 +59,7 @@ class bigbluebutton_proxy extends proxy_base {
string $username,
string $pw,
string $logouturl,
string $role,
string $configtoken = null,
string $userid = null,
string $createtime = null
@@ -67,6 +69,7 @@ class bigbluebutton_proxy extends proxy_base {
'fullName' => $username,
'password' => $pw,
'logoutURL' => $logouturl,
'role' => $role
];
if (!is_null($configtoken)) {
+2
View File
@@ -198,6 +198,7 @@ class meeting {
$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
@@ -355,6 +356,7 @@ class meeting {
];
/**
* Helper to prepare data used for create meeting.
* @todo moderatorPW and attendeePW will be removed from create after release of BBB v2.6.
*
* @return array
*/
@@ -460,6 +460,47 @@ class instance_test extends advanced_testcase {
];
}
/**
* Ensure that the get_current_user_role function works as expected.
*
* @dataProvider get_current_user_role_provider
* @param bool $isadmin
* @param bool $ismoderator
* @param bool $expectedmodrole
* @covers ::get_current_user_role
*/
public function test_get_current_user_role(bool $isadmin, bool $ismoderator, bool $expectedmodrole): void {
$stub = $this->getMockBuilder(instance::class)
->setMethods([
'is_admin',
'is_moderator',
])
->disableOriginalConstructor()
->getMock();
$stub->method('is_admin')->willReturn($isadmin);
$stub->method('is_moderator')->willReturn($ismoderator);
if ($expectedmodrole) {
$this->assertEquals('MODERATOR', $stub->get_current_user_role());
} else {
$this->assertEquals('VIEWER', $stub->get_current_user_role());
}
}
/**
* Data provider for the get_current_user_role function.
*
* @return array
*/
public function get_current_user_role_provider(): array {
return [
'Admin is a moderator' => [true, false, true],
'Moderator is a moderator' => [false, true, true],
'Others are a viewer' => [false, false, false],
];
}
/**
* Tests for the allow_recording_start_stop function.
*