bbb_plugin.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. )";
  53. Database::query($sql);
  54. //Installing course settings
  55. $this->install_course_fields_in_all_courses();
  56. }
  57. public function uninstall()
  58. {
  59. $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  60. $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
  61. $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
  62. //New settings
  63. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_tool_enable'";
  64. Database::query($sql);
  65. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_salt'";
  66. Database::query($sql);
  67. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_host'";
  68. Database::query($sql);
  69. //Old settings deleting just in case
  70. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin'";
  71. Database::query($sql);
  72. $sql = "DELETE FROM $t_options WHERE variable = 'bbb_plugin'";
  73. Database::query($sql);
  74. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_host'";
  75. Database::query($sql);
  76. $sql = "DELETE FROM $t_settings WHERE variable = 'bbb_plugin_salt'";
  77. Database::query($sql);
  78. //hack to get rid of Database::query warning (please add c_id...)
  79. $sql = "DELETE FROM $t_tool WHERE name = 'bbb'";//" AND c_id = c_id";
  80. Database::query($sql);
  81. $sql = "DROP TABLE IF EXISTS plugin_bbb_meeting";
  82. Database::query($sql);
  83. //Deleting course settings
  84. $this->uninstall_course_fields_in_all_courses($this->course_settings);
  85. }
  86. }