Просмотр файла mc-2.7.0/modules/forum/helpers/forum_installer.php

Размер файла: 3.22Kb
  1. <?php
  2.  
  3. /**
  4. * MobileCMS
  5. *
  6. * Open source content management system for mobile sites
  7. *
  8. * @author MobileCMS Team <support@mobilecms.pro>
  9. * @copyright Copyright (c) 2011-2019, MobileCMS Team
  10. * @link https://mobilecms.pro Official site
  11. * @license MIT license
  12. */
  13. defined('IN_SYSTEM') or die('<b>403<br />Запрет доступа!</b>');
  14.  
  15. /**
  16. * Хелпер установки модуля
  17. */
  18. class forum_installer {
  19.  
  20. /**
  21. * Установка модуля
  22. */
  23. public static function install($db) {
  24. $db->query("CREATE TABLE IF NOT EXISTS #__forum_forums (
  25. `forum_id` int(11) NOT NULL auto_increment,
  26. `section_id` int(11) NOT NULL,
  27. `position` int(11) NOT NULL,
  28. `name` varchar(255) NOT NULL,
  29. `topics` int(11) NOT NULL,
  30. `messages` int(11) NOT NULL,
  31. PRIMARY KEY (`forum_id`),
  32. KEY `section_id` (`section_id`)
  33. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
  34. ");
  35.  
  36. $db->query("CREATE TABLE IF NOT EXISTS #__forum_messages (
  37. `message_id` int(11) NOT NULL auto_increment,
  38. `topic_id` int(11) NOT NULL,
  39. `section_id` int(11) NOT NULL,
  40. `forum_id` int(11) NOT NULL,
  41. `user_id` int(11) NOT NULL,
  42. `message` varchar(1000) NOT NULL,
  43. `is_first_message` tinyint(1) NOT NULL default '0',
  44. `time` int(11) NOT NULL,
  45. PRIMARY KEY (`message_id`),
  46. KEY `topic_id` (`topic_id`),
  47. KEY `forum_id` (`forum_id`),
  48. KEY `section_id` (`section_id`),
  49. FULLTEXT KEY `message` (`message`)
  50. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
  51. ");
  52.  
  53. $db->query("CREATE TABLE IF NOT EXISTS #__forum_sections (
  54. `section_id` int(11) NOT NULL auto_increment,
  55. `position` int(11) NOT NULL,
  56. `name` varchar(255) NOT NULL,
  57. PRIMARY KEY (`section_id`)
  58. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
  59. ");
  60.  
  61. $db->query("CREATE TABLE IF NOT EXISTS #__forum_topics (
  62. `topic_id` int(11) NOT NULL auto_increment,
  63. `section_id` int(11) NOT NULL,
  64. `forum_id` int(11) NOT NULL,
  65. `user_id` int(11) NOT NULL,
  66. `name` varchar(30) NOT NULL,
  67. `time` int(11) NOT NULL,
  68. `last_message_time` int(11) NOT NULL,
  69. `last_user_id` int(11) NOT NULL,
  70. `messages` int(11) NOT NULL,
  71. `is_top_topic` tinyint(1) default '0',
  72. `is_close_topic` tinyint(1) default '0',
  73. PRIMARY KEY (`topic_id`),
  74. KEY `forum_id` (`forum_id`),
  75. KEY `user_id` (`user_id`),
  76. KEY `section_id` (`section_id`),
  77. KEY `last_user_id` (`last_user_id`),
  78. FULLTEXT KEY `name` (`name`)
  79. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
  80. ");
  81.  
  82. $db->query("INSERT INTO #__config (`id` , `module` , `key` , `value` )
  83. VALUES
  84. (NULL , 'forum', 'show_forums_in_list_sections', '1'),
  85. (NULL , 'forum', 'messages_per_page', '7'),
  86. (NULL , 'forum', 'topics_per_page', '7'),
  87. (NULL , 'forum', 'guests_create_topics', '0'),
  88. (NULL , 'forum', 'guests_write_messages', '0');
  89. ");
  90. }
  91.  
  92. /**
  93. * Деинсталляция модуля
  94. */
  95. public static function uninstall($db) {
  96. $db->query("DROP TABLE #__forum_forums, #__forum_messages, #__forum_sections, #__forum_topics;");
  97. $db->query("DELETE FROM #__config WHERE module = 'forum'");
  98. }
  99.  
  100. }
  101.  
  102. ?>