ticket_plugin.class.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class TicketPlugin definition file
  5. * @package chamilo.plugin.ticket
  6. */
  7. /**
  8. * Class TicketPlugin
  9. */
  10. class TicketPlugin extends Plugin
  11. {
  12. static function create() {
  13. static $result = null;
  14. return $result ? $result : $result = new self();
  15. }
  16. protected function __construct() {
  17. parent::__construct('1.0', 'Kenny Rodas Chavez', array('tool_enable' => 'boolean'));
  18. }
  19. function install() {
  20. // Create database tables
  21. require_once api_get_path(SYS_PLUGIN_PATH).PLUGIN_NAME.'/database.php';
  22. // Create link tab
  23. $homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
  24. $menutabs = 'home_tabs'; //menutabs for tabs Menu
  25. $menuf = $menutabs;
  26. $ext = '.html'; //ext for HTML Extension - when used frequently, variables are faster than hardcoded strings
  27. $lang = ''; //el for "Edit Language"
  28. if (!empty($_SESSION['user_language_choice'])) {
  29. $lang = $_SESSION['user_language_choice'];
  30. } elseif (!empty($_SESSION['_user']['language'])) {
  31. $lang = $_SESSION['_user']['language'];
  32. } else {
  33. $lang = api_get_setting('platformLanguage');
  34. }
  35. $link_url = api_get_path(WEB_PLUGIN_PATH).'ticket/s/myticket.php';
  36. $home_menu = '<li class="show_menu"><a href="'.$link_url.'" target="_self"><span>Ticket</span></a></li>';
  37. // Write
  38. if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
  39. if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
  40. $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
  41. fputs($fp, $home_menu);
  42. fclose($fp);
  43. if (file_exists($homep.$menuf.$ext)) {
  44. if (is_writable($homep.$menuf.$ext)) {
  45. $fpo = fopen($homep.$menuf.$ext, 'w');
  46. fputs($fpo, $home_menu);
  47. fclose($fpo);
  48. }
  49. }
  50. } else {
  51. $errorMsg = get_lang('HomePageFilesNotWritable');
  52. }
  53. } else {
  54. //File does not exist
  55. $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
  56. fputs($fp, $home_menu);
  57. fclose($fp);
  58. }
  59. }
  60. function uninstall() {
  61. $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
  62. $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
  63. $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
  64. //Delete settings
  65. $sql = "DELETE FROM $t_settings WHERE variable = 'ticket_tool_enable'";
  66. Database::query($sql);
  67. $sql = "DROP TABLE IF EXISTS ticket_ticket";
  68. Database::query($sql);
  69. $sql = "DROP TABLE IF EXISTS ticket_status";
  70. Database::query($sql);
  71. $sql = "DROP TABLE IF EXISTS ticket_project";
  72. Database::query($sql);
  73. $sql = "DROP TABLE IF EXISTS ticket_priority";
  74. Database::query($sql);
  75. $sql = "DROP TABLE IF EXISTS ticket_message_attch";
  76. Database::query($sql);
  77. $sql = "DROP TABLE IF EXISTS ticket_message";
  78. Database::query($sql);
  79. $sql = "DROP TABLE IF EXISTS ticket_category";
  80. Database::query($sql);
  81. $sql = "DROP TABLE IF EXISTS ticket_assigned_log";
  82. Database::query($sql);
  83. $sql = "DROP TABLE IF EXISTS ticket_ticket";
  84. Database::query($sql);
  85. //Deleting course settings
  86. $this->uninstall_course_fields_in_all_courses();
  87. }
  88. }