//$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)))
/** * @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&choice=do_join&meeting_id=" . urlencode($meeting_id) . "&title=".urlencode($title)."&att_pw=".urlencode($att_pw)."&mod_pw=".urlencode($mod_pw)."&record=$record' target='_blank'>" . q($title) . "</a>"; }else { //$joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&choice=do_join&meeting_id=" . urlencode($meeting_id) . "&att_pw=".urlencode($att_pw)."' target='_blank'>" . q($title) . "</a>"; $joinLink = "<a href='$_SERVER[SCRIPT_NAME]?course=$course_code&choice=do_join&meeting_id=" . urlencode($meeting_id) . "&title=".urlencode($title)."&att_pw=".urlencode($att_pw)."&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&id=" . getIndirectReference($id) . "&choice=edit", 'icon' => 'fa-edit'), array( 'title' => $langBBBImportRecordings, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=" . getIndirectReference($row->id) . "&choice=import_video", 'icon' => "fa-edit"), array( 'title' => $row->active? $langDeactivate : $langActivate, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=" . getIndirectReference($row->id) . "&choice=do_". ($row->active? 'disable' : 'enable'), 'icon' => $row->active ? 'fa-eye': 'fa-eye-slash'), array( 'title' => $langDelete, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&id=" . getIndirectReference($row->id) . "&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&choice=do_join&title=".urlencode($title)."&meeting_id=" . urlencode($meeting_id) . "&att_pw=".urlencode($att_pw)."&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>"; } }
/** * @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}&choice=do_join&meeting_id={$meeting_id}&title=" . urlencode($title) . "&att_pw=" . urlencode($att_pw) . "&mod_pw=" . urlencode($mod_pw) . "&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}&id={$row->id}&choice=do_delete", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langConfirmDelete), array('title' => $langModify, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$id}&choice=edit", 'icon' => 'fa-edit'), array('title' => $langBBBImportRecordings, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$row->id}&choice=import_video", 'icon' => "fa-edit"), array('title' => $row->active ? $langDeactivate : $langActivate, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&id={$row->id}&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}&choice=do_join&title=" . urlencode($title) . "&meeting_id={$meeting_id}&att_pw=" . urlencode($att_pw) . "&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}&choice=do_join&title=" . urlencode($title) . "&meeting_id={$meeting_id}&att_pw=" . urlencode($att_pw) . "&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>"; } }
/** * Function lessonToolsMenu * * Creates a multi-dimensional array of the user's tools * in regard to the user's user level * (student | professor | platform administrator) * * @return array */ function lessonToolsMenu() { global $uid, $is_editor, $is_course_admin, $courses, $course_code, $langAdministrationTools, $langExternalLinks, $modules, $admin_modules, $urlAppend, $status, $course_id; $sideMenuGroup = array(); $sideMenuSubGroup = array(); $sideMenuText = array(); $sideMenuLink = array(); $sideMenuImg = array(); $sideMenuID = array(); $arrMenuType = array(); $arrMenuType['type'] = 'none'; if ($is_editor || $is_course_admin) { $tools_sections = array(array('type' => 'Public', 'title' => $GLOBALS['langActiveTools'], 'iconext' => '_on.png', 'class' => 'active'), array('type' => 'PublicButHide', 'title' => $GLOBALS['langInactiveTools'], 'iconext' => '_off.png', 'class' => 'inactive')); } else { $tools_sections = array(array('type' => 'Public', 'title' => $GLOBALS['langCourseOptions'], 'iconext' => '_on.png', 'class' => 'active')); } foreach ($tools_sections as $section) { $result = getToolsArray($section['type']); $sideMenuSubGroup = array(); $sideMenuText = array(); $sideMenuLink = array(); $sideMenuImg = array(); $sideMenuID = array(); $mail_status = ''; $arrMenuType = array('type' => 'text', 'text' => $section['title'], 'class' => $section['class']); array_push($sideMenuSubGroup, $arrMenuType); setlocale(LC_COLLATE, $GLOBALS['langLocale']); usort($result, function ($a, $b) { global $modules; return strcoll($modules[$a->module_id]['title'], $modules[$b->module_id]['title']); }); // check if we have define mail address and want to receive messages if ($uid and $status != USER_GUEST and !get_user_email_notification($uid, $course_id)) { $mail_status = ' ' . icon('fa-exclamation-triangle'); } foreach ($result as $toolsRow) { $mid = $toolsRow->module_id; // hide groups for unregistered users if ($mid == MODULE_ID_GROUPS and !$courses[$course_code]) { continue; } // hide teleconference when no BBB servers are enabled if ($mid == MODULE_ID_BBB and !get_total_bbb_servers()) { continue; } // if we are in dropbox or announcements add (if needed) mail address status if ($mid == MODULE_ID_DROPBOX or $mid == MODULE_ID_ANNOUNCE) { if ($mid == MODULE_ID_DROPBOX) { $mbox = new Mailbox($uid, course_code_to_id($course_code)); $new_msgs = $mbox->unreadMsgsNumber(); if ($new_msgs != 0) { array_push($sideMenuText, '<b>' . q($modules[$mid]['title']) . " $mail_status<span class='badge pull-right'>$new_msgs</span></b>"); } else { array_push($sideMenuText, q($modules[$mid]['title']).' '.$mail_status); } } else { array_push($sideMenuText, q($modules[$mid]['title']).' '.$mail_status); } } elseif ($mid == MODULE_ID_DOCS and ($new_docs = get_new_document_count($course_id))) { array_push($sideMenuText, '<b>' . q($modules[$mid]['title']) . "<span class='badge pull-right'>$new_docs</span></b>"); } else { array_push($sideMenuText, q($modules[$mid]['title'])); } array_push($sideMenuLink, q($urlAppend . 'modules/' . $modules[$mid]['link'] . '/?course=' . $course_code)); array_push($sideMenuImg, $modules[$mid]['image'] . $section['iconext']); array_push($sideMenuID, $mid); } array_push($sideMenuSubGroup, $sideMenuText); array_push($sideMenuSubGroup, $sideMenuLink); array_push($sideMenuSubGroup, $sideMenuImg); array_push($sideMenuSubGroup, $sideMenuID); array_push($sideMenuGroup, $sideMenuSubGroup); } $result2 = getExternalLinks(); if ($result2) { // display external link (if any) $sideMenuSubGroup = array(); $sideMenuText = array(); $sideMenuLink = array(); $sideMenuImg = array(); $arrMenuType = array('type' => 'text', 'text' => $langExternalLinks, 'class' => 'external'); array_push($sideMenuSubGroup, $arrMenuType); foreach ($result2 as $ex_link) { array_push($sideMenuText, q($ex_link->title)); array_push($sideMenuLink, q($ex_link->url)); array_push($sideMenuImg, 'fa-external-link'); } array_push($sideMenuSubGroup, $sideMenuText); array_push($sideMenuSubGroup, $sideMenuLink); array_push($sideMenuSubGroup, $sideMenuImg); array_push($sideMenuGroup, $sideMenuSubGroup); } if ($is_course_admin) { // display course admin tools $sideMenuSubGroup = array(); $sideMenuText = array(); $sideMenuLink = array(); $sideMenuImg = array(); $sideMenuID = array(); $arrMenuType = array('type' => 'text', 'text' => $langAdministrationTools, 'class' => 'course_admin'); array_push($sideMenuSubGroup, $arrMenuType); foreach ($admin_modules as $adm_mod) { array_push($sideMenuText, $adm_mod['title']); array_push($sideMenuLink, q($urlAppend . 'modules/' . $adm_mod['link'] . '/?course=' . $course_code)); array_push($sideMenuImg, $adm_mod['image'] . $section['iconext']); } array_push($sideMenuSubGroup, $sideMenuText); array_push($sideMenuSubGroup, $sideMenuLink); array_push($sideMenuSubGroup, $sideMenuImg); array_push($sideMenuSubGroup, $sideMenuID); array_push($sideMenuGroup, $sideMenuSubGroup); } return $sideMenuGroup; }
'level' => 'primary-label'))); } else { if (isset($_GET['id'])) { $tool_content .= action_bar(array( array('title' => $langBack, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code", 'icon' => 'fa-reply', 'level' => 'primary-label'))); } else { $tool_content .= action_bar(array( array('title' => $langNewBBBSession, 'url' => "$_SERVER[SCRIPT_NAME]?course=$course_code&add=1", 'icon' => 'fa-plus-circle', 'button-class' => 'btn-success', 'level' => 'primary-label', 'show' => get_total_bbb_servers()))); } } } if (isset($_GET['add'])) { $navigation[] = array('url' => "$_SERVER[SCRIPT_NAME]?course=$course_code", 'name' => $langBBB); new_bbb_session(); } elseif(isset($_POST['update_bbb_session'])) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); $startDate_obj = DateTime::createFromFormat('d-m-Y H:i', $_POST['start_session']); $start = $startDate_obj->format('Y-m-d H:i:s'); //update_bbb_session($_GET['id'],$_POST['title'], $_POST['desc'], $start, $_POST['type'] ,$_POST['status'],(isset($_POST['notifyUsers']) ? '1' : '0'),$_POST['minutes_before'],$_POST['external_users'],$_POST['record'],$_POST['sessionUsers']); update_bbb_session(getDirectReference($_GET['id']),$_POST['title'], $_POST['desc'], $start, '0' ,$_POST['status'],(isset($_POST['notifyUsers']) ? '1' : '0'),$_POST['minutes_before'],$_POST['external_users'],$_POST['record'],$_POST['sessionUsers']);