diff --git a/plugin/bbb/config.vm.dist.php b/plugin/bbb/config.vm.dist.php index 9748a70026..a54d76b0ee 100644 --- a/plugin/bbb/config.vm.dist.php +++ b/plugin/bbb/config.vm.dist.php @@ -23,13 +23,16 @@ return array( array( 'enabled' => true, 'name' => 'DigitalOcean', - //'host' => 'server-address', - //'user'=> 'AjZjoXMEg0vm7P8QXEWOC', 'vm_client_id' => 'client_id', 'api_key' => '123456', 'vm_id' => '123456', // The VM ID we want to access 'vm_min_size_id' => '66', // VM size ID example for 512mb use 66 'vm_max_size_id' => '65' // For 1GB use 63 + ), + // The Amazon hook is not implemented yet + array( + 'enabled' => false, + 'name' => 'Amazon' ) ) ); diff --git a/plugin/bbb/lang/english.php b/plugin/bbb/lang/english.php index 9660d35221..9f78ae4ae9 100755 --- a/plugin/bbb/lang/english.php +++ b/plugin/bbb/lang/english.php @@ -52,4 +52,4 @@ $strings['plugin_tool_bbb'] = 'Video'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'There are not recording for the meeting sessions'; $strings['NoRecording'] = 'No recording'; - +$strings['ClickToContinue'] = 'Click to continue'; diff --git a/plugin/bbb/lang/french.php b/plugin/bbb/lang/french.php index 638cafd860..a349ade9b3 100755 --- a/plugin/bbb/lang/french.php +++ b/plugin/bbb/lang/french.php @@ -46,3 +46,4 @@ $strings['plugin_tool_bbb'] = 'Vidéo'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'Aucun enregistrement disponible'; $strings['NoRecording'] = "Pas d'enregistrement"; +$strings['ClickToContinue'] = 'Cliquez pour continuer'; diff --git a/plugin/bbb/lang/spanish.php b/plugin/bbb/lang/spanish.php index f2ac9a27e8..a74d72ffa5 100755 --- a/plugin/bbb/lang/spanish.php +++ b/plugin/bbb/lang/spanish.php @@ -46,3 +46,4 @@ $strings['plugin_tool_bbb'] = 'Video'; $strings['ThereAreNotRecordingsForTheMeetings'] = 'No hay grabaciones de sesiones de videoconferencia'; $strings['NoRecording'] = 'No hay grabación'; +$strings['ClickToContinue'] = 'Hacer click para continuar'; diff --git a/plugin/bbb/lib/VM.php b/plugin/bbb/lib/VM.php index 2c17b1fce0..57074240ed 100644 --- a/plugin/bbb/lib/VM.php +++ b/plugin/bbb/lib/VM.php @@ -1,4 +1,5 @@ get('tool_enable'); - $bbb_host = $plugin->get('host'); - $bbb_salt = $plugin->get('salt'); - //$course_code = api_get_course_id(); + if (empty($host)) { + $bbb_host = $plugin->get('host'); + } else { + $bbb_host = $host; + } + if (empty($salt)) { + $bbb_salt = $plugin->get('salt'); + } else { + $bbb_salt = $salt; + } $this->logout_url = api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq(); $this->table = Database::get_main_table('plugin_bbb_meeting'); @@ -65,7 +77,7 @@ class bbb return api_is_course_admin() || api_is_coach() || api_is_platform_admin(); } - /* + /** * See this file in you BBB to set up default values /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties @@ -123,8 +135,8 @@ class bbb $record = isset($params['record']) && $params['record'] ? 'true' : 'false'; $duration = isset($params['duration']) ? intval($params['duration']) : 0; // This setting currently limits the maximum conference duration, - // to avoid llingering sessions on the videoconference server #6261 - $duration = 300; + // to avoid lingering sessions on the videoconference server #6261 + $duration = 300; $bbb_params = array( 'meetingId' => $id, // REQUIRED @@ -141,11 +153,29 @@ class bbb 'duration' => $duration, // Default = 0 which means no set duration in minutes. [number] //'meta_category' => '', // Use to pass additional info to BBB server. See API docs. ); + if ($this->debug) error_log("create_meeting params: ".print_r($bbb_params,1)); - $result = $this->api->createMeetingWithXmlResponseArray($bbb_params); - if (isset($result) && (string)$result['returncode'] == 'SUCCESS') { - if ($this->debug) error_log("create_meeting result: ".print_r($result,1)); - return $this->join_meeting($meeting_name); + + $status = false; + $meeting = null; + + while ($status == false) { + $result = $this->api->createMeetingWithXmlResponseArray( + $bbb_params + ); + if (isset($result) && strval( + $result['returncode'] + ) == 'SUCCESS' + ) { + if ($this->debug) { + error_log( + "create_meeting result: " . print_r($result, 1) + ); + } + $meeting = $this->join_meeting($meeting_name, true); + + return $meeting; + } } return $this->logout; } @@ -154,7 +184,8 @@ class bbb /** * Tells whether the given meeting exists and is running * (using course code as name) - * @param string Meeting name (usually the course code) + * @param string $meeting_name Meeting name (usually the course code) + * * @return bool True if meeting exists, false otherwise * @assert ('') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false @@ -191,30 +222,68 @@ class bbb * @assert ('') === false * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false */ - public function join_meeting($meeting_name) + public function join_meeting($meeting_name, $loop = false) { - if (empty($meeting_name)) { return false; } + if (empty($meeting_name)) { + return false; + } + $pass = $this->get_user_meeting_password(); - $meeting_data = Database::select('*', $this->table, array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)), 'first'); - if (empty($meeting_data)) { + + $meeting_data = Database::select( + '*', + $this->table, + array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)), + 'first' + ); + + if (empty($meeting_data) || !is_array($meeting_data)) { if ($this->debug) error_log("meeting does not exist: $meeting_name "); return false; } - $meeting_is_running_info = $this->api->isMeetingRunningWithXmlResponseArray($meeting_data['id']); - $meeting_is_running = $meeting_is_running_info['running'] == 'true' ? true : false; + $params = array( + 'meetingId' => $meeting_data['id'], + // -- REQUIRED - The unique id for the meeting + 'password' => $this->get_mod_meeting_password() + // -- REQUIRED - The moderator password for the meeting + ); - if ($this->debug) error_log("meeting is running: ".$meeting_is_running); + $status = false; + $meeting_info_exists = false; + while ($status == false) { - $params = array( - 'meetingId' => $meeting_data['id'], // -- REQUIRED - The unique id for the meeting - 'password' => $this->get_mod_meeting_password() // -- REQUIRED - The moderator password for the meeting - ); + $meeting_is_running_info = $this->get_meeting_info($params); - $meeting_info_exists = $this->get_meeting_info($params); + error_log(print_r($meeting_is_running_info, 1)); - if (isset($meeting_is_running) && $meeting_info_exists) { + if (strval($meeting_is_running_info['returncode']) == 'SUCCESS' && + isset($meeting_is_running_info['meetingName']) && + !empty($meeting_is_running_info['meetingName']) + //strval($meeting_is_running_info['running']) == 'true' + ) { + $meeting_info_exists = true; + } + + if ($this->debug) { + error_log( + "meeting is running: " . intval($meeting_info_exists) + ); + } + + if ($meeting_info_exists) { + $status = true; + } + + if ($loop) { + continue; + } else { + break; + } + } + + if ($meeting_info_exists) { $joinParams = array( 'meetingId' => $meeting_data['id'], // -- REQUIRED - A unique id for the meeting 'username' => $this->user_complete_name, //-- REQUIRED - The name that will display for the user in the meeting @@ -495,6 +564,7 @@ class bbb } } } + return false; } @@ -509,4 +579,41 @@ class bbb return true; //return BigBlueButtonBN::isServerRunning($this->protocol.$this->url); } + + /** + * Get active session in the all platform + */ + public function getActiveSessionsCount() + { + $meetingList = Database::select( + 'count(id) as count', + $this->table, + array('where' => array('status = ?' => array(1))), + 'first' + ); + + return $meetingList['count']; + } + + /** + * @param string $url + */ + public function redirectToBBB($url) + { + if (file_exists(__DIR__ . '/../config.vm.php')) { + // Using VM + echo Display::url(get_lang('ClickToContinue'), $url); + exit; + } else { + // Classic + header("Location: $url"); + exit; + } + + // js + /*echo ''; + exit;*/ + } } diff --git a/plugin/bbb/lib/vm/AbstractVM.php b/plugin/bbb/lib/vm/AbstractVM.php index 8c33e45e5c..4c9527f687 100644 --- a/plugin/bbb/lib/vm/AbstractVM.php +++ b/plugin/bbb/lib/vm/AbstractVM.php @@ -1,4 +1,5 @@ plugin_enabled) { if ($bbb->meeting_exists($meeting_params['meeting_name'])) { $url = $bbb->join_meeting($meeting_params['meeting_name']); if ($url) { - header('location: '.$url); - exit; + $bbb->redirectToBBB($url); } else { $url = $bbb->create_meeting($meeting_params); - header('location: '.$url); - exit; + $bbb->redirectToBBB($url); } } else { if ($bbb->is_teacher()) { $url = $bbb->create_meeting($meeting_params); - header('location: '.$url); - exit; + $bbb->redirectToBBB($url); } else { $url = 'listing.php?'.api_get_cidreq(); - header('location: '.$url); - exit; + $bbb->redirectToBBB($url); } } } else { $url = 'listing.php?'.api_get_cidreq(); - header('location: '.$url); + header('Location: ' . $url); exit; } } else {