Skip to content

Commit

Permalink
Creating meetings could be broken when the alternative host user pick…
Browse files Browse the repository at this point in the history
…er is used (#222)

This patch fixes a regression after the introduction of the alternative host user picker which could result in a situation that meetings could not be created at all as soon as the admin enabled the user picker for alternative hosts.
  • Loading branch information
abias authored Mar 10, 2021
1 parent 3bcba8c commit ca96dbd
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,21 +457,25 @@ public function data_postprocessing($data) {
// of selected alternative hosts.

// Get latest list of alternative hosts from the DB.
$result = $DB->get_field('zoom', 'alternative_hosts', array('meeting_id' => $data->meeting_id), MUST_EXIST);
$alternativehostsdb = explode(',', str_replace(';', ',', $result));

// Get selectable alternative host users based on the capability.
$alternativehostschoices = zoom_get_selectable_alternative_hosts_list($this->context);

// Iterate over the latest list of alternative hosts from the DB.
foreach ($alternativehostsdb as $ah) {
// If the existing alternative host would not have been selectable.
if (!array_key_exists($ah, $alternativehostschoices)) {
// Add the alternative host to the alternative_hosts field.
if ($data->alternative_hosts == '') {
$data->alternative_hosts = $ah;
} else {
$data->alternative_hosts .= ',' . $ah;
$result = $DB->get_field('zoom', 'alternative_hosts', array('meeting_id' => $data->meeting_id), IGNORE_MISSING);

// Proceed only if there is a field of alternative hosts already.
if ($result !== false) {
$alternativehostsdb = explode(',', str_replace(';', ',', $result));

// Get selectable alternative host users based on the capability.
$alternativehostschoices = zoom_get_selectable_alternative_hosts_list($this->context);

// Iterate over the latest list of alternative hosts from the DB.
foreach ($alternativehostsdb as $ah) {
// If the existing alternative host would not have been selectable.
if (!array_key_exists($ah, $alternativehostschoices)) {
// Add the alternative host to the alternative_hosts field.
if ($data->alternative_hosts == '') {
$data->alternative_hosts = $ah;
} else {
$data->alternative_hosts .= ',' . $ah;
}
}
}
}
Expand Down

0 comments on commit ca96dbd

Please sign in to comment.