From fd5c702c974f808411491e4ba717795c5455ddec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Zendegi?= Date: Fri, 20 Dec 2024 15:51:48 +0100 Subject: [PATCH] Make protected group multilselect --- classes/webservice.php | 6 +++--- lang/en/zoom.php | 4 ++-- settings.php | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/classes/webservice.php b/classes/webservice.php index f2ad44a7..48cb64d6 100644 --- a/classes/webservice.php +++ b/classes/webservice.php @@ -101,7 +101,7 @@ class webservice { * Zoom group to protect from licenses redefining * @var array */ - protected $protectedgroup; + protected $protectedgroups; /** * Maximum limit of paid users @@ -157,7 +157,7 @@ public function __construct() { if (!empty($config->utmost)) { $this->recyclelicenses = $config->utmost; $this->instanceusers = !empty($config->instanceusers); - $this->protectedgroup = $config->protectedgroup; + $this->protectedgroups = !empty($config->protectedgroups) ? explode(',', $config->protectedgroups) : []; } if ($this->recyclelicenses) { @@ -473,7 +473,7 @@ private function get_least_recently_active_paid_user_id() { continue; } // Skip the protected group. - if (!in_array($this->protectedgroup, $user->group_ids ?? [], true)) { + if (!empty($this->protectedgroups) && array_intersect($this->protectedgroups, $user->group_ids ?? [])) { continue; } // We need the login time. diff --git a/lang/en/zoom.php b/lang/en/zoom.php index 2cce3a70..26d7de83 100644 --- a/lang/en/zoom.php +++ b/lang/en/zoom.php @@ -320,8 +320,8 @@ $string['privacy:metadata:zoom_meeting_participants:user_email'] = 'The email of the participant'; $string['privacy:metadata:zoom_meeting_view'] = 'The database table to track users that view the meeting recordings'; $string['privacy:metadata:zoom_meeting_view:userid'] = 'The id of the user that viewed the recording'; -$string['protectedgroup'] = 'Protect group'; -$string['protectedgroup_desc'] = 'Select a Zoom group to protect member users from license redefining'; +$string['protectedgroups'] = 'Protect groups'; +$string['protectedgroups_desc'] = 'Select Zoom groups to protect member users from license redefining'; $string['recording'] = 'Recording'; $string['recordingadd'] = 'Add Recording'; $string['recordingdate'] = 'Recording Date'; diff --git a/settings.php b/settings.php index 619899b2..a23eaad2 100644 --- a/settings.php +++ b/settings.php @@ -171,8 +171,8 @@ 1 ); $settings->add($recycleonjoin); - - // Only call to the web services and load the setting if the connection is OK. + + // Only call to the web services and load the setting if the connection is OK if (isset($status) && $status === 'connectionok') { $zoomgrps = []; $groupobj = zoom_webservice()->get_groups(); @@ -182,13 +182,13 @@ } } - $protectedgroup = new admin_setting_configselect( - 'zoom/protectedgroup', - get_string('protectedgroup', 'mod_zoom'), - get_string('protectedgroup_desc', 'mod_zoom'), - 0, + $protectedgroups = new admin_setting_configmultiselect( + 'zoom/protectedgroups', + get_string('protectedgroups','mod_zoom'), + get_string('protectedgroups_desc','mod_zoom'), + [], $zoomgrps); - $settings->add($protectedgroup); + $settings->add($protectedgroups); } // Global settings.