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

skala
Julio Montoya 14 years ago
parent 2a313714c8
commit 415612e5c3
  1. 92
      main/course_info/infocours.php
  2. BIN
      main/img/icons/22/bbb.png
  3. 9
      main/inc/autoload.inc.php
  4. 18
      main/inc/lib/add_course.lib.inc.php
  5. 102
      main/inc/lib/plugin.class.php
  6. 58
      main/inc/lib/plugin.lib.php
  7. 14
      plugin/bbb/course_install.php
  8. 3
      plugin/bbb/lang/english.php
  9. 44
      plugin/bbb/lib/bbb.lib.php
  10. 103
      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'];
@ -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);
// Plugin course settings
$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>');
}
$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,37 +398,7 @@ $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);
@ -497,33 +437,13 @@ if ($form->validate() && is_settings_editable()) {
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);
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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

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

@ -2504,22 +2504,10 @@ function fill_db_course($course_id, $course_repository, $language, $default_docu
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));
//Installing plugins in course
$app_plugin = new AppPlugin();
$app_plugin->install_course_plugins($course_id);
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
$language_interface = $language_interface_original;
return true;
};

@ -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;
@ -29,6 +45,7 @@ class Plugin {
$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;
@ -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]);
}
@ -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']);
}
}
}

@ -302,4 +302,62 @@ class AppPlugin {
$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);
}
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);
}

@ -43,3 +43,6 @@ $strings['salt_help'] = 'This is the security key of your BigBlueButton server,
$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['big_blue_button_welcome_message'] = 'Welcome message';
$strings['big_blue_button_record_and_store'] = 'Record and store sessions';

@ -36,7 +36,12 @@ class bbb {
$user_info = api_get_user_info();
$this->user_complete_name = $user_info['complete_name'];
$this->salt = $bbb_salt;
$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;
}
}
@ -134,20 +139,20 @@ class bbb {
$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);
$item = array();
if ($meeting['info']['returncode'] == 'FAILED') {
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;
@ -162,12 +167,10 @@ class bbb {
$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;
@ -175,19 +178,20 @@ class bbb {
}
}
}
$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'];
$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['status'] == 1) {
$item_meeting['go_url'] = $this->protocol.BigBlueButtonBN::joinURL($meeting['id'], $this->user_complete_name, $pass, $this->salt, $this->url);
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;
}
@ -265,6 +269,6 @@ class bbb {
}
function is_server_running() {
return BigBlueButtonBN::isServerRunning($this->url);
return BigBlueButtonBN::isServerRunning($this->protocol.$this->url);
}
}

@ -2,12 +2,10 @@
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() {
@ -19,50 +17,7 @@ class BBBPlugin extends Plugin
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);
$table = Database::get_main_table('plugin_bbb_meeting');
$sql = "CREATE TABLE $table (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
@ -77,34 +32,14 @@ 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_tool = Database::get_course_table(TABLE_TOOL_LIST);
//New settings
@ -115,8 +50,7 @@ class BBBPlugin extends Plugin
$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'";
@ -126,24 +60,13 @@ class BBBPlugin extends Plugin
$sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_salt'";
Database::query($sql);
$sql = "DROP TABLE IF EXISTS plugin_bbb_meeting";
$sql = "DELETE FROM $t_tool WHERE name = 'videoconference'";
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);
}
$sql = "DROP TABLE IF EXISTS plugin_bbb_meeting";
Database::query($sql);
$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