$viewerList = "-";
 $moderatorList = "-";
 // print_object( $bigbluebuttonbn );
 if (!$bigbluebuttonbn->visible) {
     // Nothing to do
 } else {
     $modPW = get_field('bigbluebuttonbn', 'moderatorpass', 'name', $bigbluebuttonbn->name);
     $attPW = get_field('bigbluebuttonbn', 'viewerpass', 'name', $bigbluebuttonbn->name);
     // print "## $modPW ##";
     $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '">' . format_string($bigbluebuttonbn->name) . '</a>';
     // $status = $bigbluebuttonbn->meetingid;
     //echo "XX";
     //
     // Output Users in the meeting
     //
     $getArray = BigBlueButtonBN::getMeetingInfoArray($bigbluebuttonbn->meetingid, $modPW, $url, $salt);
     // print_object( $getArray );
     if (!$getArray) {
         //
         // The server was unreachable
         //
         error(get_string('index_unable_display', 'bigbluebuttonbn'));
         return;
     }
     if (isset($getArray['messageKey'])) {
         //
         // There was an error returned
         //
         if ($info['messageKey'] == "checksumError") {
             error(get_string('index_checksum_error', 'bigbluebuttonbn'));
             return;
function displayBigBlueButtonRooms($url, $salt, $moderator, $course, $bigbluebuttonbn, $groupObj = null)
{
    $joinURL = null;
    $user = null;
    $result = null;
    $group = "-";
    $users = "-";
    $running = "-";
    $actions = "-";
    $viewerList = "-";
    $moderatorList = "-";
    $recording = "-";
    if (!$bigbluebuttonbn->visible) {
        // Nothing to do
    } else {
        $modPW = $bigbluebuttonbn->moderatorpass;
        $attPW = $bigbluebuttonbn->viewerpass;
        //
        // Output Users in the meeting
        //
        if ($groupObj == null) {
            $getArray = BigBlueButtonBN::getMeetingInfoArray($bigbluebuttonbn->meetingid, $modPW, $url, $salt);
            if ($bigbluebuttonbn->newwindow == 1) {
                $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '" target="_blank">' . format_string($bigbluebuttonbn->name) . '</a>';
            } else {
                $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '">' . format_string($bigbluebuttonbn->name) . '</a>';
            }
        } else {
            $getArray = BigBlueButtonBN::getMeetingInfoArray($bigbluebuttonbn->meetingid . '[' . $groupObj->id . ']', $modPW, $url, $salt);
            if ($bigbluebuttonbn->newwindow == 1) {
                $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '&group=' . $groupObj->id . '" target="_blank">' . format_string($bigbluebuttonbn->name) . '</a>';
            } else {
                $joinURL = '<a href="view.php?id=' . $bigbluebuttonbn->coursemodule . '&group=' . $groupObj->id . '">' . format_string($bigbluebuttonbn->name) . '</a>';
            }
            $group = $groupObj->name;
        }
        if (!$getArray) {
            //
            // The server was unreachable
            //
            print_error(get_string('index_error_unable_display', 'bigbluebuttonbn'));
            return;
        }
        if (isset($getArray['messageKey'])) {
            //
            // There was an error returned
            //
            if ($getArray['messageKey'] == "checksumError") {
                print_error(get_string('index_error_checksum', 'bigbluebuttonbn'));
                return;
            }
            if ($getArray['messageKey'] == "notFound" || $getArray['messageKey'] == "invalidMeetingId") {
                //
                // The meeting does not exist yet on the BigBlueButton server.  This is OK.
                //
            } else {
                //
                // There was an error
                //
                $users = $getArray['messageKey'] . ": " . $getArray['message'];
            }
        } else {
            //
            // The meeting info was returned
            //
            if ($getArray['running'] == 'true') {
                if ($moderator) {
                    if ($groupObj == null) {
                        $actions = '<form name="form1" method="post" action=""><INPUT type="hidden" name="id" value="' . $course->id . '"><INPUT type="hidden" name="a" value="' . $bigbluebuttonbn->id . '"><INPUT type="submit" name="submit" value="end" onclick="return confirm(\'' . get_string('index_confirm_end', 'bigbluebuttonbn') . '\')"></form>';
                    } else {
                        $actions = '<form name="form1" method="post" action=""><INPUT type="hidden" name="id" value="' . $course->id . '"><INPUT type="hidden" name="a" value="' . $bigbluebuttonbn->id . '"><INPUT type="hidden" name="g" value="' . $groupObj->id . '"><INPUT type="submit" name="submit" value="end" onclick="return confirm(\'' . get_string('index_confirm_end', 'bigbluebuttonbn') . '\')"></form>';
                    }
                }
                if (isset($getArray['metadata']->recording) && $getArray['metadata']->recording == 'true') {
                    // if it has been set when meeting created, set the variable on/off
                    $recording = get_string('index_enabled', 'bigbluebuttonbn');
                }
                $xml = $getArray['attendees'];
                if (count($xml) && count($xml->attendee)) {
                    $users = count($xml->attendee);
                    $viewer_count = 0;
                    $moderator_count = 0;
                    foreach ($xml->attendee as $attendee) {
                        if ($attendee->role == "MODERATOR") {
                            if ($viewer_count++ > 0) {
                                $moderatorList .= ", ";
                            } else {
                                $moderatorList = "";
                            }
                            $moderatorList .= $attendee->fullName;
                        } else {
                            if ($moderator_count++ > 0) {
                                $viewerList .= ", ";
                            } else {
                                $viewerList = "";
                            }
                            $viewerList .= $attendee->fullName;
                        }
                    }
                }
            }
        }
        return array($bigbluebuttonbn->section, $joinURL, $group, $users, $viewerList, $moderatorList, $recording, $actions);
    }
}