bbb_plugin.class.php 3.2 KB

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