openmeetings_plugin.class.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Class OpenMeetingsPlugin
  4. */
  5. class OpenMeetingsPlugin extends Plugin
  6. {
  7. public $is_course_plugin = true;
  8. //When creating a new course this settings are added to the course
  9. public $course_settings = array(array(
  10. 'name' => 'openmeetings_record_and_store',
  11. 'type' => 'checkbox'
  12. ));
  13. public static function create()
  14. {
  15. static $result = null;
  16. return $result ? $result : $result = new self();
  17. }
  18. protected function __construct()
  19. {
  20. parent::__construct('2.0', 'Francis Gonzales', array('tool_enable' => 'boolean', 'host' =>'text', 'user' => 'text', 'pass' => 'text'));
  21. }
  22. public function install()
  23. {
  24. $table = Database::get_main_table('plugin_openmeetings');
  25. // id is the internal unique ID (keeps track of historical sessions
  26. // status is 0 for closed, 1 for open (available)
  27. // room_id is a reference to the meeting ID on the OpenMeetings server.
  28. // 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
  29. $sql = "CREATE TABLE IF NOT EXISTS $table (
  30. id INT unsigned NOT NULL auto_increment PRIMARY KEY,
  31. c_id INT unsigned NOT NULL DEFAULT 0,
  32. session_id INT unsigned NOT NULL DEFAULT 0,
  33. room_id INT unsigned NOT NULL DEFAULT 0,
  34. meeting_name VARCHAR(255) NOT NULL DEFAULT '',
  35. attendee_pw VARCHAR(255) NOT NULL DEFAULT '',
  36. moderator_pw VARCHAR(255) NOT NULL DEFAULT '',
  37. record INT NOT NULL DEFAULT 0,
  38. status INT NOT NULL DEFAULT 0,
  39. created_at DATETIME NOT NULL,
  40. closed_at DATETIME,
  41. calendar_id INT DEFAULT 0,
  42. welcome_msg TEXT NOT NULL DEFAULT '')";
  43. Database::query($sql);
  44. //Installing course settings
  45. $this->install_course_fields_in_all_courses();
  46. }
  47. public function uninstall()
  48. {
  49. $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  50. $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
  51. $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
  52. //New settings
  53. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_tool_enable'";
  54. Database::query($sql);
  55. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_pass'";
  56. Database::query($sql);
  57. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_user'";
  58. Database::query($sql);
  59. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_host'";
  60. Database::query($sql);
  61. //Old settings deleting just in case
  62. $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin'";
  63. Database::query($sql);
  64. $sql = "DELETE FROM $t_options WHERE variable = 'openmeetings_plugin'";
  65. Database::query($sql);
  66. // $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin_host'";
  67. // Database::query($sql);
  68. // $sql = "DELETE FROM $t_settings WHERE variable = 'openmeetings_plugin_salt'";
  69. // Database::query($sql);
  70. //hack to get rid of Database::query warning (please add c_id...)
  71. $sql = "DELETE FROM $t_tool WHERE name = 'openmeetings' AND c_id = c_id";
  72. Database::query($sql);
  73. $sql = "DROP TABLE IF EXISTS plugin_openmeetings";
  74. Database::query($sql);
  75. //Deleting course settings
  76. $this->uninstall_course_fields_in_all_courses();
  77. }
  78. }