bbb_plugin.class.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /* To show the plugin course icons you need to add these icons:
  4. * main/img/icons/22/plugin_name.png
  5. * main/img/icons/64/plugin_name.png
  6. * main/img/icons/64/plugin_name_na.png
  7. */
  8. /**
  9. * Videoconference plugin with BBB
  10. */
  11. //namespace Chamilo\Plugin\BBB;
  12. /**
  13. * Class BBBPlugin
  14. */
  15. class BBBPlugin extends Plugin
  16. {
  17. public $isCoursePlugin = true;
  18. //When creating a new course this settings are added to the course
  19. public $course_settings = array(
  20. array(
  21. 'name' => 'big_blue_button_record_and_store',
  22. 'type' => 'checkbox'
  23. )
  24. );
  25. public static function create()
  26. {
  27. static $result = null;
  28. return $result ? $result : $result = new self();
  29. }
  30. protected function __construct()
  31. {
  32. parent::__construct('2.2', 'Julio Montoya, Yannick Warnier', array('tool_enable' => 'boolean', 'host' =>'text', 'salt' => 'text'));
  33. }
  34. public function install()
  35. {
  36. $table = Database::get_main_table('plugin_bbb_meeting');
  37. $sql = "CREATE TABLE IF NOT EXISTS $table (
  38. id INT unsigned NOT NULL auto_increment PRIMARY KEY,
  39. c_id INT unsigned NOT NULL DEFAULT 0,
  40. meeting_name VARCHAR(255) NOT NULL DEFAULT '',
  41. attendee_pw VARCHAR(255) NOT NULL DEFAULT '',
  42. moderator_pw VARCHAR(255) NOT NULL DEFAULT '',
  43. record INT NOT NULL DEFAULT 0,
  44. status INT NOT NULL DEFAULT 0,
  45. created_at VARCHAR(255) NOT NULL,
  46. closed_at VARCHAR(255) NOT NULL,
  47. calendar_id INT DEFAULT 0,
  48. welcome_msg VARCHAR(255) NOT NULL DEFAULT '',
  49. session_id INT unsigned DEFAULT 0,
  50. remote_id CHAR(30),
  51. visibility TINYINT NOT NULL DEFAULT 1,
  52. voice_bridge INT NOT NULL DEFAULT 1
  53. )";
  54. Database::query($sql);
  55. //Installing course settings
  56. $this->install_course_fields_in_all_courses();
  57. }
  58. public function uninstall()
  59. {
  60. $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  61. $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
  62. $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
  63. //New settings
  64. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_tool_enable'";
  65. Database::query($sql);
  66. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_salt'";
  67. Database::query($sql);
  68. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_host'";
  69. Database::query($sql);
  70. //Old settings deleting just in case
  71. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin'";
  72. Database::query($sql);
  73. $sql = "DELETE FROM $t_options WHERE variable = 'bbb_plugin'";
  74. Database::query($sql);
  75. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_host'";
  76. Database::query($sql);
  77. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_salt'";
  78. Database::query($sql);
  79. //hack to get rid of Database::query warning (please add c_id...)
  80. $sql = "DELETE FROM $t_tool WHERE name = 'bbb' AND c_id != 0";
  81. Database::query($sql);
  82. $t = Database::get_main_table('plugin_bbb_meeting');
  83. $sql = "DROP TABLE IF EXISTS $t";
  84. Database::query($sql);
  85. //Deleting course settings
  86. $this->uninstall_course_fields_in_all_courses($this->course_settings);
  87. }
  88. }