示例#1
0
/**
 * @brief Print a box with the details of a bbb session
 * @global type $course_id
 * @global type $tool_content
 * @global type $is_editor
 * @global type $langNewBBBSessionStart
 * @global type $langNewBBBSessionType
 * @global type $langConfirmDelete
 * @global type $langNewBBBSessionPublic
 * @global type $langNewBBBSessionPrivate
 * @global type $langBBBSessionJoin
 * @global type $langNewBBBSessionDesc
 * @global type $course_code
 * @global type $langNote
 * @global type $langBBBNoteEnableJoin
 * @global type $langTitle
 * @global type $langActivate
 * @global type $langDeactivate
 * @global type $langModify
 * @global type $langDelete
 */
function bbb_session_details() {
    global $course_id, $tool_content, $is_editor, $course_code, $head_content,
        $langNewBBBSessionStart, $langNewBBBSessionType, $langParticipants,
        $langConfirmDelete, $langNewBBBSessionPublic, $langNewBBBSessionPrivate,
        $langBBBSessionJoin, $langNewBBBSessionDesc, $langNote,
        $langBBBNoteEnableJoin, $langTitle,$langActivate, $langDeactivate,
        $langEditChange, $langDelete, $langNoBBBSesssions, $langDaysLeft, $m,
        $langBBBNotServerAvailableStudent, $langBBBNotServerAvailableTeacher,
        $langBBBImportRecordings;

    load_js('trunk8');

    $myGroups = Database::get()->queryArray("SELECT group_id FROM group_members WHERE user_id=?d", $_SESSION['uid']);

    $activeClause = $is_editor? '': "AND active = '1'";
    $result = Database::get()->queryArray("SELECT * FROM bbb_session
        WHERE course_id = ?s $activeClause ORDER BY start_date DESC", $course_id);
    if (get_total_bbb_servers() == '0') {
        if ($is_editor) {
            $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableTeacher</p>";
        } else {
            $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableStudent</p>";
        }
    } elseif ($result) {
        if (!$is_editor) {
            $tool_content .= "<div class='alert alert-info'><label>$langNote</label>:<br>$langBBBNoteEnableJoin</div>";
        }
        $headingsSent = false;
        $headings = "<div class='row'>
                       <div class='col-md-12'>
                         <div class='table-responsive'>
                           <table class='table-default'>
                             <tr class='list-header'>
                               <th style='width:25%'>$langTitle</th>
                               <th class='text-center'>$langNewBBBSessionDesc</th>
                               <th class='text-center'>$langNewBBBSessionStart</th>
                               <th class='text-center'>$langParticipants</th>
                               <th class='text-center'>".icon('fa-gears')."</th>
                             </tr>";

        define('DAY_MINUTES', 24 * 40);
        foreach ($result as $row) {
            $participants = '';
            // Get participants
            $r_group = explode(",",$row->participants);
            foreach ($r_group as $participant_uid) {
                if ($participants) {
                    $participants .= ', ';
                }
                $participant_uid = str_replace("'", '', $participant_uid);
                if (preg_match('/^_/', $participant_uid)) {
                    $participants .= gid_to_name(str_replace("_", '', $participant_uid));
                } else {
                    $participants .= uid_to_name($participant_uid, 'fullname');
                }
            }
            $participants = "<span class='trunk8'>$participants</span>";
            $id = $row->id;
            $title = $row->title;
            $start_date = $row->start_date;
            $timeLeft = date_diff_in_minutes($start_date, date('Y-m-d H:i:s'));
            $timeLabel = $start_date;
            if ($timeLeft > 0) {
                $timeLabel .= "<br><span class='label label-warning'><small>$langDaysLeft " .
                    format_time_duration($timeLeft * 60) .
                    "</small></span>";
            } elseif (-$timeLeft > DAY_MINUTES) {
                $timeLabel .= "<br><span class='label label-danger'><small>$m[expired]</small></span>";
            }

            // $row->public == '1' ? $type = $langNewBBBSessionPublic: $type = $langNewBBBSessionPrivate;
            $meeting_id = $row->meeting_id;
            $att_pw = $row->att_pw;
            $mod_pw = $row->mod_pw;
            $record = $row->record;
            $desc = isset($row->description)? $row->description: '';

            $canJoin = $row->active == '1' &&
                $timeLeft < $row->unlock_interval &&
                -$timeLeft < DAY_MINUTES &&
                get_total_bbb_servers() <> '0';
            if ($canJoin) {
                if($is_editor)
                {
                    $joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=do_join&amp;meeting_id=" . urlencode($meeting_id) . "&amp;title=".urlencode($title)."&amp;att_pw=".urlencode($att_pw)."&amp;mod_pw=".urlencode($mod_pw)."&amp;record=$record' target='_blank'>" . q($title) . "</a>";
                }else
                {
                    //$joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=do_join&amp;meeting_id=" . urlencode($meeting_id) . "&amp;att_pw=".urlencode($att_pw)."' target='_blank'>" . q($title) . "</a>";
                    $joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=do_join&amp;meeting_id=" . urlencode($meeting_id) . "&amp;title=".urlencode($title)."&amp;att_pw=".urlencode($att_pw)."&amp;record=$record' target='_blank'>" . q($title) . "</a>";
                }
            } else {
                $joinLink = q($title);
            }

            if ($is_editor) {
                if (!$headingsSent) {
                    $tool_content .= $headings;
                    $headingsSent = true;
                }
                $tool_content .= '<tr' . ($row->active? '': " class='not_visible'") . ">
                    <td class='text-left'>$joinLink</td>
                    <td>$desc</td>
                    <td class='text-center'>$timeLabel</td>
                    <td style='width: 30%'>$participants</td>
                    <td class='option-btn-cell'>".
                        action_button(array(
                            array(  'title' => $langEditChange,
                                    'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=" . getIndirectReference($id) . "&amp;choice=edit",
                                    'icon' => 'fa-edit'),
                            array(  'title' => $langBBBImportRecordings,
                                    'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=" . getIndirectReference($row->id) . "&amp;choice=import_video",
                                    'icon' => "fa-edit"),
                            array(  'title' => $row->active? $langDeactivate : $langActivate,
                                    'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=" . getIndirectReference($row->id) . "&amp;choice=do_".
                                             ($row->active? 'disable' : 'enable'),
                                    'icon' => $row->active ? 'fa-eye': 'fa-eye-slash'),
                            array(  'title' => $langDelete,
                                    'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&amp;id=" . getIndirectReference($row->id) . "&amp;choice=do_delete",
                                    'icon' => 'fa-times',
                                    'class' => 'delete',
                                    'confirm' => $langConfirmDelete)
                            )) .
                    "</td></tr>";
            } else {
                // Allow access to session only if user is in participant group or session is scheduled for everyone
                $access = false;
                if(!empty($r_group) && count($r_group)>0 && $r_group[0]<>'')
                {
                    foreach ($myGroups as $mg) {
                        if (in_array("'_" . $mg->group_id . "'", $r_group)) {
                            $access = true;
                        }
                }
                }else{
                    $access = true;
                }
                // Always allow access to editor switched to student view
                $access = $access || in_array("'".$_SESSION['uid']."'", $r_group) ||
                    (isset($_SESSION['student_view']) and $_SESSION['student_view'] == $course_code);

                if ($access) {
                    if (!$headingsSent) {
                        $tool_content .= $headings;
                        $headingsSent = true;
                    }
                    $tool_content .= "<tr>
                        <td class='text-center'>$joinLink</td>
                        <td>$desc</td>
                        <td class='text-center'>$timeLabel</td>
                        <td style='width: 30%'>$participants</td>
                        <td class='text-center'>";
                    // Join url will be active only X minutes before scheduled time and if session is visible for users
                    if ($canJoin) {
                        $tool_content .= icon('fa-sign-in', $langBBBSessionJoin,"$_SERVER[SCRIPT_NAME]?course=$course_code&amp;choice=do_join&amp;title=".urlencode($title)."&amp;meeting_id=" . urlencode($meeting_id) . "&amp;att_pw=".urlencode($att_pw)."&amp;record=$record' target='_blank");
                    } else {
                        $tool_content .= "-</td>";
                    }
                    $tool_content .= "</tr>";
                }
            }
        }
        if ($headingsSent) {
            $tool_content .= "</table></div></div></div>";
        }

        if (get_total_bbb_servers() == '0') {
            if ($is_editor) {
                $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableTeacher</p>";
            } else {
                $tool_content .= "<p class='alert alert-danger'><b>$langNote</b>:<br />$langBBBNotServerAvailableStudent</p>";
            }
        }
        if (!$is_editor and !$headingsSent) {
            $tool_content .= "<div class='alert alert-warning'>$langNoBBBSesssions</div>";
        }
    } else {
        $tool_content .= "<div class='alert alert-warning'>$langNoBBBSesssions</div>";
    }
}
示例#2
0
文件: ext.php 项目: nikosv/openeclass
//$total = Database::get()->querySingle("SELECT COUNT(*) AS count FROM bbb_servers WHERE enabled='true'")->count;
//echo $total;

//print_r($_GET);

$mod_pw = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id'])->mod_pw;
$title = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id'])->title;
$att_pw = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id'])->att_pw;
$record = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id'])->record;
$start_date = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id'])->start_date;
$active = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id'])->active;
$unlock_interval = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id'])->unlock_interval;
$r_group = explode(",",Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id'])->external_users);

if ($active<>'1' || date_diff_in_minutes($start_date,date('Y-m-d H:i:s'))> $unlock_interval || date_diff_in_minutes(date('Y-m-d H:i:s'),$start_date) > 1440 || get_total_bbb_servers()=='0' || !in_array($_GET['username'],$r_group))
{
    echo $langBBBNoteEnableJoin;
    exit;
}
if(bbb_session_running($_GET['meeting_id']) == false)
{
    //echo $title;
    create_meeting($title,$_GET['meeting_id'],$mod_pw,$att_pw,$record);
}
# Get session capacity
$c = Database::get()->querySingle("SELECT sessionUsers FROM bbb_session where meeting_id=?s",$_GET['meeting_id']);
$sess = Database::get()->querySingle("SELECT * FROM bbb_session WHERE meeting_id=?s",$_GET['meeting_id']);
$serv = Database::get()->querySingle("SELECT * FROM bbb_servers WHERE id=?d", $sess->running_at);

if( ($c->sessionUsers > 0) && ($c->sessionUsers < get_meeting_users($serv->server_key,$serv->api_url,$_GET['meeting_id'],$sess->mod_pw)))
示例#3
0
/**
 * @brief Print a box with the details of a bbb session
 * @global type $course_id
 * @global type $tool_content 
 * @global type $is_editor
 * @global type $langNewBBBSessionStart
 * @global type $langNewBBBSessionType
 * @global type $langConfirmDelete
 * @global type $langNewBBBSessionPublic
 * @global type $langNewBBBSessionPrivate
 * @global type $langBBBSessionJoin
 * @global type $langNewBBBSessionDesc
 * @global type $course_code
 * @global type $langNote
 * @global type $langBBBNoteEnableJoin
 * @global type $langTitle
 * @global type $langActivate
 * @global type $langDeactivate
 * @global type $langModify
 * @global type $langDelete
 */
function bbb_session_details()
{
    global $course_id, $tool_content, $is_editor, $langNewBBBSessionStart, $langNewBBBSessionType;
    global $langConfirmDelete, $langNewBBBSessionPublic, $langNewBBBSessionPrivate, $langBBBSessionJoin, $langNewBBBSessionDesc;
    global $course_code;
    global $langNote, $langBBBNoteEnableJoin, $langTitle, $langActivate, $langDeactivate, $langModify, $langDelete, $langNoBBBSesssions;
    global $langBBBNotServerAvailableStudent, $langBBBNotServerAvailableTeacher;
    global $langBBBImportRecordings;
    $myGroups = Database::get()->queryArray("SELECT group_id FROM group_members WHERE user_id=?d", $_SESSION['uid']);
    $result = Database::get()->queryArray("SELECT * FROM bbb_session WHERE course_id = ?s ORDER BY id DESC", $course_id);
    if ($result) {
        if (!$is_editor) {
            $tool_content .= "<div class='alert alert-info'><label>{$langNote}</label>:<br>{$langBBBNoteEnableJoin}</div>";
        }
        $tool_content .= "<div class='row'><div class='col-md-12'><div class='table-responsive'><table class='table-default'>\n                          <tr>\n                              <th class = 'text-center'>{$langTitle}</th>\n                              <th class = 'text-center'>{$langNewBBBSessionDesc}</th>\n                              <th class = 'text-center'>{$langNewBBBSessionStart}</th>\n                              <th class = 'text-center'>{$langNewBBBSessionType}</th>\n                              <th class = 'text-center'>" . icon('fa-gears') . "</th>\n                          </tr>";
        $k = 0;
        foreach ($result as $row) {
            // Get participants groups
            $r_group = explode(",", $row->participants);
            $id = $row->id;
            $title = $row->title;
            $start_date = $row->start_date;
            $row->public == '1' ? $type = $langNewBBBSessionPublic : ($type = $langNewBBBSessionPrivate);
            $meeting_id = $row->meeting_id;
            $att_pw = $row->att_pw;
            $mod_pw = $row->mod_pw;
            $record = $row->record;
            isset($row->description) ? $desc = $row->description : ($desc = "");
            $tool_content .= "<tr " . ($is_editor && !$row->active ? "class='not_visible'" : "") . ">";
            if ($is_editor) {
                // If there no available bbb servers, disable join link. Otherwise, enable
                if (get_total_bbb_servers() == '0') {
                    $tool_content .= "\n                        <td>" . q($title) . "</td>";
                } else {
                    $tool_content .= "\n                        <td><a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;choice=do_join&amp;meeting_id={$meeting_id}&amp;title=" . urlencode($title) . "&amp;att_pw=" . urlencode($att_pw) . "&amp;mod_pw=" . urlencode($mod_pw) . "&amp;record={$record}' target='_blank'>" . q($title) . "</a></td>";
                }
                $tool_content .= "<td class='text-center'>" . $desc . "</td>\n                    <td class='text-center'>" . q($start_date) . "</td>\n                    <td class='text-center'>{$type}</td>\n                    <td class='option-btn-cell'>" . action_button(array(array('title' => $langDelete, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$row->id}&amp;choice=do_delete", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langConfirmDelete), array('title' => $langModify, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$id}&amp;choice=edit", 'icon' => 'fa-edit'), array('title' => $langBBBImportRecordings, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$row->id}&amp;choice=import_video", 'icon' => "fa-edit"), array('title' => $row->active ? $langDeactivate : $langActivate, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;id={$row->id}&amp;choice=do_" . ($row->active ? 'disable' : 'enable'), 'icon' => $row->active ? 'fa-eye' : 'fa-eye-slash')));
                $tool_content .= "</td>";
            } else {
                //Allow access to session only if user is in participant group or session is scheduled for everyone
                $access = 'false';
                foreach ($myGroups as $mg) {
                    if (in_array($mg, $r_group)) {
                        $access = 'true';
                    }
                }
                if (in_array("0", $r_group) || $access == 'true') {
                    $tool_content .= "<td class='text-center'>";
                    // Join url will be active only X minutes before scheduled time and if session is visible for users
                    if ($row->active == '1' && date_diff_in_minutes($start_date, date('Y-m-d H:i:s')) <= $row->unlock_interval && get_total_bbb_servers() != '0') {
                        $tool_content .= "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;choice=do_join&amp;title=" . urlencode($title) . "&amp;meeting_id={$meeting_id}&amp;att_pw=" . urlencode($att_pw) . "&amp;record={$record}' target='_blank'>" . q($title) . "</a>";
                    } else {
                        $tool_content .= q($title);
                    }
                    $tool_content .= "<td>" . $desc . "</td>\n                            <td class='text-center'>" . q($start_date) . "</td>\n                            <td class='text-center'>{$type}</td>\n                            <td class='text-center'>";
                    // Join url will be active only X minutes before scheduled time and if session is visible for users
                    if ($row->active == '1' && date_diff_in_minutes($start_date, date('Y-m-d H:i:s')) <= $row->unlock_interval && get_total_bbb_servers() != '0') {
                        $tool_content .= icon('fa-sign-in', $langBBBSessionJoin, "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;choice=do_join&amp;title=" . urlencode($title) . "&amp;meeting_id={$meeting_id}&amp;att_pw=" . urlencode($att_pw) . "&amp;record={$record}' target='_blank");
                    } else {
                        $tool_content .= "-</td>";
                    }
                }
            }
            $tool_content .= "</tr>";
        }
        $tool_content .= "</table></div></div></div>";
        if (get_total_bbb_servers() == '0') {
            if ($is_editor) {
                $tool_content .= "<p class='alert alert-danger'><b>{$langNote}</b>:<br />{$langBBBNotServerAvailableTeacher}</p>";
            } else {
                $tool_content .= "<p class='alert alert-danger'><b>{$langNote}</b>:<br />{$langBBBNotServerAvailableStudent}</p>";
            }
        }
    } else {
        $tool_content .= "<div class='alert alert-danger'>{$langNoBBBSesssions}</div>";
    }
}