');
-// Members per group
+ // Members per group
$form->addElement('textarea', 'description', get_lang('Description'), array ('class' => 'span6', 'rows' => 6));
$form->addElement('html', '
');
$form->addElement('html', '
');
diff --git a/main/group/group_creation.php b/main/group/group_creation.php
index 2184efe5f4..c90c2cbdf7 100644
--- a/main/group/group_creation.php
+++ b/main/group/group_creation.php
@@ -19,7 +19,7 @@ api_protect_course_script(true);
/* Create the groups */
-if (isset ($_POST['action'])) {
+if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'create_groups':
$groups = array();
diff --git a/main/inc/ajax/admin.ajax.php b/main/inc/ajax/admin.ajax.php
index 84e867b378..fa08af3a28 100644
--- a/main/inc/ajax/admin.ajax.php
+++ b/main/inc/ajax/admin.ajax.php
@@ -108,6 +108,9 @@ function check_system_version()
$number_of_users = Statistics::count_users();
$number_of_active_users = Statistics::count_users(null, null, null, true);
+ // The number of sessions
+ $number_of_sessions = Statistics::count_sessions();
+
$data = array(
'url' => api_get_path(WEB_PATH),
'campus' => api_get_setting('siteName'),
@@ -116,6 +119,7 @@ function check_system_version()
'numberofcourses' => $number_of_courses,
'numberofusers' => $number_of_users,
'numberofactiveusers' => $number_of_active_users,
+ 'numberofsessions' => $number_of_sessions,
//The donotlistcampus setting recovery should be improved to make
// it true by default - this does not affect numbers counting
'donotlistcampus' => api_get_setting('donotlistcampus'),
diff --git a/main/inc/ajax/course.ajax.php b/main/inc/ajax/course.ajax.php
index a9b7ab21b8..a024108c46 100644
--- a/main/inc/ajax/course.ajax.php
+++ b/main/inc/ajax/course.ajax.php
@@ -10,25 +10,24 @@ $user_id = api_get_user_id();
switch ($action) {
case 'add_course_vote':
-
- $course_id = intval($_REQUEST['course_id']);
+ $course_id = intval($_REQUEST['course_id']);
$star = intval($_REQUEST['star']);
if (!api_is_anonymous()) {
CourseManager::add_course_vote($user_id, $star, $course_id, 0);
}
- $point_info = CourseManager::get_course_ranking($course_id, 0);
- $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
- $rating = Display::return_rating_system('star_'.$course_id, $ajax_url.'&course_id='.$course_id, $point_info, false);
- echo $rating;
+ $point_info = CourseManager::get_course_ranking($course_id, 0);
+ $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
+ $rating = Display::return_rating_system('star_'.$course_id, $ajax_url.'&course_id='.$course_id, $point_info, false);
+ echo $rating;
break;
- case 'get_user_courses':
+ case 'get_user_courses':
if (api_is_platform_admin()) {
$user_id = intval($_POST['user_id']);
$list_course_all_info = CourseManager::get_courses_list_by_user_id($user_id, false);
if (!empty($list_course_all_info)) {
- foreach($list_course_all_info as $course_item) {
+ foreach ($list_course_all_info as $course_item) {
$course_info = api_get_course_info($course_item['code']);
echo $course_info['title'].' ';
}
@@ -37,6 +36,200 @@ switch ($action) {
}
}
break;
+ case 'search_category':
+ require_once api_get_path(LIBRARY_PATH).'course_category.lib.php';
+ if (api_is_platform_admin() || api_is_allowed_to_create_course()) {
+ $results = searchCategoryByKeyword($_REQUEST['q']);
+ if (!empty($results)) {
+ foreach ($results as &$item) {
+ $item['id'] = $item['code'];
+ }
+ echo json_encode($results);
+ } else {
+ echo json_encode(array());
+ }
+ }
+ break;
+ case 'search_course':
+ if (api_is_platform_admin()) {
+ if (!empty($_GET['session_id']) && intval($_GET['session_id'])) {
+ //if session is defined, lets find only courses of this session
+ $courseList = SessionManager::get_course_list_by_session_id(
+ $_GET['session_id'],
+ $_GET['q']
+ );
+ } else {
+ //if session is not defined lets search all courses STARTING with $_GET['q']
+ //TODO change this function to search not only courses STARTING with $_GET['q']
+ $courseList = CourseManager::get_courses_list(
+ 0, //offset
+ 0, //howMany
+ 1, //$orderby = 1
+ 'ASC',
+ -1, //visibility
+ $_GET['q'],
+ null, //$urlId
+ true //AlsoSearchCode
+ );
+ }
+
+ $results = array();
+
+ require_once api_get_path(LIBRARY_PATH).'course_category.lib.php';
+
+ if (!empty($courseList)) {
+
+ foreach ($courseList as $courseInfo) {
+ $title = $courseInfo['title'];
+
+ if (!empty($courseInfo['category_code'])) {
+ $parents = getParentsToString($courseInfo['category_code']);
+ $title = $parents.$courseInfo['title'];
+ }
+
+ $results[] = array(
+ 'id' => $courseInfo['id'],
+ 'text' => $title
+ );
+ }
+ echo json_encode($results);
+ } else {
+ echo json_encode(array());
+ }
+ }
+ break;
+ case 'search_course_by_session':
+ if (api_is_platform_admin()) {
+ $results = SessionManager::get_course_list_by_session_id($_GET['session_id'], $_GET['q']);
+
+ //$results = SessionManager::get_sessions_list(array('s.name LIKE' => "%".$_REQUEST['q']."%"));
+ $results2 = array();
+ if (!empty($results)) {
+ foreach ($results as $item) {
+ $item2 = array();
+ foreach ($item as $id => $internal) {
+ if ($id == 'id') {
+ $item2[$id] = $internal;
+ }
+ if ($id == 'title') {
+ $item2['text'] = $internal;
+ }
+ }
+ $results2[] = $item2;
+ }
+ echo json_encode($results2);
+ } else {
+ echo json_encode(array());
+ }
+ }
+ break;
+ case 'search_course_by_session_all':
+ if (api_is_platform_admin()) {
+ if ($_GET['session_id'] == 'TODOS' || $_GET['session_id'] == 'T') {
+ $_GET['session_id'] = '%';
+ }
+
+ $results = SessionManager::get_course_list_by_session_id_like(
+ $_GET['session_id'],
+ $_GET['q']
+ );
+ $results2 = array();
+ if (!empty($results)) {
+ foreach ($results as $item) {
+ $item2 = array();
+ foreach ($item as $id => $internal) {
+ if ($id == 'id') {
+ $item2[$id] = $internal;
+ }
+ if ($id == 'title') {
+ $item2['text'] = $internal;
+ }
+ }
+ $results2[] = $item2;
+ }
+ echo json_encode($results2);
+ } else {
+ echo json_encode(array());
+ }
+ }
+ break;
+ case 'search_user_by_course':
+ if (api_is_platform_admin()) {
+ $user = Database :: get_main_table(TABLE_MAIN_USER);
+ $session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+
+ $course = api_get_course_info_by_id($_GET['course_id']);
+
+ $sql = "SELECT u.user_id as id, u.username, u.lastname, u.firstname
+ FROM $user u
+ INNER JOIN $session_course_user r ON u.user_id = r.id_user
+ WHERE id_session = %d AND course_code = '%s'
+ AND (u.firstname LIKE '%s' OR u.username LIKE '%s' OR u.lastname LIKE '%s')";
+ $needle = '%' . $_GET['q'] . '%';
+ $sql_query = sprintf($sql, $_GET['session_id'], $course['code'], $needle, $needle, $needle);
+
+ $result = Database::query($sql_query);
+ while ($user = Database::fetch_assoc($result)) {
+ $data[] = array('id' => $user['id'], 'text' => $user['username'] . ' (' . $user['firstname'] . ' ' . $user['lastname'] . ')');
+
+ }
+ if (!empty($data)) {
+ echo json_encode($data);
+ } else {
+ echo json_encode(array());
+ }
+ }
+ break;
+ case 'search_exercise_by_course':
+ if (api_is_platform_admin()) {
+ $course = api_get_course_info_by_id($_GET['course_id']);
+ require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
+ $session_id = (!empty($_GET['session_id'])) ? intval($_GET['session_id']) : 0 ;
+ $exercises = get_all_exercises($course, $session_id, false, $_GET['q'], true, 3);
+
+ foreach ($exercises as $exercise) {
+ $data[] = array('id' => $exercise['id'], 'text' => html_entity_decode($exercise['title']) );
+ }
+ if (!empty($data)) {
+ $data[] = array('id' => 'T', 'text' => 'TODOS');
+ echo json_encode($data);
+ } else {
+ echo json_encode(array(array('id' => 'T', 'text' => 'TODOS')));
+ }
+ }
+ break;
+ case 'search_survey_by_course':
+ if (api_is_platform_admin()) {
+ $survey = Database :: get_course_table(TABLE_SURVEY);
+
+ $sql = "SELECT survey_id as id, title, anonymous
+ FROM $survey
+ WHERE
+ c_id = %d AND
+ session_id = %d AND
+ title LIKE '%s'";
+
+ $sql_query = sprintf(
+ $sql,
+ intval($_GET['course_id']),
+ intval($_GET['session_id']),
+ '%' . Database::escape_string($_GET['q']).'%'
+ );
+ $result = Database::query($sql_query);
+ while ($survey = Database::fetch_assoc($result)) {
+ $survey['title'] .= ($survey['anonymous'] == 1) ? ' (' . get_lang('Anonymous') . ')' : '';
+ $data[] = array(
+ 'id' => $survey['id'],
+ 'text' => strip_tags(html_entity_decode($survey['title']))
+ );
+ }
+ if (!empty($data)) {
+ echo json_encode($data);
+ } else {
+ echo json_encode(array());
+ }
+ }
+ break;
default:
echo '';
}
diff --git a/main/inc/ajax/events.ajax.php b/main/inc/ajax/events.ajax.php
index f5ec86a4a6..ee153087b7 100644
--- a/main/inc/ajax/events.ajax.php
+++ b/main/inc/ajax/events.ajax.php
@@ -7,7 +7,7 @@ $event_name = isset($_REQUEST['eventName']) ? $_REQUEST['eventName'] : null;
api_protect_admin_script();
switch ($action) {
- case 'getEventTypes':
+ case 'getEventTypes':
$events = get_all_event_types();
print json_encode($events);
break;
@@ -15,7 +15,7 @@ switch ($action) {
$users = UserManager::get_user_list();
print json_encode($users);
break;
- case 'get_event_users' :
+ case 'get_event_users':
$users = get_event_users($event_name);
print json_encode($users);
break;
diff --git a/plugin/bbb/config.php b/plugin/bbb/config.php
index 2eb503d6ee..4f74dc1c5e 100644
--- a/plugin/bbb/config.php
+++ b/plugin/bbb/config.php
@@ -3,7 +3,7 @@
/* bbb parameters that will be registered in the course settings */
-//require_once '../../main/inc/global.inc.php';
+require_once __DIR__ . '/../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'plugin.class.php';
require_once 'lib/bbb.lib.php';
diff --git a/plugin/bbb/lang/english.php b/plugin/bbb/lang/english.php
index 9660d35221..9f78ae4ae9 100644
--- 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 100644
--- 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 100644
--- 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/bbb.lib.php b/plugin/bbb/lib/bbb.lib.php
index 945ae62cf3..59e7269568 100644
--- a/plugin/bbb/lib/bbb.lib.php
+++ b/plugin/bbb/lib/bbb.lib.php
@@ -1,39 +1,51 @@
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';
+ $this->logout_url = api_get_path(WEB_PLUGIN_PATH).'bbb/listing.php?'.api_get_cidreq();
$this->table = Database::get_main_table('plugin_bbb_meeting');
if ($bbb_plugin == true) {
@@ -55,15 +67,17 @@ class bbb {
$this->plugin_enabled = true;
}
}
+
/**
* Checks whether a user is teacher in the current course
* @return bool True if the user can be considered a teacher in this course, false otherwise
*/
- function is_teacher() {
+ public function is_teacher()
+ {
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
@@ -94,9 +108,11 @@ class bbb {
defaultMeetingCreateJoinDuration=5
*
*/
- function create_meeting($params) {
+ public function create_meeting($params)
+ {
$params['c_id'] = api_get_course_int_id();
$course_code = api_get_course_id();
+ $params['session_id'] = api_get_session_id();
$attende_password = $params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id();
$moderator_password = $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->get_mod_meeting_password();
@@ -114,13 +130,13 @@ class bbb {
if ($id) {
if ($this->debug) error_log("create_meeting: $id ");
- $meeting_name = isset($params['meeting_name']) ? $params['meeting_name'] : api_get_course_id();
+ $meeting_name = isset($params['meeting_name']) ? $params['meeting_name'] : api_get_course_id().'-'.api_get_session_id();
$welcome_msg = isset($params['welcome_msg']) ? $params['welcome_msg'] : null;
$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
@@ -137,27 +153,59 @@ 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;
}
}
+
/**
- * Tells whether the given meeting exists and is running
+ * 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
*/
- function meeting_exists($meeting_name) {
+ public function meeting_exists($meeting_name)
+ {
if (empty($meeting_name)) { return false; }
$course_id = api_get_course_int_id();
- $meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND meeting_name = ? AND status = 1 ' => array($course_id, $meeting_name))), 'first');
+ $session_id = api_get_session_id();
+ $meeting_data = Database::select(
+ '*',
+ $this->table,
+ array(
+ 'where' => array(
+ 'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 ' =>
+ array($course_id, $session_id, $meeting_name)
+ )
+ ),
+ 'first'
+ );
if ($this->debug) error_log("meeting_exists ".print_r($meeting_data,1));
if (empty($meeting_data)) {
return false;
@@ -174,28 +222,68 @@ class bbb {
* @assert ('') === false
* @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false
*/
- function join_meeting($meeting_name) {
- if (empty($meeting_name)) { return false; }
+ public function join_meeting($meeting_name, $loop = 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
@@ -212,13 +300,15 @@ class bbb {
if ($this->debug) error_log("return url :".$url);
return $url;
}
+
/**
* Get information about the given meeting
* @param array ...?
* @return mixed Array of information on success, false on error
* @assert (array()) === false
*/
- function get_meeting_info($params) {
+ public function get_meeting_info($params)
+ {
try {
$result = $this->api->getMeetingInfoWithXmlResponseArray($params);
if ($result == null) {
@@ -236,9 +326,10 @@ class bbb {
* Gets all the course meetings saved in the plugin_bbb_meeting table
* @return array Array of current open meeting rooms
*/
- function get_course_meetings() {
+ public function get_course_meetings()
+ {
$pass = $this->get_user_meeting_password();
- $meeting_list = Database::select('*', $this->table, array('where' => array('c_id = ? ' => api_get_course_int_id())));
+ $meeting_list = Database::select('*', $this->table, array('where' => array('c_id = ? AND session_id = ? ' => array(api_get_course_int_id(), api_get_session_id()))));
$new_meeting_list = array();
$item = array();
@@ -315,6 +406,7 @@ class bbb {
$item['created_at'] = api_convert_and_format_date($meeting_db['created_at']);
//created_at
+ $meeting_db['created_at'] = $item['created_at']; //avoid overwrite in array_merge() below
$item['publish_url'] = api_get_self().'?'.api_get_cidreq().'&action=publish&id='.$meeting_db['id'];
$item['unpublish_url'] = api_get_self().'?'.api_get_cidreq().'&action=unpublish&id='.$meeting_db['id'];
@@ -335,18 +427,23 @@ class bbb {
}
return $new_meeting_list;
}
+
/**
* Function disabled
*/
- function publish_meeting($id) {
+ public function publish_meeting($id)
+ {
//return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt);
}
+
/**
* Function disabled
*/
- function unpublish_meeting($id) {
+ public function unpublish_meeting($id)
+ {
//return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
}
+
/**
* Closes a meeting (usually when the user click on the close button from
* the conferences listing.
@@ -354,7 +451,8 @@ class bbb {
* @return void
* @assert (0) === false
*/
- function end_meeting($id) {
+ public function end_meeting($id)
+ {
if (empty($id)) { return false; }
$pass = $this->get_user_meeting_password();
$endParams = array(
@@ -364,22 +462,26 @@ class bbb {
$this->api->endMeetingWithXmlResponseArray($endParams);
Database::update($this->table, array('status' => 0, 'closed_at' => api_get_utc_datetime()), array('id = ? ' => $id));
}
+
/**
* Gets the password for a specific meeting for the current user
* @return string A moderator password if user is teacher, or the course code otherwise
*/
- function get_user_meeting_password() {
+ public function get_user_meeting_password()
+ {
if ($this->is_teacher()) {
return $this->get_mod_meeting_password();
} else {
return api_get_course_id();
}
}
+
/**
* Generated a moderator password for the meeting
* @return string A password for the moderation of the videoconference
*/
- function get_mod_meeting_password() {
+ public function get_mod_meeting_password()
+ {
return api_get_course_id().'mod';
}
@@ -388,9 +490,11 @@ class bbb {
* @return int The number of users currently connected to the videoconference
* @assert () > -1
*/
- function get_users_online_in_current_room() {
+ public function get_users_online_in_current_room()
+ {
$course_id = api_get_course_int_id();
- $meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND status = 1 ' => $course_id)), 'first');
+ $session_id = api_get_session_id();
+ $meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND session_id = ? AND status = 1 ' => array($course_id, $session_id))), 'first');
if (empty($meeting_data)) {
return 0;
}
@@ -403,19 +507,21 @@ class bbb {
}
return 0;
}
+
/**
* Deletes a previous recording of a meeting
- * @param int intergal ID of the recording
+ * @param int integral ID of the recording
* @return array ?
* @assert () === false
* @todo Also delete links and agenda items created from this recording
*/
- function delete_record($ids) {
+ public function delete_record($ids)
+ {
if (empty($ids) or (is_array($ids) && count($ids)==0)) { return false; }
$recordingParams = array(
/*
- * NOTE: Set the recordId below to a valid id after you have
- * created a recorded meeting, and received a real recordID
+ * NOTE: Set the recordId below to a valid id after you have
+ * created a recorded meeting, and received a real recordID
* back from your BBB server using the
* getRecordingsWithXmlResponseArray method.
*/
@@ -425,6 +531,7 @@ class bbb {
);
return $this->api->deleteRecordingsWithXmlResponseArray($recordingParams);
}
+
/**
* Creates a link in the links tool from the given videoconference recording
* @param int ID of the item in the plugin_bbb_meeting table
@@ -434,7 +541,8 @@ class bbb {
* @assert (1, null) === false
* @assert (null, 'abcdefabcdefabcdefabcdef') === false
*/
- function copy_record_to_link_tool($id, $record_id) {
+ public function copy_record_to_link_tool($id, $record_id)
+ {
if (empty($id) or empty($record_id)) {
return false;
}
@@ -456,16 +564,56 @@ class bbb {
}
}
}
+
return false;
}
+
/**
* Checks if the videoconference server is running.
* Function currently disabled (always returns 1)
* @return bool True if server is running, false otherwise
* @assert () === false
*/
- function is_server_running() {
+ public function is_server_running()
+ {
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/bbb_api.php b/plugin/bbb/lib/bbb_api.php
index 630d52d3be..7c67feb301 100644
--- a/plugin/bbb/lib/bbb_api.php
+++ b/plugin/bbb/lib/bbb_api.php
@@ -164,7 +164,7 @@ class BigBlueButtonBN {
*/
$xml = $this->_processXmlResponse($this->getCreateMeetingURL($creationParams));
- if($xml) {
+ if ($xml) {
if($xml->meetingID)
return array(
'returncode' => $xml->returncode,
@@ -247,7 +247,7 @@ class BigBlueButtonBN {
);
*/
$xml = $this->_processXmlResponse($this->getEndMeetingURL($endParams));
- if($xml) {
+ if ($xml) {
return array(
'returncode' => $xml->returncode,
'message' => $xml->message,
diff --git a/plugin/bbb/lib/bbb_plugin.class.php b/plugin/bbb/lib/bbb_plugin.class.php
index fc4284671c..9d0919ab5f 100644
--- a/plugin/bbb/lib/bbb_plugin.class.php
+++ b/plugin/bbb/lib/bbb_plugin.class.php
@@ -6,26 +6,35 @@
* main/img/icons/64/plugin_name.png
* main/img/icons/64/plugin_name_na.png
*/
+
+/**
+ * Class BBBPlugin
+ */
class BBBPlugin extends Plugin
{
- public $is_course_plugin = true;
+ public $isCoursePlugin = true;
//When creating a new course this settings are added to the course
public $course_settings = array(
-// array('name' => 'big_blue_button_welcome_message', 'type' => 'text'),
- array('name' => 'big_blue_button_record_and_store', 'type' => 'checkbox')
+ array(
+ 'name' => 'big_blue_button_record_and_store',
+ 'type' => 'checkbox'
+ )
);
- static function create() {
+ static function create()
+ {
static $result = null;
return $result ? $result : $result = new self();
}
- protected function __construct() {
- parent::__construct('2.0', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text'));
+ protected function __construct()
+ {
+ parent::__construct('2.1', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text'));
}
- function install() {
+ public function install()
+ {
$table = Database::get_main_table('plugin_bbb_meeting');
$sql = "CREATE TABLE IF NOT EXISTS $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
@@ -38,14 +47,16 @@ class BBBPlugin extends Plugin
created_at VARCHAR(255) NOT NULL,
closed_at VARCHAR(255) NOT NULL,
calendar_id INT DEFAULT 0,
- welcome_msg VARCHAR(255) NOT NULL DEFAULT '')";
+ welcome_msg VARCHAR(255) NOT NULL DEFAULT '',
+ session_id INT unsigned DEFAULT 0)";
Database::query($sql);
//Installing course settings
$this->install_course_fields_in_all_courses();
}
- function uninstall() {
+ public function uninstall()
+ {
$t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
@@ -70,13 +81,13 @@ class BBBPlugin extends Plugin
Database::query($sql);
//hack to get rid of Database::query warning (please add c_id...)
- $sql = "DELETE FROM $t_tool WHERE name = 'bbb' AND c_id = c_id";
+ $sql = "DELETE FROM $t_tool WHERE name = 'bbb'";//" AND c_id = c_id";
Database::query($sql);
$sql = "DROP TABLE IF EXISTS plugin_bbb_meeting";
Database::query($sql);
//Deleting course settings
- $this->uninstall_course_fields_in_all_courses();
+ $this->uninstall_course_fields_in_all_courses($this->course_settings);
}
}
diff --git a/plugin/bbb/listing.php b/plugin/bbb/listing.php
index 265d06786e..2b152a951f 100644
--- a/plugin/bbb/listing.php
+++ b/plugin/bbb/listing.php
@@ -32,7 +32,14 @@ if ($teacher) {
$title = sprintf(get_lang('VideoConferenceXCourseX'), $id, $course_info['name']);
$content = Display::url(get_lang('GoToTheVideoConference'), $_GET['url']);
- $event_id = $agenda->add_event($_REQUEST['start'], null, 'true', null, $title, $content, array('everyone'));
+ $event_id = $agenda->add_event(
+ $_REQUEST['start'],
+ null,
+ 'true',
+ $title,
+ $content,
+ array('everyone')
+ );
if (!empty($event_id)) {
$message = Display::return_message(get_lang('VideoConferenceAddedToTheCalendar'), 'success');
} else {
@@ -57,7 +64,28 @@ if ($teacher) {
break;
case 'end':
$bbb->end_meeting($_GET['id']);
- $message = Display::return_message(get_lang('MeetingClosed').' '.get_lang('MeetingClosedComment'), 'success', false);
+ $message = Display::return_message(
+ get_lang('MeetingClosed') . ' ' . get_lang(
+ 'MeetingClosedComment'
+ ),
+ 'success',
+ false
+ );
+
+ if (file_exists(__DIR__ . '/config.vm.php')) {
+ require __DIR__ . '/../../vendor/autoload.php';
+
+ require __DIR__ . '/lib/vm/AbstractVM.php';
+ require __DIR__ . '/lib/vm/VMInterface.php';
+ require __DIR__ . '/lib/vm/DigitalOceanVM.php';
+ require __DIR__ . '/lib/VM.php';
+
+ $config = require __DIR__ . '/config.vm.php';
+
+ $vm = new VM($config);
+ $vm->resizeToMinLimit();
+ }
+
break;
case 'publish':
//$result = $bbb->publish_meeting($_GET['id']);
@@ -76,7 +104,7 @@ if (!empty($meetings)) {
}
$users_online = $bbb->get_users_online_in_current_room();
$status = $bbb->is_server_running();
-$meeting_exists = $bbb->meeting_exists(api_get_course_id());
+$meeting_exists = $bbb->meeting_exists(api_get_course_id().'-'.api_get_session_id());
$show_join_button = false;
if ($meeting_exists || $teacher) {
$show_join_button = true;
diff --git a/plugin/bbb/plugin.php b/plugin/bbb/plugin.php
index 4c38a011e1..a9ad573475 100644
--- a/plugin/bbb/plugin.php
+++ b/plugin/bbb/plugin.php
@@ -1,4 +1,5 @@
get_info();
\ No newline at end of file
+
+$plugin_info = BBBPlugin::create()->get_info();
diff --git a/plugin/bbb/start.php b/plugin/bbb/start.php
index 96afc2949e..e51f9dde2d 100644
--- a/plugin/bbb/start.php
+++ b/plugin/bbb/start.php
@@ -1,16 +1,23 @@
plugin_enabled) {
@@ -18,33 +25,52 @@ if ($bbb->plugin_enabled) {
if (isset($_GET['launch']) && $_GET['launch'] == 1) {
+ if (file_exists(__DIR__ . '/config.vm.php')) {
+ $config = require __DIR__ . '/config.vm.php';
+ $vmIsEnabled = true;
+ $host = null;
+ $salt = null;
+
+ require __DIR__ . '/lib/vm/AbstractVM.php';
+ require __DIR__ . '/lib/vm/VMInterface.php';
+ require __DIR__ . '/lib/vm/DigitalOceanVM.php';
+ require __DIR__ . '/lib/VM.php';
+
+ $vm = new VM($config);
+
+ if ($vm->IsEnabled()) {
+ try {
+ $vm->resizeToMaxLimit();
+ } catch (\Exception $e) {
+ echo $e->getMessage();
+ exit;
+ }
+ }
+ }
+
$meeting_params = array();
- $meeting_params['meeting_name'] = api_get_course_id();
+ $meeting_params['meeting_name'] = api_get_course_id().'-'.api_get_session_id();
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';
- header('location: '.$url);
- exit;
+ $url = 'listing.php?'.api_get_cidreq();
+ $bbb->redirectToBBB($url);
}
}
} else {
- $url = 'listing.php';
- header('location: '.$url);
+ $url = 'listing.php?'.api_get_cidreq();
+ header('Location: ' . $url);
exit;
}
} else {
diff --git a/plugin/before_login/plugin.php b/plugin/before_login/plugin.php
index 35b486b2c6..290584e74e 100644
--- a/plugin/before_login/plugin.php
+++ b/plugin/before_login/plugin.php
@@ -8,7 +8,7 @@
*/
/* Plugin config */
-return;
+
// The plugin title.
$plugin_info['title'] = 'Show HTML before login';
// The comments that go with the plugin.