Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect group from license borrowing #630

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
19 changes: 18 additions & 1 deletion classes/webservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ class webservice {
*/
protected $instanceusers;

/**
* Zoom group to protect from licenses redefining
* @var array
*/
protected $protectedgroup;

/**
* Maximum limit of paid users
* @var int
Expand Down Expand Up @@ -151,6 +157,7 @@ public function __construct() {
if (!empty($config->utmost)) {
$this->recyclelicenses = $config->utmost;
$this->instanceusers = !empty($config->instanceusers);
$this->protectedgroup = $config->protectedgrp;
}

if ($this->recyclelicenses) {
Expand Down Expand Up @@ -461,7 +468,8 @@ private function get_least_recently_active_paid_user_id() {
$userslist = $this->list_users();

foreach ($userslist as $user) {
if ($user->type != ZOOM_USER_TYPE_BASIC && isset($user->last_login_time)) {
if ($user->type != ZOOM_USER_TYPE_BASIC && isset($user->last_login_time)
&& !in_array($this->protectedgroup,$user->group_ids ?? array(),true)) { // needle: 'PROTECTED' zoom group
jrchamp marked this conversation as resolved.
Show resolved Hide resolved
// Count the user if we're including all users or if the user is on this instance.
if (!$this->instanceusers || core_user::get_user_by_email($user->email)) {
$usertimes[$user->id] = strtotime($user->last_login_time);
Expand All @@ -476,6 +484,15 @@ private function get_least_recently_active_paid_user_id() {
return false;
}

/**
* Get a list of Zoom groups
*
* @return stdClass The call's result in JSON format.
*/
public function get_groups() {
return $this->make_call('/groups');
}
jrchamp marked this conversation as resolved.
Show resolved Hide resolved

/**
* Gets a user's settings.
*
Expand Down
2 changes: 2 additions & 0 deletions lang/en/zoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +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['protectedgrp'] = 'Protect group';
$string['protectedgrp_desc'] = 'Select a Zoom group to protect member users from license redefining';
jrchamp marked this conversation as resolved.
Show resolved Hide resolved
$string['recording'] = 'Recording';
$string['recordingadd'] = 'Add Recording';
$string['recordingdate'] = 'Recording Date';
Expand Down
16 changes: 16 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

require_once($CFG->dirroot . '/mod/zoom/locallib.php');
require_once($CFG->libdir . '/environmentlib.php');
require_once($CFG->dirroot . '/mod/zoom/classes/webservice.php');
jrchamp marked this conversation as resolved.
Show resolved Hide resolved

if ($ADMIN->fulltree) {
require_once($CFG->dirroot . '/mod/zoom/classes/invitation.php');
Expand Down Expand Up @@ -171,6 +172,21 @@
1
);
$settings->add($recycleonjoin);

// Only call to the web services and load the setting if the connection is OK
if (isset($status)) {
if ($status == 'connectionok') {
izendegi marked this conversation as resolved.
Show resolved Hide resolved
$zoomgrps[] = null;
izendegi marked this conversation as resolved.
Show resolved Hide resolved
$groupobj = zoom_webservice()->get_groups();
jrchamp marked this conversation as resolved.
Show resolved Hide resolved
foreach ($groupobj->groups as $group) {
$zoomgrps[$group->id] = $group->name;
}
$protectedgrp = new admin_setting_configselect('zoom/protectedgrp',
get_string('protectedgrp','mod_zoom'),
get_string('protectedgrp_desc','mod_zoom'),0,$zoomgrps);
jrchamp marked this conversation as resolved.
Show resolved Hide resolved
$settings->add($protectedgrp);
}
}

// Global settings.
$settings->add(new admin_setting_heading(
Expand Down
Loading