openmeetings_plugin.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /* See license terms in /license.txt */
  3. /**
  4. * Class OpenMeetingsPlugin.
  5. */
  6. class OpenMeetingsPlugin extends Plugin
  7. {
  8. public $isCoursePlugin = true;
  9. //When creating a new course this settings are added to the course
  10. public $course_settings = [[
  11. 'name' => 'openmeetings_record_and_store',
  12. 'type' => 'checkbox',
  13. ]];
  14. protected function __construct()
  15. {
  16. parent::__construct('2.0', 'Francis Gonzales', ['tool_enable' => 'boolean', 'host' => 'text', 'user' => 'text', 'pass' => 'text']);
  17. }
  18. public static function create()
  19. {
  20. static $result = null;
  21. return $result ? $result : $result = new self();
  22. }
  23. public function install()
  24. {
  25. $table = Database::get_main_table('plugin_openmeetings');
  26. // id is the internal unique ID (keeps track of historical sessions
  27. // status is 0 for closed, 1 for open (available)
  28. // room_id is a reference to the meeting ID on the OpenMeetings server.
  29. // Any c_id + session_id occurence gets a unique new meeting ID to avoid issues with the number of rooms, as indicated in https://issues.apache.org/jira/browse/OPENMEETINGS-802#comment-13860340
  30. $sql = "CREATE TABLE IF NOT EXISTS $table (
  31. id INT unsigned NOT NULL auto_increment PRIMARY KEY,
  32. c_id INT unsigned NOT NULL DEFAULT 0,
  33. session_id INT unsigned NOT NULL DEFAULT 0,
  34. room_id INT unsigned NOT NULL DEFAULT 0,
  35. meeting_name VARCHAR(255) NOT NULL DEFAULT '',
  36. attendee_pw VARCHAR(255) NOT NULL DEFAULT '',
  37. moderator_pw VARCHAR(255) NOT NULL DEFAULT '',
  38. record INT NOT NULL DEFAULT 0,
  39. status INT NOT NULL DEFAULT 0,
  40. created_at DATETIME NOT NULL,
  41. closed_at DATETIME,
  42. calendar_id INT DEFAULT 0,
  43. welcome_msg TEXT NOT NULL DEFAULT '')";
  44. Database::query($sql);
  45. //Installing course settings
  46. $this->install_course_fields_in_all_courses();
  47. }
  48. public function uninstall()
  49. {
  50. $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  51. $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
  52. $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
  53. //New settings
  54. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_tool_enable'";
  55. Database::query($sql);
  56. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_pass'";
  57. Database::query($sql);
  58. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_user'";
  59. Database::query($sql);
  60. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_host'";
  61. Database::query($sql);
  62. //Old settings deleting just in case
  63. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin'";
  64. Database::query($sql);
  65. $sql = "DELETE FROM $t_options WHERE variable = 'openmeetings_plugin'";
  66. Database::query($sql);
  67. // $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin_host'";
  68. // Database::query($sql);
  69. // $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_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 = 'openmeetings' AND c_id = c_id";
  73. Database::query($sql);
  74. $t = Database::get_main_table('plugin_openmeetings');
  75. $sql = "DROP TABLE IF EXISTS $t";
  76. Database::query($sql);
  77. //Deleting course settings
  78. $this->uninstall_course_fields_in_all_courses($this->course_settings);
  79. }
  80. /**
  81. * @param int $course_id
  82. * @param bool $add_tool_link
  83. */
  84. public function course_install($course_id, $add_tool_link = true)
  85. {
  86. //force ignoring the tools table insertion for this plugin
  87. $this->install_course_fields($course_id, $add_tool_link);
  88. }
  89. }