function bigbluebuttonbn_is_moderator($user, $roles, $participants) { $participant_list = json_decode(htmlspecialchars_decode($participants)); if (is_array($participant_list)) { // Iterate looking for all configuration foreach ($participant_list as $participant) { if ($participant->selectiontype == 'all') { if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) { return true; } } } //Iterate looking for roles $db_moodle_roles = bigbluebuttonbn_get_db_moodle_roles(); foreach ($participant_list as $participant) { if ($participant->selectiontype == 'role') { foreach ($roles as $role) { $db_moodle_role = bigbluebuttonbn_moodle_db_role_lookup($db_moodle_roles, $role->roleid); if ($participant->selectionid == $db_moodle_role->shortname) { if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) { return true; } } } } } //Iterate looking for users foreach ($participant_list as $participant) { if ($participant->selectiontype == 'user') { if ($participant->selectionid == $user) { if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) { return true; } } } } } return false; }
/** * Returns an array with all the users enrolled in a given course * * @package mod_bigbluebuttonbn * @return array a list of enrolled users in the course */ function bigbluebuttonbn_get_users($context) { global $DB; $roles = bigbluebuttonbn_get_db_moodle_roles(); $sqluserids = array(); foreach ($roles as $role) { $users = get_role_users($role->id, $context); foreach ($users as $user) { array_push($sqluserids, $user->id); } } $users_array = array(); if (!empty($sqluserids)) { $users_array = $DB->get_records_select("user", "id IN (" . implode(', ', $sqluserids) . ") AND deleted = 0"); } return $users_array; }