Improving bbb in order to create easily course plugins see #4840

skala
Julio Montoya 14 years ago
parent 2a313714c8
commit 415612e5c3
  1. 142
      main/course_info/infocours.php
  2. BIN
      main/img/icons/22/bbb.png
  3. 11
      main/inc/autoload.inc.php
  4. 254
      main/inc/lib/add_course.lib.inc.php
  5. 138
      main/inc/lib/plugin.class.php
  6. 234
      main/inc/lib/plugin.lib.php
  7. 14
      plugin/bbb/course_install.php
  8. 7
      plugin/bbb/lang/english.php
  9. 216
      plugin/bbb/lib/bbb.lib.php
  10. 164
      plugin/bbb/lib/bbb_api.php
  11. 131
      plugin/bbb/lib/bbb_plugin.class.php

@ -17,7 +17,7 @@
/* INIT SECTION */
// Language files that need to be included
$language_file = array('create_course', 'course_info', 'admin');
$language_file = array('create_course', 'course_info', 'admin', 'gradebook');
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_COURSE_SETTING;
$this_section = SECTION_COURSES;
@ -41,12 +41,6 @@ $is_allowedToEdit = $is_courseAdmin || $is_platformAdmin;
$course_code = $_course['sysCode'];
$course_access_settings = CourseManager :: get_access_settings($course_code);
$video_conference_enabled = false;
if (api_get_setting('bbb_tool_enable') == 'true') {
$video_conference_enabled = true;
}
//LOGIC FUNCTIONS
function is_settings_editable() {
return $GLOBALS['course_info_is_editable'];
@ -61,7 +55,7 @@ $show_delete_watermark_text_message = false;
if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
if (isset($_GET['delete_watermark'])) {
PDF::delete_watermark($course_code);
$show_delete_watermark_text_message = true;
$show_delete_watermark_text_message = true;
}
}
$table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
@ -120,14 +114,14 @@ $form->addElement('html', '<div><h3>'.Display::return_icon('settings.png', Secur
$image_html = '';
// Sending image
if ($form->validate() && is_settings_editable()) {
if ($form->validate() && is_settings_editable()) {
// update course picture
$picture = $_FILES['picture'];
if (!empty($picture['name'])) {
$picture_uri = CourseManager::update_course_picture($course_code, $picture['name'], $picture['tmp_name']);
}
}
// Display course picture
$course_path = api_get_path(SYS_COURSE_PATH).$currentCourseRepository; // course path
if (file_exists($course_path.'/course-pic85x85.png')) {
@ -174,11 +168,11 @@ if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
$url = PDF::get_watermark($course_code);
$form->add_textfield('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, array('size' => '60'));
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) {
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$form->addElement('html', '<div class="row"><div class="formw"><a href="'.$url.'">'.$url.' '.$delete_url.'</a></div></div>');
}
$form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
$form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
}
$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
@ -303,9 +297,9 @@ if (api_get_setting('allow_course_theme') == 'true') {
$group[]=$form->createElement('radio', 'allow_learning_path_theme', get_lang('AllowLearningPathTheme'), get_lang('AllowLearningPathThemeAllow'), 1);
$group[]=$form->createElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0);
$form->addGroup($group, '', array(get_lang("AllowLearningPathTheme")), '');
$group = array();
$group[]=$form->createElement('select_theme', 'course_theme', null, array('class'=>' ', 'id'=>'course_theme_id'));
$group[]=$form->createElement('select_theme', 'course_theme', null, array('class'=>' ', 'id'=>'course_theme_id'));
$form->addGroup($group, '', array(get_lang("Stylesheets")), '');
}
@ -347,34 +341,10 @@ $form->addElement('html', '</div></div>');
// BBB SETTINGS
if ($video_conference_enabled) {
$form->addElement('html', '<div><h3>'.Display::return_icon('visio.png', Security::remove_XSS(get_lang('VideoConferenceSettings')),'', ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('VideoConferenceSettings')).'</h3><div>');
// $form->add_textfield('big_blue_button_welcome_message', get_lang('big_blue_button_welcome_message'), false, array('class' => 'span5'));
/* $form->add_textfield('big_blue_button_meeting_name', get_lang('big_blue_button_meeting_name'), false, array('class' => 'span5'));
$form->add_textfield('big_blue_button_attendee_password', get_lang('big_blue_button_attendee_password'), false, array('class' => 'span5'));
$form->add_textfield('big_blue_button_moderator_password', get_lang('big_blue_button_moderator_password'), false, array('class' => 'span5'));
$form->addElement('checkbox', 'big_blue_button_open_new_window', array(null, null, get_lang('big_blue_button_open_new_window')), null);
$form->addElement('checkbox', 'big_blue_button_student_must_wait_until_moderator', array(null, null, get_lang('big_blue_button_student_must_wait_until_moderator')), null);
$form->addElement('datepicker', 'big_blue_button_join_start_date', array(get_lang('big_blue_button_join_start_date')), null);
$form->addElement('datepicker', 'big_blue_button_join_end_date', array(get_lang('big_blue_button_join_end_date')), null);*/
$form->add_textfield('big_blue_button_max_students_allowed', get_lang('big_blue_button_max_students_allowed'), false, array('class' => 'span5'));
$form->addElement('checkbox', 'big_blue_button_record_and_store', array(null, null, get_lang('big_blue_button_record_and_store')), null);
$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
$form->addElement('html', '</div></div>');
}
// Plugin course settings
$app_plugin = new AppPlugin();
$app_plugin->add_course_settings_form($form);
// Get all the course information
$all_course_information = CourseManager::get_course_information($_course['sysCode']);
@ -428,62 +398,32 @@ $values['enable_lp_auto_launch'] = api_get_course_setting('en
$values['pdf_export_watermark_text'] = api_get_course_setting('pdf_export_watermark_text');
$values['allow_public_certificates'] = api_get_course_setting('allow_public_certificates');
if ($video_conference_enabled) {
$values['big_blue_button_welcome_message'] = api_get_course_setting('big_blue_button_welcome_message');
$values['big_blue_button_max_students_allowed'] = api_get_course_setting('big_blue_button_max_students_allowed');
/*$values['big_blue_button_meeting_name'] = api_get_course_setting('big_blue_button_meeting_name');
$values['big_blue_button_attendee_password'] = api_get_course_setting('big_blue_button_attendee_password');
$values['big_blue_button_moderator_password'] = api_get_course_setting('big_blue_button_moderator_password');
$values['big_blue_button_open_new_window'] = api_get_course_setting('big_blue_button_open_new_window');
$values['big_blue_button_student_must_wait_until_moderator'] = api_get_course_setting('big_blue_button_student_must_wait_until_moderator');
$start_date = api_get_course_setting('big_blue_button_join_start_date');
if (empty($start_date)) {
$start_date = date('Y-m-d 12:00:00');
}
$values['big_blue_button_join_start_date'] = $start_date;
$end_date = api_get_course_setting('big_blue_button_join_end_date');
if (empty($end_date)) {
$end_date = date('Y-m-d 18:00:00');
}
$values['big_blue_button_join_end_date'] = $end_date;
*/
$values['big_blue_button_record_and_store'] = api_get_course_setting('big_blue_button_record_and_store');
}
$app_plugin->set_course_settings_defaults($values);
$form->setDefaults($values);
// Validate form
if ($form->validate() && is_settings_editable()) {
if ($form->validate() && is_settings_editable()) {
$update_values = $form->exportValues();
$pdf_export_watermark_path = $_FILES['pdf_export_watermark_path'];
if (!empty($pdf_export_watermark_path['name'])) {
$pdf_export_watermark_path_result = PDF::upload_watermark($pdf_export_watermark_path['name'], $pdf_export_watermark_path['tmp_name'], $course_code);
if (!empty($pdf_export_watermark_path['name'])) {
$pdf_export_watermark_path_result = PDF::upload_watermark($pdf_export_watermark_path['name'], $pdf_export_watermark_path['tmp_name'], $course_code);
unset($update_values['pdf_export_watermark_path']);
}
//Variables that will be saved in the TABLE_MAIN_COURSE table
$update_in_course_table = array('title', 'course_language','category_code','department_name', 'department_url','visibility',
$update_in_course_table = array('title', 'course_language','category_code','department_name', 'department_url','visibility',
'subscribe', 'unsubscribe','tutor_name','course_registration_password', 'legal', 'activate_legal');
foreach ($update_values as $index =>$value) {
$update_values[$index] = Database::escape_string($value);
}
unset($value);
}
unset($value);
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql = "UPDATE $table_course SET
title = '".$update_values['title']."',
title = '".$update_values['title']."',
course_language = '".$update_values['course_language']."',
category_code = '".$update_values['category_code']."',
department_name = '".$update_values['department_name']."',
@ -496,36 +436,16 @@ if ($form->validate() && is_settings_editable()) {
registration_code = '".$update_values['course_registration_password']."'
WHERE code = '".$course_code."'";
Database::query($sql);
if ($video_conference_enabled) {
/*
if (isset($update_values['big_blue_button_open_new_window']) && $update_values['big_blue_button_open_new_window']) {
$update_values['big_blue_button_open_new_window'] = 1;
} else {
$update_values['big_blue_button_open_new_window'] = 0;
}
if (isset($update_values['big_blue_button_student_must_wait_until_moderator']) && $update_values['big_blue_button_student_must_wait_until_moderator']) {
$update_values['big_blue_button_student_must_wait_until_moderator'] = 1;
} else {
$update_values['big_blue_button_student_must_wait_until_moderator'] = 0;
}
*/
if (isset($update_values['big_blue_button_record_and_store']) && $update_values['big_blue_button_record_and_store']) {
$update_values['big_blue_button_record_and_store'] = 1;
} else {
$update_values['big_blue_button_record_and_store'] = 0;
}
}
// Update course_settings table - this assumes those records exist, otherwise triggers an error
$table_course_setting = Database::get_course_table(TABLE_COURSE_SETTING);
$table_course_setting = Database::get_course_table(TABLE_COURSE_SETTING);
foreach ($update_values as $key =>$value) {
//We do not update variables that were already saved in the TABLE_MAIN_COURSE table
if (!in_array($key, $update_in_course_table)) {
Database::update($table_course_setting, array('value' => $update_values[$key]), array('variable = ? AND c_id = ?' => array($key, api_get_course_int_id()), true));
}
}
Database::update($table_course_setting, array('value' => $update_values[$key]), array('variable = ? AND c_id = ?' => array($key, api_get_course_int_id())));
}
}
$cidReset = true;
$cidReq = $course_code;
require '../inc/local.inc.php';
@ -547,7 +467,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
echo '<script>
$(function() {
$("#course_settings").accordion({
autoHeight: false,
autoHeight: false,
header: "div > h3"
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -6,4 +6,13 @@
*/
require_once dirname(__FILE__) . '/lib/autoload.class.php';
Autoload::register();
Autoload::register();
/**
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony\\Component\\HttpFoundation', __DIR__.'/vendor/symfony/http-foundation',
));
$loader->register();
*/

@ -82,7 +82,7 @@ function define_course_keys($wanted_code, $prefix_for_all = '', $prefix_for_base
return $keys;
}
}
$keys['currentCourseCode'] = $keys_course_code;
$keys['currentCourseId'] = $keys_course_id;
$keys['currentCourseRepository'] = $keys_course_repository;
@ -159,8 +159,8 @@ function prepare_course_repository($course_repository, $course_code) {
function get_course_tables() {
$tables = array();
$tables[]= 'tool';
$tables[]= 'tool';
$tables[]= 'tool_intro';
$tables[]= 'group_info';
$tables[]= 'group_category';
@ -168,7 +168,7 @@ function get_course_tables() {
$tables[]= 'group_rel_tutor';
$tables[]= 'item_property';
$tables[]= 'userinfo_content';
$tables[]= 'userinfo_def';
$tables[]= 'userinfo_def';
$tables[]= 'course_description';
$tables[]= 'calendar_event';
$tables[]= 'calendar_event_repeat';
@ -198,7 +198,7 @@ function get_course_tables() {
$tables[]= 'quiz_rel_question';
$tables[]= 'quiz_question';
$tables[]= 'quiz_answer';
$tables[]= 'quiz_question_option';
$tables[]= 'quiz_question_option';
$tables[]= 'quiz_question_category';
$tables[]= 'quiz_question_rel_category';
$tables[]= 'dropbox_post';
@ -249,33 +249,33 @@ function get_course_tables() {
$tables[]= 'thematic_plan';
$tables[]= 'thematic_advance';
$tables[]= 'metadata';
return $tables;
return $tables;
}
/* Executed only before create_course_tables() */
function drop_course_tables() {
$list = get_course_tables();
function drop_course_tables() {
$list = get_course_tables();
foreach ($list as $table) {
$sql = "DROP TABLE IF EXISTS ".DB_COURSE_PREFIX.$table;
Database::query($sql);
}
}
}
/**
* Creates all the necessary tables for a new course
* Creates all the necessary tables for a new course
*/
function create_course_tables($course_db_name = null) {
global $_configuration;
$charset_clause = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci';
global $_configuration;
$charset_clause = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci';
$use_one_db = true;
if ($use_one_db) {
$course_db_name = DB_COURSE_PREFIX;
} else {
if (!$_configuration['single_database']) {
Database::query("CREATE DATABASE IF NOT EXISTS " . $course_db_name . "" . $charset_clause);
}
}
$course_db_name = $_configuration['table_prefix'].$course_db_name.$_configuration['db_glue'];
}
@ -294,7 +294,7 @@ function create_course_tables($course_db_name = null) {
$TABLETOOLAGENDAREPEAT = $course_db_name . 'calendar_event_repeat';
$TABLETOOLAGENDAREPEATNOT = $course_db_name . 'calendar_event_repeat_not';
$TABLETOOLAGENDAATTACHMENT = $course_db_name . 'calendar_event_attachment';
// Announcements
$TABLETOOLANNOUNCEMENTS = $course_db_name . 'announcement';
$TABLETOOLANNOUNCEMENTSATTACHMENT = $course_db_name . 'announcement_attachment';
@ -335,7 +335,7 @@ function create_course_tables($course_db_name = null) {
$TABLEQUIZQUESTION = $course_db_name . 'quiz_rel_question';
$TABLEQUIZQUESTIONLIST = $course_db_name . 'quiz_question';
$TABLEQUIZANSWERSLIST = $course_db_name . 'quiz_answer';
$TABLEQUIZQUESTIONOPTION = $course_db_name . 'quiz_question_option';
$TABLEQUIZQUESTIONOPTION = $course_db_name . 'quiz_question_option';
$table_quiz_question_category = $course_db_name . 'quiz_question_category';
$table_quiz_question_rel_category = $course_db_name . 'quiz_question_rel_category';
@ -408,12 +408,12 @@ function create_course_tables($course_db_name = null) {
// Thematic
$TBL_THEMATIC = $course_db_name . 'thematic';
$TBL_THEMATIC_PLAN = $course_db_name . 'thematic_plan';
$TBL_THEMATIC_ADVANCE = $course_db_name . 'thematic_advance';
$TBL_THEMATIC_ADVANCE = $course_db_name . 'thematic_advance';
$TBL_METADATA = $course_db_name . 'metadata';
$add_to_all_tables = ' c_id INT NOT NULL, ';
/* Announcement tool */
/* Announcement tool */
$sql = "
CREATE TABLE `".$TABLETOOLANNOUNCEMENTS . "` (
@ -662,13 +662,13 @@ function create_course_tables($course_db_name = null) {
$sql = "ALTER TABLE `".$TABLETOOLFORUMQUALIFYLOG. "` ADD INDEX (user_id, thread_id)";
Database::query($sql);
/*
* Exercise tool
/*
* Exercise tool
*/
// Exercise tool - Tests/exercises
$sql = "CREATE TABLE `".$TABLEQUIZ . "` (
$add_to_all_tables
$add_to_all_tables
id mediumint unsigned NOT NULL auto_increment,
title varchar(255) NOT NULL,
description text default NULL,
@ -708,7 +708,7 @@ function create_course_tables($course_db_name = null) {
ponderation float(6,2) NOT NULL default 0,
position mediumint unsigned NOT NULL default 1,
type tinyint unsigned NOT NULL default 2,
picture varchar(50) default NULL,
picture varchar(50) default NULL,
level int unsigned NOT NULL default 0,
extra varchar(255) default NULL,
PRIMARY KEY (c_id, id)
@ -732,24 +732,24 @@ function create_course_tables($course_db_name = null) {
hotspot_coordinates text,
hotspot_type enum('square','circle','poly','delineation','oar') default NULL,
destination text NOT NULL,
id_auto int NOT NULL AUTO_INCREMENT,
id_auto int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (c_id, id, question_id),
UNIQUE KEY id_auto (id_auto)
)" . $charset_clause;
Database::query($sql);
// Exercise tool - answer options
$sql = "
CREATE TABLE `".$TABLEQUIZQUESTIONOPTION . "` (
$add_to_all_tables
id int NOT NULL auto_increment,
question_id int NOT NULL,
question_id int NOT NULL,
name varchar(255),
position int unsigned NOT NULL,
position int unsigned NOT NULL,
PRIMARY KEY (c_id, id)
)" . $charset_clause;
Database::query($sql);
// Exercise tool - Test/question relations
$sql = "
@ -761,9 +761,9 @@ function create_course_tables($course_db_name = null) {
PRIMARY KEY (c_id, question_id,exercice_id)
)" . $charset_clause;
Database::query($sql);
$sql = "CREATE TABLE `".$table_quiz_question_category . "` (
$add_to_all_tables
id int NOT NULL AUTO_INCREMENT,
@ -772,17 +772,17 @@ function create_course_tables($course_db_name = null) {
PRIMARY KEY (c_id,id)
)" . $charset_clause;
Database::query($sql);
$sql = "CREATE TABLE `".$table_quiz_question_rel_category . "` (
$add_to_all_tables
$add_to_all_tables
question_id int NOT NULL,
category_id int NOT NULL,
PRIMARY KEY (c_id,question_id)
)" . $charset_clause;
Database::query($sql);
/* Course description */
$sql = "
@ -920,7 +920,7 @@ function create_course_tables($course_db_name = null) {
qualificator_id INT UNSIGNED NOT NULL DEFAULT 0,
weight float(6,2) UNSIGNED NOT NULL default 0,
session_id INT UNSIGNED NOT NULL default 0,
user_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
allow_text_assignment INTEGER NOT NULL DEFAULT 0,
contains_file INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (c_id, id)
@ -935,7 +935,7 @@ function create_course_tables($course_db_name = null) {
ends_on datetime NOT NULL default '0000-00-00 00:00:00',
add_to_calendar tinyint NOT NULL,
enable_qualification tinyint NOT NULL,
publication_id int NOT NULL,
publication_id int NOT NULL,
PRIMARY KEY (c_id, id)
)" . $charset_clause;
Database::query($sql);
@ -944,7 +944,7 @@ function create_course_tables($course_db_name = null) {
Database::query($sql);
/*
Links tool
Links tool
*/
$sql = "
@ -1101,8 +1101,8 @@ function create_course_tables($course_db_name = null) {
$sql = "ALTER TABLE `".$TABLETOOLCHATCONNECTED . "` ADD INDEX char_connected_index(user_id, session_id, to_group_id) ";
Database::query($sql);
/*
Groups tool
/*
Groups tool
*/
Database::query("CREATE TABLE `".$TABLEGROUPS . "` (
@ -1278,7 +1278,7 @@ function create_course_tables($course_db_name = null) {
*/
$sql = "CREATE TABLE IF NOT EXISTS `$TABLELP` (
$add_to_all_tables
$add_to_all_tables
" .
"id int unsigned auto_increment," . // unique ID, generated by MySQL
"lp_type smallint unsigned not null," . // lp_types can be found in the main database's lp_type table
@ -1305,10 +1305,10 @@ function create_course_tables($course_db_name = null) {
"seriousgame_mode tinyint NOT NULL DEFAULT 0, ".
"use_max_score int unsigned not null default 1, " .
"autolunch int unsigned not null default 0, " . // auto lunch LP
"created_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"modified_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"publicated_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"expired_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
"created_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"modified_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"publicated_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .
"expired_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (c_id, id)
)" . $charset_clause;
@ -1325,7 +1325,7 @@ function create_course_tables($course_db_name = null) {
"last_item int unsigned not null default 0," . // last item seen in this view
"progress int unsigned default 0," .
"session_id int not null default 0,
PRIMARY KEY (c_id, id)
PRIMARY KEY (c_id, id)
)" . $charset_clause; // lp's progress for this user
if (!Database::query($sql)) {
@ -1372,7 +1372,7 @@ function create_course_tables($course_db_name = null) {
"search_did INT NULL,". // contains the internal search-engine id of this element
"audio VARCHAR(250),
PRIMARY KEY (c_id, id)
)" . $charset_clause; // contains the audio file that goes with the learning path step
if (!Database::query($sql)) {
@ -1399,7 +1399,7 @@ function create_course_tables($course_db_name = null) {
"lesson_location text null default ''," .
"core_exit varchar(32) not null default 'none'," .
"max_score varchar(8) default '',
PRIMARY KEY (c_id, id)
PRIMARY KEY (c_id, id)
)" . $charset_clause;
if (!Database::query($sql)) {
@ -1690,9 +1690,9 @@ function create_course_tables($course_db_name = null) {
error_log($sql, 0);
}
/*
* Course Config Settings
*
/*
* Course Config Settings
*
*/
Database::query("
@ -1710,8 +1710,8 @@ function create_course_tables($course_db_name = null) {
PRIMARY KEY (c_id, id)
)" . $charset_clause);
/*
Survey
/*
Survey
*/
$sql = "CREATE TABLE `".$TABLESURVEY."` (
@ -1808,7 +1808,7 @@ function create_course_tables($course_db_name = null) {
$result = Database::query($sql);
$sql = "CREATE TABLE `".$TABLESURVEYGROUP."` (
$add_to_all_tables
$add_to_all_tables
id int unsigned NOT NULL auto_increment,
name varchar(20) NOT NULL,
description varchar(255) NOT NULL,
@ -1922,7 +1922,7 @@ function create_course_tables($course_db_name = null) {
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_RESULT."` ADD INDEX (user_id)";
Database::query($sql);
// attendance sheet log table
$sql = "CREATE TABLE `".$TBL_ATTENDANCE_SHEET_LOG."` (
$add_to_all_tables
@ -1935,7 +1935,7 @@ function create_course_tables($course_db_name = null) {
PRIMARY KEY (c_id, id)
)" . $charset_clause;
$result = Database::query($sql) or die(Database::error());
// Thematic table
$sql = "CREATE TABLE `".$TBL_THEMATIC."` (
@ -1985,8 +1985,8 @@ function create_course_tables($course_db_name = null) {
$sql = "ALTER TABLE `".$TBL_THEMATIC_ADVANCE."` ADD INDEX (thematic_id)";
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS " . $TBL_METADATA . " ( " .
$add_to_all_tables.
"eid VARCHAR(250) NOT NULL," . // entry-id, e.g. doc.1
@ -1996,7 +1996,7 @@ function create_course_tables($course_db_name = null) {
"htmlcache2 TEXT default ''," . // cached HTML, part 2
"indexabletext TEXT default ''," . // indexable for search
"PRIMARY KEY (c_id, eid) )".$charset_clause;
Database::query($sql);
return 0;
@ -2222,15 +2222,15 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
}
global $_configuration;
$course_id = intval($course_id);
if (empty($course_id)) {
return false;
return false;
}
$tbl_course_homepage = Database::get_course_table(TABLE_TOOL_LIST);
$TABLEINTROS = Database::get_course_table(TABLE_TOOL_INTRO);
$TABLEGROUPCATEGORIES = Database::get_course_table(TABLE_GROUP_CATEGORY);
$TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLEINTROS = Database::get_course_table(TABLE_TOOL_INTRO);
$TABLEGROUPCATEGORIES = Database::get_course_table(TABLE_GROUP_CATEGORY);
$TABLEITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLETOOLAGENDA = Database::get_course_table(TABLE_AGENDA);
$TABLETOOLANNOUNCEMENTS = Database::get_course_table(TABLE_ANNOUNCEMENT);
$TABLETOOLDOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
@ -2248,8 +2248,8 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
include api_get_path(SYS_CODE_PATH).'lang/english/create_course.inc.php';
$file_to_include = api_get_path(SYS_CODE_PATH).'lang/'.$language.'/create_course.inc.php';
if (file_exists($file_to_include)) {
if (file_exists($file_to_include)) {
include $file_to_include;
}
@ -2321,20 +2321,20 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
Database::query("INSERT INTO $TABLESETTING (c_id, variable,value,category) VALUES ($course_id, 'enable_lp_auto_launch',0,'learning_path')");
Database::query("INSERT INTO $TABLESETTING (c_id, variable,value,category) VALUES ($course_id, 'pdf_export_watermark_text','','learning_path')");
Database::query("INSERT INTO $TABLESETTING (c_id, variable,value,category) VALUES ($course_id, 'allow_public_certificates','','certificates')");
/* Course homepage tools for platform admin only */
/* Group tool */
Database::query("INSERT INTO $TABLEGROUPCATEGORIES (c_id, id , title , description , max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order )
Database::query("INSERT INTO $TABLEGROUPCATEGORIES (c_id, id , title , description , max_student , self_reg_allowed , self_unreg_allowed , groups_per_user , display_order )
VALUES ($course_id, '2', '".lang2db(get_lang('DefaultGroupCategory')) . "', '', '8', '0', '0', '0', '0');");
/* Example Material */
global $language_interface;
$language_interface = !empty($language_interface) ? $language_interface : api_get_setting('platformLanguage');
// Example material should be in the same language as the course is.
$language_interface_original = $language_interface;
$language_interface = $language;
@ -2399,7 +2399,7 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
$image_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,NOW(),NOW(),$image_id,'DocumentAdded',1,0,NULL,0)");
}
if ($value['file'] != '') {
$temp = explode('/', $value['file']);
$file_size = filesize($course_documents_folder.$value['file']);
@ -2411,7 +2411,7 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
}
}
}
if ($fill_with_exemplary_content) {
/* Agenda tool */
@ -2430,7 +2430,7 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
// We need to add the item properties too!
$insert_id = Database :: insert_id();
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, '" . TOOL_LINK . "',1,NOW(),NOW(),$insert_id,'LinkAdded',1,0,NULL,1)";
Database::query($sql);
@ -2445,13 +2445,13 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
/* Annoucement tool */
$sql = "INSERT INTO $TABLETOOLANNOUNCEMENTS (c_id, title,content,end_date,display_order,email_sent)
$sql = "INSERT INTO $TABLETOOLANNOUNCEMENTS (c_id, title,content,end_date,display_order,email_sent)
VALUES ($course_id, '".lang2db(get_lang('AnnouncementExampleTitle')) . "', '".lang2db(get_lang('AnnouncementEx')) . "', NOW(), '1','0')";
Database::query($sql);
// We need to add the item properties too!
$insert_id = Database :: insert_id();
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
$sql = "INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, '" . TOOL_ANNOUNCEMENT . "',1,NOW(),NOW(),$insert_id,'AnnouncementAdded',1,0,NULL,1)";
Database::query($sql);
@ -2476,9 +2476,9 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
Database::query("INSERT INTO $TABLEQUIZANSWERSLIST VALUES ($course_id, '4', '1', '".lang2db(get_lang('Contradiction')) . "', '1', '".lang2db(get_lang('NotFalse')) . "', '5', '4','','','','')");
$html=Database::escape_string('<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="top" align="left"><img src="'.api_get_path(WEB_CODE_PATH).'default_course_document/images/mr_dokeos/thinking.jpg"></td><td valign="top" align="left">'.get_lang('Antique').'</td></tr></table>');
Database::query('INSERT INTO '.$TABLEQUIZ . ' (c_id, title, description, type, random, random_answers, active, results_disabled )
Database::query('INSERT INTO '.$TABLEQUIZ . ' (c_id, title, description, type, random, random_answers, active, results_disabled )
VALUES ('.$course_id.', "'.lang2db(get_lang('ExerciceEx')) . '", "'.$html.'", "1", "0", "0", "1", "0")');
Database::query("INSERT INTO $TABLEQUIZQUESTIONLIST (c_id, id, question, description, ponderation, position, type, picture, level)
Database::query("INSERT INTO $TABLEQUIZQUESTIONLIST (c_id, id, question, description, ponderation, position, type, picture, level)
VALUES ( '.$course_id.', '1', '".lang2db(get_lang('SocraticIrony')) . "', '".lang2db(get_lang('ManyAnswers')) . "', '10', '1', '2','',1)");
Database::query("INSERT INTO $TABLEQUIZQUESTION (c_id, question_id, exercice_id, question_order) VALUES ('.$course_id.', 1,1,1)");
@ -2486,40 +2486,28 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
Database::query("INSERT INTO $TABLEFORUMCATEGORIES VALUES ($course_id, 1,'".lang2db(get_lang('ExampleForumCategory'))."', '', 1, 0, 0)");
$insert_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'forum_category',1,NOW(),NOW(),$insert_id,'ForumCategoryAdded',1,0,NULL,1)");
Database::query("INSERT INTO $TABLEFORUMS (c_id, forum_title, forum_comment, forum_threads,forum_posts,forum_last_post,forum_category, allow_anonymous, allow_edit,allow_attachments, allow_new_threads,default_view,forum_of_group,forum_group_public_private, forum_order,locked,session_id )
Database::query("INSERT INTO $TABLEFORUMS (c_id, forum_title, forum_comment, forum_threads,forum_posts,forum_last_post,forum_category, allow_anonymous, allow_edit,allow_attachments, allow_new_threads,default_view,forum_of_group,forum_group_public_private, forum_order,locked,session_id )
VALUES ($course_id, '".lang2db(get_lang('ExampleForum'))."', '', 0, 0, 0, 1, 0, 1, '0', 1, 'flat','0', 'public', 1, 0,0)");
$insert_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, '".TOOL_FORUM."', 1,NOW(),NOW(),$insert_id,'ForumAdded',1,0,NULL,1)");
Database::query("INSERT INTO $TABLEFORUMTHREADS (c_id, thread_id, thread_title, forum_id, thread_replies, thread_poster_id, thread_poster_name, thread_views, thread_last_post, thread_date, locked, thread_qualify_max, session_id)
Database::query("INSERT INTO $TABLEFORUMTHREADS (c_id, thread_id, thread_title, forum_id, thread_replies, thread_poster_id, thread_poster_name, thread_views, thread_last_post, thread_date, locked, thread_qualify_max, session_id)
VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', 1, 0, 1, '', 0, 1, NOW(), 0, 10, 0)");
$insert_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility)
VALUES ($course_id, 'forum_thread',1,NOW(),NOW(),$insert_id,'ForumThreadAdded',1,0,NULL,1)");
Database::query("INSERT INTO $TABLEFORUMPOSTS VALUES ($course_id, 1, '".lang2db(get_lang('ExampleThread'))."', '".lang2db(get_lang('ExampleThreadContent'))."', 1, 1, 1, '', NOW(), 0, 0, 1)");
}
// PLUGINS - if an installed plugin has a course_install.php file, execute it
$installed_plugins = api_get_settings('Plugins','list', $_configuration['access_url']);
$shortlist_installed = array();
foreach ($installed_plugins as $plugin) {
$shortlist_installed[] = $plugin['subkey'];
}
$shortlist_installed = array_flip(array_flip($shortlist_installed));
foreach ($shortlist_installed as $plugin) {
$pluginpath = api_get_path(SYS_PLUGIN_PATH).$plugin.'/course_install.php';
if (is_file($pluginpath) && is_readable($pluginpath)) {
//execute the install procedure
include $pluginpath;
}
}
//end of installed plugins alterations
//Installing plugins in course
$app_plugin = new AppPlugin();
$app_plugin->install_course_plugins($course_id);
$language_interface = $language_interface_original;
return true;
};
@ -2559,7 +2547,7 @@ function string2binary($variable) {
*/
function register_course($params) {
global $error_msg, $firstExpirationDelay;
$title = $params['title'];
$code = $params['code'];
$visual_code = $params['visual_code'];
@ -2568,31 +2556,31 @@ function register_course($params) {
//$description = $params['description'];
$category_code = $params['category_code'];
$course_language = isset($params['course_language']) && !empty($params['course_language']) ? $params['course_language'] : api_get_setting('platformLanguage');
$user_id = empty($params['user_id']) ? api_get_user_id() : intval($params['user_id']);
$course_language = isset($params['course_language']) && !empty($params['course_language']) ? $params['course_language'] : api_get_setting('platformLanguage');
$user_id = empty($params['user_id']) ? api_get_user_id() : intval($params['user_id']);
$department_name = $params['department_name'];
$department_url = $params['department_url'];
$disk_quota = $params['disk_quota'];
$subscribe = isset($params['subscribe']) ? intval($params['subscribe']) : 0;
$unsubscribe = isset($params['unsubscribe']) ? intval($params['unsubscribe']) : 0;
if (!isset($params['visibility'])) {
$default_course_visibility = api_get_setting('courses_default_creation_visibility');
if (isset($default_course_visibility)) {
$visibility = $default_course_visibility;
$visibility = $default_course_visibility;
} else {
$visibility = COURSE_VISIBILITY_OPEN_PLATFORM;
}
} else {
$visibility = $params['visibility'];
}
$expiration_date = $params['expiration_date'];
$teachers = $params['teachers'];
$status = $params['status'];
$status = $params['status'];
$TABLECOURSE = Database :: get_main_table(TABLE_MAIN_COURSE);
$TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$TABLECOURSUSER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$ok_to_register_course = true;
@ -2604,16 +2592,16 @@ function register_course($params) {
if (empty($visual_code)) {
$error_msg[] = 'courseScreenCode is missing';
$ok_to_register_course = false;
}
}
if (empty($directory)) {
$error_msg[] = 'courseRepository is missing';
$ok_to_register_course = false;
}
if (empty($title)) {
$error_msg[] = 'title is missing';
$ok_to_register_course = false;
}
}
if (empty($expiration_date)) {
$expiration_date = api_get_utc_datetime(time() + $firstExpirationDelay);
@ -2629,20 +2617,20 @@ function register_course($params) {
if (empty($disk_quota)) {
$disk_quota = api_get_setting('default_document_quotum');
}
$time = api_get_utc_datetime();
if (stripos($department_url, 'http://') === false && stripos($department_url, 'https://') === false) {
$department_url = 'http://'.$department_url;
}
//just in case
if ($department_url == 'http://') {
$department_url = '';
}
$course_id = 0;
}
$course_id = 0;
if ($ok_to_register_course) {
// Here we must add 2 fields.
$sql = "INSERT INTO ".$TABLECOURSE . " SET
code = '".Database :: escape_string($code) . "',
@ -2661,17 +2649,17 @@ function register_course($params) {
tutor_name = '".Database :: escape_string($tutor_name) . "',
department_name = '".Database :: escape_string($department_name) . "',
department_url = '".Database :: escape_string($department_url) . "',
subscribe = '".intval($subscribe) . "',
unsubscribe = '".intval($unsubscribe) . "',
subscribe = '".intval($subscribe) . "',
unsubscribe = '".intval($unsubscribe) . "',
visual_code = '".Database :: escape_string($visual_code) . "'";
Database::query($sql);
$course_id = Database::get_last_insert_id();
if ($course_id) {
$sort = api_max_sort_value('0', api_get_user_id());
$i_course_sort = CourseManager :: userCourseSort($user_id, $code);
if (!empty($user_id)) {
$sql = "INSERT INTO ".$TABLECOURSUSER . " SET
@ -2683,7 +2671,7 @@ function register_course($params) {
sort = '". ($i_course_sort) . "',
user_course_cat = '0'";
Database::query($sql);
}
}
if (!empty($teachers)) {
foreach ($teachers as $key) {
//just in case
@ -2704,7 +2692,7 @@ function register_course($params) {
Database::query($sql);
}
}
// Adding the course to an URL.
global $_configuration;
require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
@ -2717,18 +2705,18 @@ function register_course($params) {
} else {
UrlManager::add_course_to_url($code, 1);
}
// Add event to the system log.
// Add event to the system log.
$user_id = api_get_user_id();
event_system(LOG_COURSE_CREATE, LOG_COURSE_CODE, $code, api_get_utc_datetime(), $user_id, $code);
$send_mail_to_admin = api_get_setting('send_email_to_admin_when_create_course');
// @todo Improve code to send to all current portal administrators.
if ($send_mail_to_admin == 'true') {
$siteName = api_get_setting('siteName');
$recipient_email = api_get_setting('emailAdministrator');
$recipient_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'));
$recipient_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'));
$iname = api_get_setting('Institution');
$subject = get_lang('NewCourseCreatedIn').' '.$siteName.' - '.$iname;
$message = get_lang('Dear').' '.$recipient_name.",\n\n".get_lang('MessageOfNewCourseToAdmin').' '.$siteName.' - '.$iname."\n";
@ -2736,7 +2724,7 @@ function register_course($params) {
$message .= get_lang('Category').' '.$category."\n";
$message .= get_lang('Tutor').' '.$tutor_name."\n";
$message .= get_lang('Language').' '.$course_language;
@api_mail($recipient_name, $recipient_email, $subject, $message, $siteName, $recipient_email);
}
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Base class for plugins
@ -6,6 +7,8 @@
* @copyright (c) 2012 University of Geneva
* @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html
* @author Laurent Opprecht <laurent@opprecht.info>
* @author Julio Montoya <gugli100@gmail.com> added course settings support + lang variable fixes
*
*/
class Plugin {
@ -13,6 +16,19 @@ class Plugin {
protected $author = '';
protected $fields = array();
private $settings = null;
private $strings = null;
/**
* When creating a new course this settings are added to the course in the course_info/infocours.php
* @example
* $course_settings = array(
array('name' => 'big_blue_button_welcome_message', 'type' => 'text'),
array('name' => 'big_blue_button_record_and_store', 'type' => 'checkbox')
);
*/
public $course_settings = array();
protected function __construct($version, $author, $settings = array()) {
$this->version = $version;
$this->author = $author;
@ -25,11 +41,12 @@ class Plugin {
function get_info() {
$result = array();
$result['title'] = $this->get_title();
$result['comment'] = $this->get_comment();
$result['version'] = $this->get_version();
$result['author'] = $this->get_author();
$result['title'] = $this->get_title();
$result['comment'] = $this->get_comment();
$result['version'] = $this->get_version();
$result['author'] = $this->get_author();
$result['plugin_class'] = get_class($this);
if ($form = $this->get_settings_form()) {
$result['settings_form'] = $form;
foreach ($this->fields as $name => $type) {
@ -64,7 +81,7 @@ class Plugin {
}
function get_css() {
$name = $this->get_name();
$name = $this->get_name();
$path = api_get_path(SYS_PLUGIN_PATH)."$name/resources/$name.css";
if (!is_readable($path)) {
return '';
@ -85,29 +102,29 @@ class Plugin {
$defaults = array();
foreach ($this->fields as $name => $type) {
$value = $this->get($name);
$defaults[$name] = $value;
$type = isset($type) ? $type : 'text';
$help = null;
if ($this->get_lang_plugin_exists($name.'_help')) {
$help = $this->get_lang($name.'_help');
}
switch ($type) {
case 'html':
$result->addElement('html', $this->get_lang($name));
$result->addElement('html', $this->get_lang($name));
break;
case 'wysiwyg':
$result->add_html_editor($name, $this->get_lang($name));
break;
case 'text':
$result->addElement($type, $name, array($this->get_lang($name), $help));
case 'text':
$result->addElement($type, $name, array($this->get_lang($name), $help));
break;
case 'boolean':
$group = array();
$group[] = $result->createElement('radio', $name, '', get_lang('Yes'), 'true');
$group[] = $result->createElement('radio', $name, '', get_lang('No'), 'false');
$group[] = $result->createElement('radio', $name, '', get_lang('No'), 'false');
$result->addGroup($group, null, array($this->get_lang($name), $help));
break;
}
@ -117,8 +134,8 @@ class Plugin {
return $result;
}
function get($name) {
$settings = $this->get_settings();
function get($name) {
$settings = $this->get_settings();
foreach ($settings as $setting) {
if ($setting['variable'] == ($this->get_name() . '_' . $name)) {
return $setting['selected_value'];
@ -127,8 +144,6 @@ class Plugin {
return false;
}
private $settings = null;
public function get_settings() {
if (is_null($this->settings)) {
$settings = api_get_settings_params(array("subkey = ? AND category = ? AND type = ? " => array($this->get_name(), 'Plugins', 'setting')));
@ -137,8 +152,6 @@ class Plugin {
return $this->settings;
}
private $strings = null;
public function get_lang_plugin_exists($name) {
return isset($this->strings[$name]);
}
@ -147,15 +160,15 @@ class Plugin {
if (is_null($this->strings)) {
global $language_interface;
$root = api_get_path(SYS_PLUGIN_PATH);
$plugin_name = $this->get_name();
$plugin_name = $this->get_name();
//1. Loading english if exists
//1. Loading english if exists
$english_path = $root.$plugin_name."/lang/english.php";
if (is_readable($english_path)) {
include $english_path;
$this->strings = $strings;
}
$path = $root.$plugin_name."/lang/$language_interface.php";
//2. Loading the system language
if (is_readable($path)) {
@ -175,4 +188,85 @@ class Plugin {
}
return get_lang($name);
}
function course_install($course_id) {
$this->install_course_fields($course_id);
}
/* Add course settings and add a tool link */
public function install_course_fields($course_id) {
$plugin_name = $this->get_name();
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
$course_id = intval($course_id);
if (empty($course_id)) {
return false;
}
//Ads course settings
if (!empty($this->course_settings)) {
foreach ($this->course_settings as $setting) {
$variable = Database::escape_string($setting['name']);
$sql = "SELECT value FROM $t_course WHERE c_id = $course_id AND variable = '$variable' ";
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$sql_course = "INSERT INTO $t_course (c_id, variable, value, category, subkey) VALUES ($course_id, '$variable','', 'plugins', '$plugin_name')";
$r = Database::query($sql_course);
}
}
}
//Add an icon in the table tool list
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
$sql = "SELECT name FROM $t_tool WHERE c_id = $course_id AND name = '$plugin_name' ";
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$tool_link = "../../plugin/$plugin_name/start.php";
$visibility = string2binary(api_get_setting('course_create_active_tools', $plugin_name));
$sql_course = "INSERT INTO $t_tool VALUES ($course_id, NULL, '$plugin_name', '$tool_link', '$plugin_name.png',' ".$visibility."','0', 'squaregrey.gif','NO','_self','plugin','0')";
$r = Database::query($sql_course);
}
}
public function uninstall_course_fields($course_id) {
$course_id = intval($course_id);
if (empty($course_id)) {
return false;
}
$plugin_name = $this->get_name();
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
if (!empty($this->course_settings)) {
foreach ($this->course_settings as $setting) {
$variable = Database::escape_string($setting['name']);
$sql_course = "DELETE FROM $t_course WHERE c_id = $course_id AND variable = '$variable'";
Database::query($sql_course);
}
}
$sql_course = "DELETE FROM $t_tool WHERE c_id = $course_id AND name = '$plugin_name'";
Database::query($sql_course);
}
function install_course_fields_in_all_courses() {
// Update existing courses to add conference settings
$t_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id, code FROM $t_courses ORDER BY id";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$this->install_course_fields($row['id']);
}
}
function uninstall_course_fields_in_all_courses() {
// Update existing courses to add conference settings
$t_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id, code FROM $t_courses ORDER BY id";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$this->uninstall_course_fields($row['id']);
}
}
}

@ -2,32 +2,32 @@
/* See license terms in /license.txt */
class AppPlugin {
var $plugin_regions = array (
var $plugin_regions = array (
// 'loginpage_main',
'login_top',
'login_bottom',
'menu_top',
'menu_bottom',
/* 'campushomepage_main',
'menu_top',
'menu_bottom',
/* 'campushomepage_main',
'campushomepage_menu',
'mycourses_main',
'mycourses_main',
'mycourses_menu',*/
'content_top',
'content_bottom',
'header_main',
'header_center',
'header_left',
'header_right',
'header_right',
//'footer',
'footer_left',
'footer_center',
'footer_right',
'course_tool_plugin'
);
function __construct() {
function __construct() {
}
function read_plugins_from_path() {
/* We scan the plugin directory. Each folder is a potential plugin. */
$pluginpath = api_get_path(SYS_PLUGIN_PATH);
@ -39,25 +39,25 @@ class AppPlugin {
}
}
@closedir($handle);
sort($possible_plugins);
sort($possible_plugins);
return $possible_plugins;
}
function get_installed_plugins_by_region(){
$used_plugins = array();
/* We retrieve all the active plugins. */
$result = api_get_settings('Plugins');
/* We retrieve all the active plugins. */
$result = api_get_settings('Plugins');
foreach ($result as $row) {
$used_plugins[$row['variable']][] = $row['selected_value'];
}
return $used_plugins;
}
function get_installed_plugins() {
$installed_plugins = array();
$plugin_array = api_get_settings_params(array("variable = ? AND selected_value = ? AND category = ? " =>
array('status', 'installed', 'Plugins')));
array('status', 'installed', 'Plugins')));
if (!empty($plugin_array)) {
foreach ($plugin_array as $row) {
$installed_plugins[$row['subkey']] = true;
@ -66,7 +66,7 @@ class AppPlugin {
}
return $installed_plugins;
}
function install($plugin_name, $access_url_id = null) {
if (empty($access_url_id)) {
$access_url_id = api_get_current_access_url_id();
@ -74,16 +74,16 @@ class AppPlugin {
$access_url_id = intval($access_url_id);
}
api_add_setting('installed', 'status', $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, $access_url_id, 1);
//api_add_setting($plugin, $area, $plugin, null, 'Plugins', $plugin, null, null, null, $_configuration['access_url'], 1);
$pluginpath = api_get_path(SYS_PLUGIN_PATH).$plugin_name.'/install.php';
if (is_file($pluginpath) && is_readable($pluginpath)) {
//execute the install procedure
require $pluginpath;
}
}
}
function uninstall($plugin_name, $access_url_id = null) {
if (empty($access_url_id)) {
$access_url_id = api_get_current_access_url_id();
@ -98,9 +98,9 @@ class AppPlugin {
require $pluginpath;
}
}
function get_areas_by_plugin($plugin_name) {
$result = api_get_settings('Plugins');
$result = api_get_settings('Plugins');
$areas = array();
foreach ($result as $row) {
if ($plugin_name == $row['selected_value']) {
@ -109,11 +109,11 @@ class AppPlugin {
}
return $areas;
}
function is_valid_plugin_location($location) {
return in_array($location, $this->plugin_list);
}
function is_valid_plugin($plugin_name) {
if (is_dir(api_get_path(SYS_PLUGIN_PATH).$plugin_name)) {
if (is_file(api_get_path(SYS_PLUGIN_PATH).$plugin_name.'/index.php')) {
@ -122,59 +122,59 @@ class AppPlugin {
}
return false;
}
function get_plugin_regions() {
sort($this->plugin_regions);
return $this->plugin_regions;
}
function load_region($region, $main_template, $forced = false) {
ob_start();
ob_start();
$this->get_all_plugin_contents_by_region($region, $main_template, $forced);
$content = ob_get_contents();
ob_end_clean();
return $content;
}
/**
* Loads the translation files inside a plugin if exists. It loads by default english see the hello world plugin
*
*
* @todo add caching
* @param string $plugin_name
* @param string $plugin_name
*/
function load_plugin_lang_variables($plugin_name) {
function load_plugin_lang_variables($plugin_name) {
global $language_interface;
$root = api_get_path(SYS_PLUGIN_PATH);
$root = api_get_path(SYS_PLUGIN_PATH);
//1. Loading english if exists
$english_path = $root.$plugin_name."/lang/english.php";
if (is_readable($english_path)) {
//1. Loading english if exists
$english_path = $root.$plugin_name."/lang/english.php";
if (is_readable($english_path)) {
include $english_path;
foreach ($strings as $key => $string) {
foreach ($strings as $key => $string) {
//$$key = $string;
$GLOBALS[$key] = $string;
}
$GLOBALS[$key] = $string;
}
}
//2. Loading the system language
if ($language_interface != 'english') {
$path = $root.$plugin_name."/lang/$language_interface.php";
if (is_readable($path)) {
include $path;
if (!empty($strings)) {
if (!empty($strings)) {
foreach ($strings as $key => $string) {
//$$key = $string;
$GLOBALS[$key] = $string;
$GLOBALS[$key] = $string;
}
}
}
}
}
/**
/**
*
*
* @param string $block
@ -186,103 +186,103 @@ class AppPlugin {
if (isset($_plugins[$region]) && is_array($_plugins[$region])) {
//if (1) {
//Load the plugin information
foreach ($_plugins[$region] as $plugin_name) {
//The plugin_info variable is available inside the plugin index
$plugin_info = $this->get_plugin_info($plugin_name, $forced);
foreach ($_plugins[$region] as $plugin_name) {
//The plugin_info variable is available inside the plugin index
$plugin_info = $this->get_plugin_info($plugin_name, $forced);
//We also know where the plugin is
$plugin_info['current_region'] = $region;
// Loading the plugin/XXX/index.php file
$plugin_info['current_region'] = $region;
// Loading the plugin/XXX/index.php file
$plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php";
if (file_exists($plugin_file)) {
//Loading the lang variables of the plugin if exists
self::load_plugin_lang_variables($plugin_name);
//Loading the lang variables of the plugin if exists
self::load_plugin_lang_variables($plugin_name);
//Printing the plugin index.php file
require $plugin_file;
//If the variable $_template is set we assign those values to be accesible in Twig
if (isset($_template)) {
if (isset($_template)) {
$_template['plugin_info'] = $plugin_info;
} else {
$_template = array();
$_template['plugin_info'] = $plugin_info;
}
//Setting the plugin info available in the template if exists
//Setting the plugin info available in the template if exists
$template->assign($plugin_name, $_template);
//Loading the Twig template plugin files if exists
$template_list = array();
if (isset($plugin_info) && isset($plugin_info['templates'])) {
$template_list = $plugin_info['templates'];
}
}
if (!empty($template_list)) {
foreach ($template_list as $plugin_tpl) {
if (!empty($plugin_tpl)) {
//$template_plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/$plugin_tpl"; //for smarty
$template_plugin_file = "$plugin_name/$plugin_tpl"; // for twig
$template_plugin_file = "$plugin_name/$plugin_tpl"; // for twig
$template->display($template_plugin_file);
}
}
}
}
}
}
}
}
return true;
}
/**
* Loads plugin info
* Loads plugin info
* @staticvar array $plugin_data
* @param string plugin name
* @param bool load from DB or from the static array
* @todo filter setting_form
* @return array
* @return array
*/
function get_plugin_info($plugin_name, $forced = false) {
static $plugin_data = array();
if (isset($plugin_data[$plugin_name]) && $forced == false) {
return $plugin_data[$plugin_name];
if (isset($plugin_data[$plugin_name]) && $forced == false) {
return $plugin_data[$plugin_name];
} else {
$plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php";
$plugin_info = array();
if (file_exists($plugin_file)) {
require $plugin_file;
}
require $plugin_file;
}
//extra options
$plugin_settings = api_get_settings_params(array("subkey = ? AND category = ? AND type = ? " =>
array($plugin_name, 'Plugins','setting')));
array($plugin_name, 'Plugins','setting')));
$settings_filtered = array();
foreach ($plugin_settings as $item) {
$settings_filtered[$item['variable']] = $item['selected_value'];
}
$plugin_info['settings'] = $settings_filtered;
$plugin_data[$plugin_name] = $plugin_info;
$plugin_info['settings'] = $settings_filtered;
$plugin_data[$plugin_name] = $plugin_info;
return $plugin_info;
}
}
/*
* Get the template list
*/
function get_templates_list($plugin_name) {
$plugin_info = $this->get_plugin_info($plugin_name);
$plugin_info = $this->get_plugin_info($plugin_name);
if (isset($plugin_info) && isset($plugin_info['templates'])) {
return $plugin_info['templates'];
} else {
return false;
}
}
/* *
* Remove all regions of an specific plugin
*/
@ -291,15 +291,73 @@ class AppPlugin {
if (!empty($plugin)) {
api_delete_settings_params(array('category = ? AND type = ? AND access_url = ? AND subkey = ? ' =>
array('Plugins', 'region', $access_url_id, $plugin)));
}
}
/*
/*
* Add a plugin to a region
*/
function add_to_region($plugin, $region) {
$access_url_id = api_get_current_access_url_id();
api_add_setting($plugin, $region, $plugin, 'region', 'Plugins', $plugin, null, null, null, $access_url_id, 1);
api_add_setting($plugin, $region, $plugin, 'region', 'Plugins', $plugin, null, null, null, $access_url_id, 1);
}
function install_course_plugins($course_id) {
$plugin_list = $this->get_installed_plugins();
if (!empty($plugin_list)) {
foreach ($plugin_list as $plugin_name) {
$plugin_path = api_get_path(SYS_PLUGIN_PATH).$plugin_name.'/plugin.php';
if (file_exists($plugin_path)) {
require_once $plugin_path;
if (isset($plugin_info) && isset($plugin_info['plugin_class'])) {
$plugin_info['plugin_class']::create()->course_install($course_id);
}
}
}
}
}
function add_course_settings_form($form) {
$plugin_list = $this->get_installed_plugins();
foreach ($plugin_list as $plugin_name) {
$plugin_info = $this->get_plugin_info($plugin_name);
if (isset($plugin_info['plugin_class'])) {
$obj = $plugin_info['plugin_class']::create();
if (!empty($obj->course_settings)) {
$icon = Display::return_icon($plugin_name.'.png', Security::remove_XSS($plugin_info['title']),'', ICON_SIZE_SMALL);
//$icon = null;
$form->addElement('html', '<div><h3>'.$icon.Security::remove_XSS($plugin_info['title']).'</h3><div>');
foreach ($obj->course_settings as $setting) {
$form->addElement($setting['type'], $setting['name'], $obj->get_lang($setting['name']));
}
$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
$form->addElement('html', '</div></div>');
}
}
}
}
function set_course_settings_defaults(& $values) {
$plugin_list = $this->get_installed_plugins();
foreach ($plugin_list as $plugin_name) {
$plugin_info = $this->get_plugin_info($plugin_name);
if (isset($plugin_info['plugin_class'])) {
$obj = $plugin_info['plugin_class']::create();
if (!empty($obj->course_settings)) {
foreach ($obj->course_settings as $setting) {
if (isset($setting['name'])) {
$result = api_get_course_setting($setting['name']);
if ($result != '-1') {
$values[$setting['name']] = $result;
}
}
}
}
}
}
}
}

@ -1,14 +0,0 @@
<?php
/**
* This script is executed when a new course is created
* @package chamilo.plugin.bigbluebutton
*/
/**
* Initialization
*/
require 'config.php';
// $course_id is set in the add_course.lib.inc.php
if (!empty($course_id)) {
BBBPlugin::create()->course_install($course_id);
}

@ -41,5 +41,8 @@ $strings['salt'] = 'BigBlueButton salt';
$strings['salt_help'] = 'This is the security key of your BigBlueButton server, which will allow your server to authentify the Chamilo installation. Refer to the BigBlueButton documentation to locate it. Try bbb-conf --salt';
$strings['tool_enable'] = 'BigBlueButton videoconference tool enabled';
$strings['tool_enable_help'] = "Choose whether you want to enable the BigBlueButton videoconference tool.
Once enabled, it will show as an additional course tool in all courses' homepage, and teachers will be able to launch a conference at any time. Students will not be able to launch a conference, only join one. If you don't have a BigBlueButton server, please <a target=\"_blank\" href=\"http://bigbluebutton.org/\">set one up</a> or ask the Chamilo official providers for a quote. BigBlueButton is a free (as in freedom *and* beer), but its installation requires a set of technical skills that might not be immediately available to all. You can install it on your own or seek professional help to assist you or do it for you. This help, however, will generate a certain cost. In the pure logic of the free software, we offer you the tools to make your work easier and recommend professionals (the Chamilo Official Providers) that will be able to help you if this were too difficult.<br />";
$strings['tool_enable_help'] = "Choose whether you want to enable the BigBlueButton videoconference tool.
Once enabled, it will show as an additional course tool in all courses' homepage, and teachers will be able to launch a conference at any time. Students will not be able to launch a conference, only join one. If you don't have a BigBlueButton server, please <a target=\"_blank\" href=\"http://bigbluebutton.org/\">set one up</a> or ask the Chamilo official providers for a quote. BigBlueButton is a free (as in freedom *and* beer), but its installation requires a set of technical skills that might not be immediately available to all. You can install it on your own or seek professional help to assist you or do it for you. This help, however, will generate a certain cost. In the pure logic of the free software, we offer you the tools to make your work easier and recommend professionals (the Chamilo Official Providers) that will be able to help you if this were too difficult.<br />";
$strings['big_blue_button_welcome_message'] = 'Welcome message';
$strings['big_blue_button_record_and_store'] = 'Record and store sessions';

@ -8,7 +8,7 @@ require_once api_get_path(LIBRARY_PATH).'plugin.class.php';
require_once 'bbb_plugin.class.php';
class bbb {
var $url;
var $salt;
var $api;
@ -17,72 +17,77 @@ class bbb {
var $debug = true;
var $logout_url = null;
var $plugin_enabled = false;
function __construct() {
// initialize video server settings from global settings
// initialize video server settings from global settings
$plugin = BBBPlugin::create();
$bbb_plugin = $plugin->get('tool_enable');
$bbb_plugin = $plugin->get('tool_enable');
$bbb_host = $plugin->get('host');
$bbb_salt = $plugin->get('salt');
$course_code = api_get_course_id();
$this->logout_url = api_get_path(WEB_COURSE_PATH).$course_code;
$this->logout_url = api_get_path(WEB_COURSE_PATH).$course_code;
$this->table = Database::get_main_table('plugin_bbb_meeting');
if ($bbb_plugin == true) {
$user_info = api_get_user_info();
$this->user_complete_name = $user_info['complete_name'];
$this->user_complete_name = $user_info['complete_name'];
$this->salt = $bbb_salt;
$this->url = $bbb_host.'/bigbluebutton/';
$info = parse_url($bbb_host);
$this->url = $bbb_host.'/bigbluebutton/';
if (isset($info['scheme'])) {
$this->protocol = $info['scheme'].'://';
$this->url = str_replace($this->protocol, '', $this->url);
}
$this->plugin_enabled = true;
}
}
}
function is_teacher() {
return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
}
function create_meeting($params) {
$params['c_id'] = api_get_course_int_id();
function create_meeting($params) {
$params['c_id'] = api_get_course_int_id();
$course_code = api_get_course_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'] : api_get_course_id().'mod';
$params['record'] = api_get_course_setting('big_blue_button_record_and_store', $course_code) == 1 ? true : false;
$max = api_get_course_setting('big_blue_button_max_students_allowed', $course_code);
$max = isset($max) ? $max : -1;
$params['status'] = 1;
if ($this->debug) error_log("enter create_meeting ".print_r($params, 1));
$params['created_at'] = api_get_utc_datetime();
$id = Database::insert($this->table, $params);
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();
$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;
// ??
// ??
$voiceBridge = 0;
$metadata = array('maxParticipants' => $max);
$metadata = array('maxParticipants' => $max);
$result = $this->protocol.BigBlueButtonBN::createMeetingAndGetJoinURL(
$this->user_complete_name, $meeting_name, $id, $welcome_msg, $moderator_password, $attende_password,
$this->user_complete_name, $meeting_name, $id, $welcome_msg, $moderator_password, $attende_password,
$this->salt, $this->url, $this->logout_url, $record, $duration, $voiceBridge, $metadata
);
);
if ($this->debug) error_log("create_meeting result: ".print_r($result,1));
return $result;
}
}
function is_meeting_exist($meeting_name) {
$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');
@ -93,178 +98,177 @@ class bbb {
return true;
}
}
/**
* @todo implement moderator pass
*/
function join_meeting($meeting_name) {
function join_meeting($meeting_name) {
$pass = $this->get_user_meeting_password();
$mod_pass = $this->get_mod_meeting_password();
$meeting_data = Database::select('*', $this->table, array('where' => array('meeting_name = ? AND status = 1 ' => $meeting_name)), 'first');
if (empty($meeting_data)) {
if ($this->debug) error_log("meeting does not exist: $meeting_name ");
return false;
}
}
$meeting_is_running = BigBlueButtonBN::isMeetingRunning($meeting_data['id'], $this->url, $this->salt);
$meeting_info = BigBlueButtonBN::getMeetingInfoArray($meeting_data['id'], $mod_pass, $this->url, $this->salt);
$meeting_info_exists = false;
if ($meeting_info['returncode'] != 'FAILED') {
$meeting_info_exists = true;
}
$url = false;
if ($this->debug) error_log("meeting is running: ".$meeting_is_running);
if ($this->debug) error_log("meeting is running: ".$meeting_is_running);
if ($this->debug) error_log("meeting is running:getMeetingInfoArray ".print_r($meeting_info, 1));
if (isset($meeting_is_running) && $meeting_info_exists) {
$url = $this->protocol.BigBlueButtonBN::joinURL($meeting_data['id'], $this->user_complete_name, $pass, $this->salt, $this->url);
if (isset($meeting_is_running) && $meeting_info_exists) {
$url = $this->protocol.BigBlueButtonBN::joinURL($meeting_data['id'], $this->user_complete_name, $pass, $this->salt, $this->url);
}
if ($this->debug) error_log("return url :".$url);
return $url;
}
}
/**
* Gets all the course meetings saved in the plugin_bbb_meeting table
* @return string
* @return string
*/
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 = ? ' => api_get_course_int_id())));
$new_meeting_list = array();
foreach ($meeting_list as $meeting) {
$item_meeting = $meeting;
$item_meeting['info'] = BigBlueButtonBN::getMeetingInfoArray($meeting['id'], $pass, $this->url, $this->salt);
if ($meeting['info']['returncode'] == 'FAILED') {
$item = array();
foreach ($meeting_list as $meeting_db) {
$meeting_bbb = BigBlueButtonBN::getMeetingInfoArray($meeting_db['id'], $pass, $this->url, $this->salt);
if ($meeting_bbb['returncode'] == 'FAILED') {
} else {
$item_meeting['end_url'] = api_get_self().'?action=end&id='.$meeting['id'];
$item_meeting['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meeting['id'].'&start='.api_strtotime($meeting['created_at']);
}
$meeting_bbb['end_url'] = api_get_self().'?action=end&id='.$meeting_db['id'];
$meeting_bbb['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']);
}
$record_array = array();
if ($meeting['record'] == 1) {
$records = BigBlueButtonBN::getRecordingsArray($meeting['id'], $this->url, $this->salt);
if ($meeting_db['record'] == 1) {
$records = BigBlueButtonBN::getRecordingsArray($meeting_db['id'], $this->url, $this->salt);
//var_dump($meeting['id']);
if (!empty($records)) {
$count = 1;
foreach ($records as $record) {
foreach ($records as $record) {
if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) {
//Fix the bbb timestamp
//$record['startTime'] = substr($record['startTime'], 0, strlen($record['startTime']) -3);
//$record['endTime'] = substr($record['endTime'], 0, strlen($record['endTime']) -3);
//.' - '.api_convert_and_format_date($record['startTime']).' - '.api_convert_and_format_date($record['endTime'])
foreach ($record['playbacks'] as $item) {
//.' - '.api_convert_and_format_date($record['startTime']).' - '.api_convert_and_format_date($record['endTime'])
foreach ($record['playbacks'] as $item) {
$url = Display::url(get_lang('ViewRecord'), $item['url'], array('target' => '_blank'));
//$url .= Display::url(get_lang('DeleteRecord'), api_get_self().'?action=delete_record&'.$record['recordID']);
if ($this->is_teacher()) {
$url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meeting['id'].'&record_id='.$record['recordID']);
$url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meeting['id'].'&start='.api_strtotime($meeting['created_at']).'&url='.$item['url']);
$url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meeting_db['id'].'&record_id='.$record['recordID']);
$url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']).'&url='.$item['url']);
$url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordID']);
}
//$url .= api_get_self().'?action=publish&id='.$record['recordID'];
$count++;
$record_array[] = $url;
}
}
}
}
}
$item_meeting['show_links'] = implode('<br />', $record_array);
$item['show_links'] = implode('<br />', $record_array);
}
$item_meeting['created_at'] = api_convert_and_format_date($item_meeting['created_at']);
$item['created_at'] = api_convert_and_format_date($meeting_db['created_at']);
//created_at
$item_meeting['publish_url'] = api_get_self().'?action=publish&id='.$meeting['id'];
$item_meeting['unpublish_url'] = api_get_self().'?action=unpublish&id='.$meeting['id'];
if ($meeting['status'] == 1) {
$item_meeting['go_url'] = $this->protocol.BigBlueButtonBN::joinURL($meeting['id'], $this->user_complete_name, $pass, $this->salt, $this->url);
$item['publish_url'] = api_get_self().'?action=publish&id='.$meeting_db['id'];
$item['unpublish_url'] = api_get_self().'?action=unpublish&id='.$meeting_db['id'];
if ($meeting_db['status'] == 1) {
$item['go_url'] = $this->protocol.BigBlueButtonBN::joinURL($meeting_db['id'], $this->user_complete_name, $pass, $this->salt, $this->url);
}
$new_meeting_list[] = $item_meeting;
}
$item = array_merge($item, $meeting_db, $meeting_bbb);
$new_meeting_list[] = $item;
}
return $new_meeting_list;
}
function publish_meeting($id) {
return BigBlueButtonBN::setPublishRecordings($id, 'true', $this->url, $this->salt);
}
function unpublish_meeting($id) {
return BigBlueButtonBN::setPublishRecordings($id, 'false', $this->url, $this->salt);
}
function end_meeting($id) {
$pass = $this->get_user_meeting_password();
BigBlueButtonBN::endMeeting($id, $pass, $this->url, $this->salt);
Database::update($this->table, array('status' => 0), array('id = ? ' => $id));
}
function get_user_meeting_password() {
function get_user_meeting_password() {
if ($this->is_teacher()) {
return api_get_course_id().'mod';
} else {
return api_get_course_id();
}
}
function get_mod_meeting_password() {
return api_get_course_id().'mod';
function get_mod_meeting_password() {
return api_get_course_id().'mod';
}
/**
* Get users online in the current course room
* Get users online in the current course room
*/
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');
$meeting_data = Database::select('*', $this->table, array('where' => array('c_id = ? AND status = 1 ' => $course_id)), 'first');
if (empty($meeting_data)) {
return 0;
}
$pass = $this->get_mod_meeting_password();
}
$pass = $this->get_mod_meeting_password();
//$meeting_is_running = BigBlueButtonBN::isMeetingRunning($meeting_data['id'], $this->url, $this->salt);
$info = BigBlueButtonBN::getMeetingInfoArray($meeting_data['id'], $pass, $this->url, $this->salt);
if (!empty($info) && isset($info['participantCount'])) {
return $info['participantCount'];
}
return 0;
}
}
function delete_record($ids) {
return BigBlueButtonBN::deleteRecordings($ids, $this->url, $this->salt);
return BigBlueButtonBN::deleteRecordings($ids, $this->url, $this->salt);
}
function copy_record_to_link_tool($id, $record_id) {
require_once api_get_path(LIBRARY_PATH).'link.lib.php';
$records = BigBlueButtonBN::getRecordingsArray($id, $this->url, $this->salt);
require_once api_get_path(LIBRARY_PATH).'link.lib.php';
$records = BigBlueButtonBN::getRecordingsArray($id, $this->url, $this->salt);
if (!empty($records)) {
foreach ($records as $record) {
if ($record['recordID'] == $record_id) {
if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) {
foreach ($record['playbacks'] as $item) {
$link = new Link();
$link = new Link();
$params['url'] = $item['url'];
$params['title'] = 'bbb 1';
$params['title'] = 'bbb 1';
$id = $link->save($params);
return $id;
}
}
}
}
}
}
return false;
return false;
}
function is_server_running() {
return BigBlueButtonBN::isServerRunning($this->url);
return BigBlueButtonBN::isServerRunning($this->protocol.$this->url);
}
}

@ -33,7 +33,7 @@ Versions:
/*
@param
$userName = userName AND meetingID (string)
$userName = userName AND meetingID (string)
$welcomeString = welcome message (string)
$modPW = moderator password (string)
@ -45,24 +45,24 @@ $logout = logout url (url)
// TODO::
// create some set methods
// create some set methods
class BigBlueButtonBN {
var $userName = array();
var $meetingID; // the meeting id
var $welcomeString;
// the next 2 fields are maybe not needed?!?
var $modPW; // the moderator password
var $modPW; // the moderator password
var $attPW; // the attendee pw
var $securitySalt; // the security salt; gets encrypted with sha1
var $URL; // the url the bigbluebuttonbn server is installed
var $sessionURL; // the url for the administrator to join the sessoin
var $userURL;
var $conferenceIsRunning = false;
// this constructor is used to create a BigBlueButton Object
// use this object to create servers
// Use is either 0 arguments or all 7 arguments
@ -81,12 +81,12 @@ class BigBlueButtonBN {
$this->attPW = func_get_arg(4);
$this->securitySalt = func_get_arg(5);
$this->URL = func_get_arg(6);
$arg_list = func_get_args();
}// end else if
}
//------------------------------------------------GET URLs-------------------------------------------------
/**
*This method returns the url to join the specified meeting.
@ -105,7 +105,7 @@ class BigBlueButtonBN {
return ($url_join.$params.'&checksum='.sha1("join".$params.$SALT) );
}
/**
*This method returns the url to join the specified meeting.
*
@ -135,18 +135,18 @@ class BigBlueButtonBN {
$params = 'name='.urlencode($name).'&meetingID='.urlencode($meetingID).'&attendeePW='.urlencode($attendeePW).'&moderatorPW='.urlencode($moderatorPW).'&voiceBridge='.$voiceBridge.'&logoutURL='.urlencode($logoutURL).'&record='.$record.$meta;
$duration = intval($duration);
$duration = intval($duration);
if( $duration > 0 )
$params .= '&duration='.$duration;
if( trim( $welcome ) )
if( trim( $welcome ) )
$params .= '&welcome='.urlencode($welcome);
return ( $url_create.$params.'&checksum='.sha1("create".$params.$SALT) );
}
/**
*This method returns the url to check if the specified meeting is running.
*
@ -159,7 +159,7 @@ class BigBlueButtonBN {
public static function isMeetingRunningURL( $meetingID, $URL, $SALT ) {
$base_url = $URL."api/isMeetingRunning?";
$params = 'meetingID='.urlencode($meetingID);
return ($base_url.$params.'&checksum='.sha1("isMeetingRunning".$params.$SALT) );
return ($base_url.$params.'&checksum='.sha1("isMeetingRunning".$params.$SALT) );
}
/**
@ -175,9 +175,9 @@ class BigBlueButtonBN {
public static function getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) {
$base_url = $URL."api/getMeetingInfo?";
$params = 'meetingID='.urlencode($meetingID).'&password='.urlencode($modPW);
return ( $base_url.$params.'&checksum='.sha1("getMeetingInfo".$params.$SALT));
return ( $base_url.$params.'&checksum='.sha1("getMeetingInfo".$params.$SALT));
}
/**
*This method returns the url for listing all meetings in the bigbluebuttonbn server.
*
@ -186,7 +186,7 @@ class BigBlueButtonBN {
*
*@return The url of getMeetings.
*/
public static function getMeetingsURL($URL, $SALT) {
public static function getMeetingsURL($URL, $SALT) {
$base_url = $URL."api/getMeetings?";
$params = '';
return ( $base_url.$params.'&checksum='.sha1("getMeetings".$params.$SALT));
@ -206,13 +206,13 @@ class BigBlueButtonBN {
$base_url = $URL."api/end?";
$params = 'meetingID='.urlencode($meetingID).'&password='.urlencode($modPW);
return ( $base_url.$params.'&checksum='.sha1("end".$params.$SALT) );
}
}
//-----------------------------------------------CREATE----------------------------------------------------
/**
*This method creates a meeting and returnS the join url for moderators.
*
*@param username
*@param username
*@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server
*@param welcomeString -- the welcome message to be displayed when a user logs in to the meeting
*@param mPW -- the moderator password of the meeting
@ -226,11 +226,11 @@ class BigBlueButtonBN {
*/
public static function createMeetingAndGetJoinURL( $username, $meeting_name, $meetingID, $welcomeString, $mPW, $aPW, $SALT, $URL, $logoutURL, $record = 'false', $duration=0, $voiceBridge=0, $metadata = array()) {
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::createMeetingURL($meeting_name, $meetingID, $aPW, $mPW, $welcomeString, $logoutURL, $SALT, $URL, $record, $duration, $voiceBridge, $metadata ) );
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::createMeetingURL($meeting_name, $meetingID, $aPW, $mPW, $welcomeString, $logoutURL, $SALT, $URL, $record, $duration, $voiceBridge, $metadata ) );
if( $xml && $xml->returncode == 'SUCCESS' ) {
return ( BigBlueButtonBN::joinURL( $meetingID, $username, $mPW, $SALT, $URL ) );
}
}
else if( $xml ) {
return ( $xml->messageKey.' : '.$xml->message );
}
@ -242,7 +242,7 @@ class BigBlueButtonBN {
/**
*This method creates a meeting and return an array of the xml packet
*
*@param username
*@param username
*@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server
*@param welcomeString -- the welcome message to be displayed when a user logs in to the meeting
*@param mPW -- the moderator password of the meeting
@ -254,7 +254,7 @@ class BigBlueButtonBN {
*
*@return
* - Null if unable to reach the bigbluebuttonbn server
* - If failed it returns an array containing a returncode, messageKey, message.
* - If failed it returns an array containing a returncode, messageKey, message.
* - If success it returns an array containing a returncode, messageKey, message, meetingID, attendeePW, moderatorPW, hasBeenForciblyEnded.
*/
public static function createMeetingArray( $username, $meetingID, $welcomeString, $mPW, $aPW, $SALT, $URL, $logoutURL, $record='false', $duration=0, $voiceBridge=0, $metadata = array() ) {
@ -268,8 +268,8 @@ class BigBlueButtonBN {
else {
return null;
}
}
}
//-------------------------------------------getMeetingInfo---------------------------------------------------
/**
*This method calls the getMeetingInfo on the bigbluebuttonbn server and returns an xml packet.
@ -279,9 +279,9 @@ class BigBlueButtonBN {
*@param SALT -- the security salt of the bigbluebuttonbn server
*@param URL -- the url of the bigbluebuttonbn server
*
*@return An xml packet.
* If failed it returns an xml packet containing a returncode, messagekey, and message.
* If success it returnsan xml packet containing a returncode,
*@return An xml packet.
* If failed it returns an xml packet containing a returncode, messagekey, and message.
* If success it returnsan xml packet containing a returncode,
*/
public static function getMeetingInfo( $meetingID, $modPW, $URL, $SALT ) {
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) );
@ -299,15 +299,15 @@ class BigBlueButtonBN {
*@param SALT -- the security salt of the bigbluebuttonbn server
*@param URL -- the url of the bigbluebuttonbn server
*
*@return An Array.
*@return An Array.
* - Null if unable to reach the bigbluebuttonbn server
* - If failed it returns an array containing a returncode, messagekey, message.
* - If success it returns an array containing a meetingID, moderatorPW, attendeePW, hasBeenForciblyEnded, running, startTime, endTime,
* - If failed it returns an array containing a returncode, messagekey, message.
* - If success it returns an array containing a meetingID, moderatorPW, attendeePW, hasBeenForciblyEnded, running, startTime, endTime,
participantCount, moderatorCount, attendees.
*/
public static function getMeetingInfoArray( $meetingID, $modPW, $URL, $SALT ) {
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) );
if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey == null){//The meetings were returned
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey );
}
@ -323,7 +323,7 @@ class BigBlueButtonBN {
}
}
//-----------------------------------------------getMeetings------------------------------------------------------
/**
*This method calls getMeetings on the bigbluebuttonbn server, then calls getMeetingInfo for each meeting and concatenates the result.
@ -331,7 +331,7 @@ class BigBlueButtonBN {
*@param URL -- the url of the bigbluebuttonbn server
*@param SALT -- the security salt of the bigbluebuttonbn server
*
*@return
*@return
* - If failed then returns a boolean of false.
* - If succeeded then returns an xml of all the meetings.
*/
@ -339,7 +339,7 @@ class BigBlueButtonBN {
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::getMeetingsURL( $URL, $SALT ) );
if( $xml && $xml->returncode == 'SUCCESS' ) {
if( $xml->messageKey )
return ( $xml->message->asXML() );
return ( $xml->message->asXML() );
ob_start();
echo '<meetings>';
if( count( $xml->meetings ) && count( $xml->meetings->meeting ) ) {
@ -364,10 +364,10 @@ class BigBlueButtonBN {
*@param URL -- the url of the bigbluebuttonbn server
*@param SALT -- the security salt of the bigbluebuttonbn server
*
*@return
*@return
* - Null if the server is unreachable
* - If FAILED then returns an array containing a returncode, messageKey, message.
* - If SUCCESS then returns an array of all the meetings. Each element in the array is an array containing a meetingID,
* - If SUCCESS then returns an array of all the meetings. Each element in the array is an array containing a meetingID,
moderatorPW, attendeePW, hasBeenForciblyEnded, running.
*/
public static function getMeetingsArray( $URL, $SALT ) {
@ -377,7 +377,7 @@ class BigBlueButtonBN {
return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
}
else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created
foreach ($xml->meetings->meeting as $meeting)
{
$meetings[] = array( 'meetingID' => $meeting->meetingID, 'moderatorPW' => $meeting->moderatorPW, 'attendeePW' => $meeting->attendeePW, 'hasBeenForciblyEnded' => $meeting->hasBeenForciblyEnded, 'running' => $meeting->running );
@ -393,7 +393,7 @@ class BigBlueButtonBN {
return null;
}
}
//----------------------------------------------getUsers---------------------------------------
/**
*This method prints the usernames of the attendees in the specified conference.
@ -426,7 +426,7 @@ class BigBlueButtonBN {
return (false);
}
}
/**
*This method returns an array of the attendees in the specified meeting.
*
@ -459,8 +459,8 @@ class BigBlueButtonBN {
return null;
}
}
//------------------------------------------------Other Methods------------------------------------
/**
*This method calls end meeting on the specified meeting in the bigbluebuttonbn server.
@ -485,7 +485,7 @@ class BigBlueButtonBN {
}
}
/**
*This method check the BigBlueButton server to see if the meeting is running (i.e. there is someone in the meeting)
*
@ -497,12 +497,12 @@ class BigBlueButtonBN {
*/
public static function isMeetingRunning( $meetingID, $URL, $SALT ) {
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::isMeetingRunningURL( $meetingID, $URL, $SALT ) );
if( $xml && $xml->returncode == 'SUCCESS' )
if( $xml && $xml->returncode == 'SUCCESS' )
return ( ( $xml->running == 'true' ) ? true : false);
else
return ( false );
}
/**
*This method calls isMeetingRunning on the BigBlueButton server.
*
@ -510,19 +510,19 @@ class BigBlueButtonBN {
*@param SALT -- the security salt of the bigbluebuttonbn server
*@param URL -- the url of the bigbluebuttonbn server
*
*@return
*@return
* - If SUCCESS it returns an xml packet
* - If the FAILED or the server is unreachable returns a string of 'false'
*/
public static function getMeetingXML( $meetingID, $URL, $SALT ) {
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::isMeetingRunningURL( $meetingID, $URL, $SALT ) );
if( $xml && $xml->returncode == 'SUCCESS')
if( $xml && $xml->returncode == 'SUCCESS')
return ( str_replace('</response>', '', str_replace("<?xml version=\"1.0\"?>\n<response>", '', $xml->asXML())));
else
return 'false';
return 'false';
}
// TODO: WRITE AN ITERATOR WHICH GOES OVER WHATEVER IT IS BEING TOLD IN THE API AND LIST INFORMATION
/* we have to define at least 2 variable fields for getInformation to read out information at any position
The first is: An identifier to chose if we look for attendees or the meetings or something else
@ -556,19 +556,19 @@ class BigBlueButtonBN {
else {
return true;
}
}
function getServerIP() {
// get the server url
$sIP = $_SERVER['SERVER_ADDR'];
return $serverIP = 'http://'.$sIP.'/bigbluebuttonbn/';
}
/**
*This method check the BigBlueButton server to see if the meeting has been created
*This method check the BigBlueButton server to see if the meeting has been created
*
*@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server
*@param SALT -- the security salt of the bigbluebuttonbn server
@ -588,7 +588,7 @@ class BigBlueButtonBN {
}
/**
*This method creates a new meeting room in the BigBlueButton server
*This method creates a new meeting room in the BigBlueButton server
*
*@param name -- a name fot the meeting
*@param meetingID -- the unique meeting identifier used to store the meeting in the bigbluebuttonbn server
@ -601,7 +601,7 @@ class BigBlueButtonBN {
*@param record -- the flag which indicate if the meetings will be recorded or not record=true|false, default false
*
*@return A boolean of true if the meeting has been created, doesn't matter if is running or not and false if it was an error
*/
*/
public static function createMeeting($name, $meetingID, $attendeePW, $moderatorPW, $welcome, $logoutURL, $SALT, $URL, $record = 'false', $duration=0, $voiceBridge=0, $metadata = array() ) {
@ -629,10 +629,10 @@ class BigBlueButtonBN {
*@param URL -- the url of the bigbluebuttonbn server
*@param SALT -- the security salt of the bigbluebuttonbn server
*
*@return
*@return
* - Null if the server is unreachable
* - If FAILED then returns an array containing a returncode, messageKey, message.
* - If SUCCESS then returns an array of all the meetings. Each element in the array is an array containing a meetingID,
* - If SUCCESS then returns an array of all the meetings. Each element in the array is an array containing a meetingID,
moderatorPW, attendeePW, hasBeenForciblyEnded, running.
*/
public static function getRecordingsArray($meetingID, $URL, $SALT ) {
@ -641,7 +641,7 @@ class BigBlueButtonBN {
return array('returncode' => (string) $xml->returncode, 'message' => (string) $xml->message, 'messageKey' => (string) $xml->messageKey);
} else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created
$recordings = array();
foreach ($xml->recordings->recording as $recording) {
$recordings[(string) $recording->recordID] = array( 'recordID' => (string) $recording->recordID, 'meetingID' => (string) $recording->meetingID, 'meetingName' => (string) $recording->name, 'published' => (string) $recording->published, 'startTime' => (string) $recording->startTime, 'endTime' => (string) $recording->endTime );
$recordings[(string) $recording->recordID]['playbacks'] = array();
@ -650,7 +650,7 @@ class BigBlueButtonBN {
}
// THIS IS FOR TESTING MULTIPLE FORMATS, DO REMOVE IT FOR FINAL RELEASE
//$recordings[(string) $recording->recordID]['playbacks']['desktop'] = array( 'type' => 'desktop', 'url' => (string) $recording->playback->format->url );
//Add the metadata to the recordings array
$metadata = get_object_vars($recording->metadata);
while ($data = current($metadata)) {
@ -658,7 +658,7 @@ class BigBlueButtonBN {
next($metadata);
}
}
ksort($recordings);
return $recordings;
@ -676,10 +676,10 @@ class BigBlueButtonBN {
$params = 'recordID='.urlencode($recordID);
return ($url_delete.$params.'&checksum='.sha1("deleteRecordings".$params.$SALT) );
}
public static function deleteRecordings( $recordIDs, $URL, $SALT ) {
$ids = explode(",", $recordIDs);
foreach( $ids as $id){
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::deleteRecordingsURL($id, $URL, $SALT) );
@ -696,13 +696,13 @@ class BigBlueButtonBN {
$params = 'recordID='.$recordID."&publish=".$set;
return ($url_delete.$params.'&checksum='.sha1("publishRecordings".$params.$SALT) );
}
public static function setPublishRecordings( $recordIDs, $set, $URL, $SALT ) {
$ids = explode(",", $recordIDs);
$ids = explode(",", $recordIDs);
foreach( $ids as $id){
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::setPublishRecordingsURL($id, $set, $URL, $SALT) );
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( BigBlueButtonBN::setPublishRecordingsURL($id, $set, $URL, $SALT) );
if( $xml && $xml->returncode != 'SUCCESS' )
return false;
}
@ -710,10 +710,10 @@ class BigBlueButtonBN {
}
public static function getServerVersion( $URL ){
$base_url_record = $URL."api";
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( $base_url_record );
if( $xml && $xml->returncode == 'SUCCESS' )
return $xml->version;
@ -724,7 +724,7 @@ class BigBlueButtonBN {
public static function isServerRunning( $URL ){
$base_url_record = $URL."api";
$xml = BigBlueButtonBN::_wrap_simplexml_load_file( $base_url_record );
if( $xml && $xml->returncode == 'SUCCESS' )
return true;
@ -732,14 +732,14 @@ class BigBlueButtonBN {
return false;
}
public function _wrap_simplexml_load_file($url){
if (extension_loaded('curl')) {
$ch = curl_init() or die ( curl_error() );
$timeout = 10;
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout);
@ -753,8 +753,8 @@ class BigBlueButtonBN {
}
return (simplexml_load_file($url,'SimpleXMLElement', LIBXML_NOCDATA));
}
}
}
//----End

@ -1,75 +1,30 @@
<?php
class BBBPlugin extends Plugin
{
public $variables = array(
'big_blue_button_meeting_name',
'big_blue_button_attendee_password',
'big_blue_button_moderator_password',
'big_blue_button_welcome_message',
'big_blue_button_max_students_allowed',
{
//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')
);
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'));
}
function course_install($course_id) {
if (empty($course_id)) {
return false;
}
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_welcome_message','','plugins')";
$r = Database::query($sql_course);
/*
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_meeting_name','','plugins')";
$r = Database::query($sql_course);
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_attendee_password','','plugins')";
$r = Database::query($sql_course);
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_moderator_password','','plugins')";
$r = Database::query($sql_course);
//New BBB settings
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_max_students_allowed','','plugins')";
$r = Database::query($sql_course);
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_open_new_window','','plugins')";
$r = Database::query($sql_course);
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_student_must_wait_until_moderator','','plugins')";
$r = Database::query($sql_course);
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_join_start_date','','plugins')";
$r = Database::query($sql_course);
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_join_end_date','','plugins')";
$r = Database::query($sql_course);*/
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, 'big_blue_button_record_and_store','','plugins')";
$r = Database::query($sql_course);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
$sql_course = "INSERT INTO $t_tool VALUES ($course_id, NULL, 'videoconference','../../plugin/bbb/start.php','visio.gif','".string2binary(api_get_setting('course_create_active_tools', 'videoconference'))."','0','squaregrey.gif','NO','_self','plugin','0')";
$r = Database::query($sql_course);
}
function install() {
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
function install() {
$table = Database::get_main_table('plugin_bbb_meeting');
$sql = "CREATE TABLE $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
$sql = "CREATE TABLE $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
c_id INT unsigned NOT NULL DEFAULT 0,
meeting_name VARCHAR(255) NOT NULL DEFAULT '',
meeting_name VARCHAR(255) NOT NULL DEFAULT '',
attendee_pw VARCHAR(255) NOT NULL DEFAULT '',
moderator_pw VARCHAR(255) NOT NULL DEFAULT '',
moderator_pw VARCHAR(255) NOT NULL DEFAULT '',
record INT NOT NULL DEFAULT 0,
status INT NOT NULL DEFAULT 0,
created_at VARCHAR(255) NOT NULL,
@ -77,73 +32,41 @@ class BBBPlugin extends Plugin
welcome_msg VARCHAR(255) NOT NULL DEFAULT '')";
Database::query($sql);
// Update existing courses to add conference settings
$t_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id, code FROM $t_courses ORDER BY id";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$course_id = $row['id'];
foreach ($this->variables as $variable) {
$sql = "SELECT value FROM $t_course WHERE c_id = $course_id AND variable = '$variable' ";
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$sql_course = "INSERT INTO $t_course (c_id, variable,value,category) VALUES ($course_id, '$variable','','plugins')";
$r = Database::query($sql_course);
}
}
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
$sql = "SELECT name FROM $t_tool WHERE c_id = $course_id AND name = 'videoconference' ";
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$sql_course = "INSERT INTO $t_tool VALUES ($course_id, NULL, 'videoconference','../../plugin/bbb/start.php','visio.gif','".string2binary(api_get_setting('course_create_active_tools', 'videoconference'))."','0','squaregrey.gif','NO','_self','plugin','0')";
$r = Database::query($sql_course);
}
}
//Installing course settings
$this->install_course_fields_in_all_courses();
}
function uninstall() {
$t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
//New settings
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_tool_enable'";
Database::query($sql);
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_salt'";
Database::query($sql);
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_host'";
Database::query($sql);
//Old settings
//Old settings deleting just in case
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin'";
Database::query($sql);
$sql = "DELETE FROM $t_options WHERE variable = 'bbb_plugin'";
$sql = "DELETE FROM $t_options WHERE variable = 'bbb_plugin'";
Database::query($sql);
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_host'";
Database::query($sql);
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_salt'";
Database::query($sql);
$sql = "DELETE FROM $t_tool WHERE name = 'videoconference'";
Database::query($sql);
$sql = "DROP TABLE IF EXISTS plugin_bbb_meeting";
Database::query($sql);
// update existing courses to add conference settings
$t_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT id, code FROM $t_courses ORDER BY id";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
// $variables is loaded in the config.php file
foreach ($this->variables as $variable) {
$sql_course = "DELETE FROM $t_course WHERE c_id = " . $row['id'] . " AND variable = '$variable'";
$r = Database::query($sql_course);
}
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
$sql_course = "DELETE FROM $t_tool WHERE c_id = " . $row['id'] . " AND link = '../../plugin/bbb/start.php'";
$r = Database::query($sql_course);
}
//Deleting course settings
$this->uninstall_course_fields_in_all_courses();
}
}
Loading…
Cancel
Save