Moving code inside the lib folder, moving install, uninstall code in a class see BT#3123

skala
Julio Montoya 13 years ago
parent dbe0d408b1
commit 1b59b05808
  1. 13
      plugin/bbb/config.php
  2. 38
      plugin/bbb/course_install.php
  3. 5
      plugin/bbb/end.php
  4. 62
      plugin/bbb/install.php
  5. 4
      plugin/bbb/lang/english.php
  6. 3
      plugin/bbb/lib/bbb.lib.php
  7. 0
      plugin/bbb/lib/bbb_api.php
  8. 138
      plugin/bbb/lib/bbb_plugin.class.php
  9. 4
      plugin/bbb/listing.php
  10. 4
      plugin/bbb/plugin.php
  11. 4
      plugin/bbb/start.php
  12. 33
      plugin/bbb/uninstall.php

@ -3,9 +3,10 @@
/* bbb parameters that will be registered in the course settings */
$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'
);
require_once '../../main/inc/global.inc.php';
require_once 'lib/bbb_plugin.class.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once 'lib/bbb.lib.php';
require_once 'lib/bbb_api.php';
require_once 'lib/bbb_plugin.class.php';

@ -6,43 +6,9 @@
/**
* Initialization
*/
require 'config.php';
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
// $course_id is set in the add_course.lib.inc.php
if (!empty($course_id)) {
$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);
BBBPlugin::create()->course_install($course_id);
}

@ -6,6 +6,11 @@
/**
* Initialization
*/
//@todo check if this script is used
exit;
require_once '../../main/inc/global.inc.php';
require_once 'bbb.lib.php';
//The script receives the course_code (cidReq), which allows it to get the corresponding data

@ -8,63 +8,5 @@
* Initialization
*/
require 'config.php';
$t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
/**
* Queries
*/
$sql = "INSERT INTO $t_settings (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable, access_url_locked) VALUES
('bbb_plugin', '', 'radio', 'Extra', 'false', 'BigBlueButtonEnableTitle','BigBlueButtonEnableComment',NULL,NULL, 1, 1)";
Database::query($sql);
$sql = "INSERT INTO $t_options (variable, value, display_text) VALUES ('bbb_plugin', 'true', 'Yes')";
Database::query($sql);
$sql = "INSERT INTO $t_options (variable, value, display_text) VALUES ('bbb_plugin', 'false', 'No')";
Database::query($sql);
$sql = "INSERT INTO $t_settings (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable, access_url_locked) VALUES
('bbb_plugin_host', '', 'textfield', 'Extra', '192.168.0.100', 'BigBlueButtonHostTitle','BigBlueButtonHostComment',NULL,NULL, 1,1)";
Database::query($sql);
$sql = "INSERT INTO $t_settings (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable, access_url_locked) VALUES
('bbb_plugin_salt', '', 'textfield', 'Extra', '', 'BigBlueButtonSecuritySaltTitle','BigBlueButtonSecuritySaltComment',NULL,NULL, 1,1)";
Database::query($sql);
$table = Database::get_main_table('plugin_bbb_meeting');
$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 '',
attendee_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,
calendar_id INT DEFAULT 0,
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 ($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);
}
}
require_once 'config.php';
BBBPlugin::create()->install();

@ -7,8 +7,8 @@
*/
//Needed in order to show the plugin title
$strings['plugin_title'] = "BigBlueButton";
$strings['plugin_comment'] = "Open Source Videoconference tool";
$strings['plugin_title'] = "BigBlueButton (BBB)";
$strings['plugin_comment'] = "Adds a videoconference room Chamilo courses";
$strings['Videoconference'] = "Videoconference";
$strings['MeetingOpened'] = "Meeting opened";

@ -270,4 +270,7 @@ class bbb {
function is_server_running() {
return BigBlueButtonBN::isServerRunning($this->url);
}
}

@ -2,6 +2,13 @@
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'
);
static function create() {
static $result = null;
return $result ? $result : $result = new self();
@ -10,4 +17,135 @@ class BBBPlugin extends Plugin
protected function __construct() {
parent::__construct('2.0', 'Julio Montoya, Yannick Warnier');
}
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_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$t_course = Database::get_course_table(TABLE_COURSE_SETTING);
$sql = "INSERT INTO $t_settings (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable, access_url_locked) VALUES
('bbb_plugin', '', 'radio', 'Extra', 'false', 'BigBlueButtonEnableTitle','BigBlueButtonEnableComment',NULL,NULL, 1, 1)";
Database::query($sql);
$sql = "INSERT INTO $t_options (variable, value, display_text) VALUES ('bbb_plugin', 'true', 'Yes')";
Database::query($sql);
$sql = "INSERT INTO $t_options (variable, value, display_text) VALUES ('bbb_plugin', 'false', 'No')";
Database::query($sql);
$sql = "INSERT INTO $t_settings (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable, access_url_locked) VALUES
('bbb_plugin_host', '', 'textfield', 'Extra', '192.168.0.100', 'BigBlueButtonHostTitle','BigBlueButtonHostComment',NULL,NULL, 1,1)";
Database::query($sql);
$sql = "INSERT INTO $t_settings (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable, access_url_locked) VALUES
('bbb_plugin_salt', '', 'textfield', 'Extra', '', 'BigBlueButtonSecuritySaltTitle','BigBlueButtonSecuritySaltComment',NULL,NULL, 1,1)";
Database::query($sql);
$table = Database::get_main_table('plugin_bbb_meeting');
$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 '',
attendee_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,
calendar_id INT DEFAULT 0,
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);
}
}
}
function uninstall() {
$t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin'";
Database::query($sql);
$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 = "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);
}
}
}

@ -9,9 +9,7 @@
$course_plugin = 'bbb';
require_once '../../main/inc/global.inc.php';
require_once 'bbb.lib.php';
require_once 'bbb_api.php';
require_once 'config.php';
$tool_name = get_lang('Videoconference');
$tpl = new Template($tool_name);

@ -1,6 +1,4 @@
<?php
require_once api_get_path(LIBRARY_PATH) . '/plugin.class.php';
require_once dirname(__FILE__) . '/lib/bbb_plugin.class.php';
require_once 'config.php';
$plugin_info = BBBPlugin::create()->get_info();

@ -6,9 +6,7 @@
/**
* Initialization
*/
require_once '../../main/inc/global.inc.php';
require_once 'bbb.lib.php';
require_once 'bbb_api.php';
require_once 'config.php';
$tool_name = get_lang('Videoconference');
$tpl = new Template($tool_name);

@ -9,34 +9,5 @@
/**
* Queries
*/
require 'config.php';
$t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin'";
Database::query($sql);
$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 = "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 ($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);
}
require_once 'config.php';
BBBPlugin::create()->uninstall();
Loading…
Cancel
Save