$can_tag = false;
         }
         $status_can_end = '"can_tag": ' . ($can_tag ? 'true' : 'false') . ', ';
     }
     echo $params['callback'] . '({ "running": ' . ($meeting_running ? 'true' : 'false') . ', "info": ' . json_encode($meeting_info) . ', "status": {"can_join": ' . ($can_join ? 'true' : 'false') . ',"join_url": "' . $bbbsession['joinURL'] . '","join_button_text": "' . $join_button_text . '", ' . $status_can_end . $status_can_tag . '"message": "' . $initial_message . '"} });';
     break;
 case 'meeting_end':
     if ($bbbsession['administrator'] || $bbbsession['moderator']) {
         //Execute the end command
         $meeting_info = bigbluebuttonbn_bbb_broker_do_end_meeting($params['id'], $bbbsession['modPW']);
         // Moodle event logger: Create an event for meeting ended
         if (isset($bigbluebuttonbn)) {
             bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_MEETING_ENDED, $bigbluebuttonbn, $context, $cm);
         }
         // Update the cache
         $meeting_info = bigbluebuttonbn_bbb_broker_get_meeting_info($params['id'], $bbbsession['modPW'], true);
         echo $params['callback'] . '({ "status": true });';
     } else {
         error_log("ERROR: User not authorized to execute end command");
         header("HTTP/1.0 401 Unauthorized. User not authorized to execute end command");
     }
     break;
 case 'recording_list':
     break;
 case 'recording_info':
     if ($bbbsession['managerecordings']) {
         //Retrieve the array of imported recordings
         $recordings_imported = bigbluebuttonbn_getRecordingsImportedArray($bbbsession['course']->id, isset($bbbsession['bigbluebuttonbn']) ? $bbbsession['bigbluebuttonbn']->id : NULL);
         $recordings_indexed = bigbluebuttonbn_index_recordings($recordings_imported);
         if (isset($recordings_indexed[$params['id']])) {
             //Look up for an update on the imported recording
function bigbluebutton_bbb_view_execute_join($bbbsession, $cm, $context, $bigbluebuttonbn)
{
    //// Update the cache
    $meeting_info = bigbluebuttonbn_bbb_broker_get_meeting_info($bbbsession['meetingid'], $bbbsession['modPW'], true);
    if ($bbbsession['userlimit'] == 0 || intval($meeting_info['participantCount']) < $bbbsession['userlimit']) {
        //// Build the URL
        if ($bbbsession['administrator'] || $bbbsession['moderator']) {
            $password = $bbbsession['modPW'];
        } else {
            $password = $bbbsession['viewerPW'];
        }
        $join_url = bigbluebuttonbn_getJoinURL($bbbsession['meetingid'], $bbbsession['username'], $password, $bbbsession['shared_secret'], $bbbsession['endpoint'], $bbbsession['logoutURL']);
        //// Moodle event logger: Create an event for meeting joined
        bigbluebuttonbn_event_log(BIGBLUEBUTTON_EVENT_MEETING_JOINED, $bigbluebuttonbn, $context, $cm);
        /// Internal logger: Instert a record with the meeting created
        bigbluebuttonbn_logs($bbbsession, BIGBLUEBUTTONBN_LOG_EVENT_JOIN);
        //// Before executing the redirect, increment the number of participants
        bigbluebuttonbn_bbb_broker_participant_joined($bbbsession['meetingid'], $bbbsession['administrator'] || $bbbsession['moderator']);
        //// Execute the redirect
        header('Location: ' . $join_url);
    } else {
        header('Location: ' . $bbbsession['logoutURL']);
    }
}