Browse Source

Now we can add boolean (yes, no) options in a plugin settings, all BBB settings are now moved to the plugin see BT#3123

Julio Montoya 13 years ago
parent
commit
3414a8aa8b

+ 1 - 1
main/admin/configure_plugin.php

@@ -24,7 +24,6 @@ if (empty($plugin_info)) {
 
 $installed_plugins = $plugin_obj->get_installed_plugins();
 
-
 if (!in_array($plugin_name, $installed_plugins)) {
     api_not_allowed();
 }
@@ -49,6 +48,7 @@ if (isset($plugin_info['settings_form'])) {
 if (isset($form)) {
     if ($form->validate()) {
         $values = $form->exportValues();
+        
         //api_delete_category_settings_by_subkey($plugin_name);
         $access_url_id = api_get_current_access_url_id();
         api_delete_settings_params(array('category = ? AND access_url = ? AND subkey = ? AND type = ? and variable <> ?' =>

+ 1 - 1
main/course_info/infocours.php

@@ -42,7 +42,7 @@ $course_code 				= $_course['sysCode'];
 $course_access_settings 	= CourseManager :: get_access_settings($course_code);
 
 $video_conference_enabled = false;
-if (api_get_setting('bbb_plugin') == 'true') {
+if (api_get_setting('bbb_tool_enable') == 'true') {
     $video_conference_enabled = true;
 }
 

+ 0 - 1
main/inc/lib/display.lib.php

@@ -781,7 +781,6 @@ class Display {
         $lis = '';
         $i = 1;
         foreach ($header_list as $item) {
-
             $item =self::tag('a', $item, array('href'=>'#'.$id.'-'.$i));
             $lis .=self::tag('li', $item, $ul_attributes);
             $i++;

+ 31 - 11
main/inc/lib/plugin.class.php

@@ -29,6 +29,7 @@ class Plugin {
         $result['comment'] = $this->get_comment();
         $result['version'] = $this->get_version();
         $result['author'] = $this->get_author();
+        
         if ($form = $this->get_settings_form()) {
             $result['settings_form'] = $form;
             foreach ($this->fields as $name => $type) {
@@ -84,30 +85,45 @@ class Plugin {
         $defaults = array();
         foreach ($this->fields as $name => $type) {
             $value = $this->get($name);
+            
             $defaults[$name] = $value;
-            $type = $type ? $type : 'text';
-            if ($type == 'wysiwyg') {
-                $result->add_html_editor($name, $this->get_lang($name));
-            } else {
-                $result->addElement($type, $name, $this->get_lang($name));
+            $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));  
+                    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));    
+                    break;
+                case 'boolean':
+                    $group = array();
+                    $group[] = $result->createElement('radio', $name, '', get_lang('Yes'), 'true');
+                    $group[] = $result->createElement('radio', $name, '', get_lang('No'),  'false');                    
+                    $result->addGroup($group, null, array($this->get_lang($name), $help));
+                    break;
             }
         }
         $result->setDefaults($defaults);
-
         $result->addElement('style_submit_button', 'submit_button', $this->get_lang('Save'));
         return $result;
     }
 
-    function get($name) {
-        $content = '';
-        $title = 'Static';
-        $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'];
             }
         }
-
         return false;
     }
 
@@ -122,6 +138,10 @@ class Plugin {
     }
 
     private $strings = null;
+    
+    public function get_lang_plugin_exists($name) {
+        return isset($this->strings[$name]);
+    }
 
     public function get_lang($name) {
         if (is_null($this->strings)) {

+ 11 - 1
plugin/bbb/lang/english.php

@@ -32,4 +32,14 @@ $strings['RecordList']          = "Record list";
 $strings['ServerIsNotRunning']  = "Videoconference server is not running";
 $strings['ServerIsNotConfigured']  = "Videoconference server is not configured";
 
-$strings['XUsersOnLine']        = "%s user(s) online";
+$strings['XUsersOnLine']        = "%s user(s) online";
+
+$strings['host'] = 'BigBlueButton server host';
+$strings['host_help'] = 'This is the name of the server where your BigBlueButton server is running. Might be localhost, an IP address (e.g. 192.168.13.54) or a domain name (e.g. my.video.com)';
+
+$strings['salt'] = 'Security key of the BigBlueButton server';
+$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.';
+
+$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 />";

+ 3 - 3
plugin/bbb/lib/bbb.lib.php

@@ -25,9 +25,9 @@ class bbb {
                 $bbb_settings[$setting['variable']] = $setting['selected_value'];
             }
         }
-        $bbb_plugin = $bbb_settings['bbb_plugin'] === 'true';
-        $bbb_host   = $bbb_settings['bbb_plugin_host'];
-        $bbb_salt   = $bbb_settings['bbb_plugin_salt'];
+        $bbb_plugin = $bbb_settings['bbb_tool_enable'] === 'true';
+        $bbb_host   = $bbb_settings['bbb_host'];
+        $bbb_salt   = $bbb_settings['bbb_salt'];
         
         $course_code = api_get_course_id();
         

+ 18 - 20
plugin/bbb/lib/bbb_plugin.class.php

@@ -2,11 +2,12 @@
 
 class BBBPlugin extends Plugin
 {        
-    public $variables = array( 'big_blue_button_meeting_name',
+    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'    
+                    'big_blue_button_max_students_allowed', 
     );
     
     static function create() {
@@ -15,7 +16,7 @@ class BBBPlugin extends Plugin
     }
     
     protected function __construct() {
-        parent::__construct('2.0', 'Julio Montoya, Yannick Warnier');
+        parent::__construct('2.0', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text'));
     }
     
     function course_install($course_id) {    
@@ -60,23 +61,7 @@ class BBBPlugin extends Plugin
     }
     
     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 ( 
@@ -119,7 +104,18 @@ class BBBPlugin extends Plugin
     
     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);        
+        
+        //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
 
         $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin'";
         Database::query($sql);
@@ -129,8 +125,10 @@ class BBBPlugin extends Plugin
         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";

+ 1 - 1
plugin/search_course/plugin.php

@@ -5,7 +5,7 @@
  * @author Laurent Opprecht
  */
 
-require_once api_get_path(LIBRARY_PATH) . '/plugin.class.php';
+require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
 require_once dirname(__FILE__) . '/lib/search_course_plugin.class.php';
 
 $plugin_info = SearchCoursePlugin::create()->get_info();

+ 1 - 1
plugin/static/plugin.php

@@ -6,7 +6,7 @@
  * @author Laurent Opprecht
  */
 
-require_once api_get_path(LIBRARY_PATH) . '/plugin.class.php';
+require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
 require_once dirname(__FILE__) . '/lib/static_plugin.class.php';
 
 $plugin_info = StaticPlugin::create()->get_info();