install.sql 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. SET @sName = 'bx_reputation';
  2. -- TABLE: handlers
  3. CREATE TABLE IF NOT EXISTS `bx_reputation_handlers` (
  4. `id` int(11) NOT NULL auto_increment,
  5. `group` varchar(64) NOT NULL default '',
  6. `type` enum('insert','update','delete') NOT NULL DEFAULT 'insert',
  7. `alert_unit` varchar(64) NOT NULL default '',
  8. `alert_action` varchar(64) NOT NULL default '',
  9. `points_active` int(11) NOT NULL default '0',
  10. `points_passive` int(11) NOT NULL default '0',
  11. `active` tinyint(4) NOT NULL default '1',
  12. PRIMARY KEY (`id`),
  13. UNIQUE `alert` (`alert_unit`, `alert_action`)
  14. );
  15. -- Friendship
  16. INSERT INTO `bx_reputation_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `points_active`, `points_passive`, `active`) VALUES
  17. ('friendship', 'insert', 'sys_profiles_friends', 'connection_added', '2', '0', '1'),
  18. ('friendship', 'delete', 'sys_profiles_friends', 'connection_removed', '-2', '0', '1');
  19. -- Subscription
  20. INSERT INTO `bx_reputation_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `points_active`, `points_passive`, `active`) VALUES
  21. ('subscription', 'insert', 'sys_profiles_subscriptions', 'connection_added', '1', '0', '1'),
  22. ('subscription', 'delete', 'sys_profiles_subscriptions', 'connection_removed', '-1', '0', '1');
  23. -- TABLES: events
  24. CREATE TABLE IF NOT EXISTS `bx_reputation_events` (
  25. `id` int(11) NOT NULL auto_increment,
  26. `owner_id` int(11) NOT NULL default '0',
  27. `context_id` int(11) NOT NULL default '0',
  28. `type` varchar(64) NOT NULL default '',
  29. `action` varchar(64) NOT NULL default '',
  30. `object_id` int(11) NOT NULL default '0',
  31. `object_owner_id` int(11) NOT NULL default '0',
  32. `points` int(11) NOT NULL DEFAULT '0',
  33. `date` int(11) NOT NULL default '0',
  34. PRIMARY KEY (`id`),
  35. KEY `owner_id` (`owner_id`),
  36. KEY `object_id` (`object_id`)
  37. );
  38. -- TABLE: levels
  39. CREATE TABLE IF NOT EXISTS `bx_reputation_levels` (
  40. `id` int(11) NOT NULL auto_increment,
  41. `name` varchar(32) NOT NULL default '',
  42. `title` varchar(64) NOT NULL default '',
  43. `icon` text NOT NULL,
  44. `points_in` int(11) NOT NULL DEFAULT '0',
  45. `points_out` int(11) NOT NULL DEFAULT '0',
  46. `date` int(11) NOT NULL default '0',
  47. `active` tinyint(4) NOT NULL DEFAULT '1',
  48. `order` int(11) NOT NULL DEFAULT '0',
  49. PRIMARY KEY (`id`),
  50. UNIQUE KEY `name` (`name`)
  51. );
  52. INSERT INTO `bx_reputation_levels` (`name`, `title`, `icon`, `points_in`, `points_out`, `date`, `active`, `order`) VALUES
  53. ('newcomer', '_bx_reputation_txt_level_newcomer', '', 1, 4, UNIX_TIMESTAMP(), 1, 1),
  54. ('explorer', '_bx_reputation_txt_level_explorer', '', 5, 19, UNIX_TIMESTAMP(), 1, 2),
  55. ('contributor', '_bx_reputation_txt_level_contributor', '', 20, 49, UNIX_TIMESTAMP(), 1, 3),
  56. ('collaborator', '_bx_reputation_txt_level_collaborator', '', 50, 99, UNIX_TIMESTAMP(), 1, 4),
  57. ('enthusiast', '_bx_reputation_txt_level_enthusiast', '', 100, 499, UNIX_TIMESTAMP(), 1, 5),
  58. ('advocate', '_bx_reputation_txt_level_advocate', '', 500, 1999, UNIX_TIMESTAMP(), 1, 6),
  59. ('visionary', '_bx_reputation_txt_level_visionary', '', 2000, 9999, UNIX_TIMESTAMP(), 1, 7),
  60. ('luminary', '_bx_reputation_txt_level_luminary', '', 10000, 49999, UNIX_TIMESTAMP(), 1, 8),
  61. ('origin', '_bx_reputation_txt_level_origin', '', 50000, 0, UNIX_TIMESTAMP(), 1, 9);
  62. -- TABLE: profiles
  63. CREATE TABLE IF NOT EXISTS `bx_reputation_profiles` (
  64. `id` int(11) NOT NULL auto_increment,
  65. `profile_id` int(11) NOT NULL DEFAULT '0',
  66. `context_id` int(11) NOT NULL default '0',
  67. `points` int(11) NOT NULL DEFAULT '0',
  68. `visible` tinyint(4) NOT NULL default '1',
  69. PRIMARY KEY (`id`),
  70. UNIQUE KEY `profile` (`profile_id`, `context_id`)
  71. );
  72. -- TABLE: profiles' levels
  73. CREATE TABLE IF NOT EXISTS `bx_reputation_profiles_levels` (
  74. `id` int(11) NOT NULL auto_increment,
  75. `profile_id` int(11) NOT NULL DEFAULT '0',
  76. `context_id` int(11) NOT NULL default '0',
  77. `level_id` int(11) NOT NULL DEFAULT '0',
  78. `date` int(11) NOT NULL default '0',
  79. PRIMARY KEY (`id`),
  80. UNIQUE KEY `level` (`profile_id`, `context_id`, `level_id`)
  81. );
  82. -- FORMS: handler
  83. INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_attrs`, `submit_name`, `table`, `key`, `uri`, `uri_title`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES
  84. ('bx_reputation_handler', @sName, '_bx_reputation_form_handler', '', '', 'do_submit', 'bx_reputation_handlers', 'id', '', '', '', 0, 1, '', '');
  85. INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `view_mode`) VALUES
  86. ('bx_reputation_handler_edit', @sName, 'bx_reputation_handler', '_bx_reputation_form_handler_display_edit', 0);
  87. INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES
  88. ('bx_reputation_handler', @sName, 'points_active', '', '', 0, 'text', '_bx_reputation_form_handler_input_sys_points_active', '_bx_reputation_form_handler_input_points_active', '_bx_reputation_form_handler_input_points_active_info', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
  89. ('bx_reputation_handler', @sName, 'points_passive', '', '', 0, 'text', '_bx_reputation_form_handler_input_sys_points_passive', '_bx_reputation_form_handler_input_points_passive', '_bx_reputation_form_handler_input_points_passive_info', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
  90. ('bx_reputation_handler', @sName, 'controls', '', 'do_submit,do_cancel', 0, 'input_set', '_bx_reputation_form_handler_input_sys_controls', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
  91. ('bx_reputation_handler', @sName, 'do_submit', '_bx_reputation_form_handler_input_do_submit', '', 0, 'submit', '_bx_reputation_form_handler_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
  92. ('bx_reputation_handler', @sName, 'do_cancel', '_bx_reputation_form_handler_input_do_cancel', '', 0, 'button', '_bx_reputation_form_handler_input_sys_do_cancel', '', '', 0, 0, 0, 'a:2:{s:7:"onclick";s:45:"$(''.bx-popup-applied:visible'').dolPopupHide()";s:5:"class";s:22:"bx-def-margin-sec-left";}', '', '', '', '', '', '', '', 1, 0);
  93. INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES
  94. ('bx_reputation_handler_edit', 'points_active', 2147483647, 1, 1),
  95. ('bx_reputation_handler_edit', 'points_passive', 2147483647, 1, 2),
  96. ('bx_reputation_handler_edit', 'controls', 2147483647, 1, 3),
  97. ('bx_reputation_handler_edit', 'do_submit', 2147483647, 1, 4),
  98. ('bx_reputation_handler_edit', 'do_cancel', 2147483647, 1, 5);
  99. -- FORMS: level
  100. INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_attrs`, `submit_name`, `table`, `key`, `uri`, `uri_title`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES
  101. ('bx_reputation_level', @sName, '_bx_reputation_form_level', '', '', 'do_submit', 'bx_reputation_levels', 'id', '', '', '', 0, 1, 'BxReputationFormLevel', 'modules/boonex/reputation/classes/BxReputationFormLevel.php');
  102. INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `view_mode`) VALUES
  103. ('bx_reputation_level_add', @sName, 'bx_reputation_level', '_bx_reputation_form_level_display_add', 0),
  104. ('bx_reputation_level_edit', @sName, 'bx_reputation_level', '_bx_reputation_form_level_display_edit', 0);
  105. INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES
  106. ('bx_reputation_level', @sName, 'name', '', '', 0, 'text', '_bx_reputation_form_level_input_sys_name', '_bx_reputation_form_level_input_name', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_reputation_form_input_err', 'Xss', '', 1, 0),
  107. ('bx_reputation_level', @sName, 'title', '', '', 0, 'text_translatable', '_bx_reputation_form_level_input_sys_title', '_bx_reputation_form_level_input_title', '', 1, 0, 0, '', '', '', 'AvailTranslatable', 'a:1:{i:0;s:5:"title";}', '_bx_reputation_form_input_err', 'Xss', '', 1, 0),
  108. ('bx_reputation_level', @sName, 'icon', '', '', 0, 'textarea', '_bx_reputation_form_level_input_sys_icon', '_bx_reputation_form_level_input_icon', '_bx_reputation_form_level_input_icon_info', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0),
  109. ('bx_reputation_level', @sName, 'points_in', '', '', 0, 'text', '_bx_reputation_form_level_input_sys_points_in', '_bx_reputation_form_level_input_points_in', '_bx_reputation_form_level_input_points_in_info', 1, 0, 0, '', '', '', 'Avail', '', '_bx_reputation_form_input_err', 'Int', '', 1, 0),
  110. ('bx_reputation_level', @sName, 'points_out', '', '', 0, 'text', '_bx_reputation_form_level_input_sys_points_out', '_bx_reputation_form_level_input_points_out', '_bx_reputation_form_level_input_points_out_info', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
  111. ('bx_reputation_level', @sName, 'controls', '', 'do_submit,do_cancel', 0, 'input_set', '_bx_reputation_form_level_input_sys_controls', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
  112. ('bx_reputation_level', @sName, 'do_submit', '_bx_reputation_form_level_input_do_submit', '', 0, 'submit', '_bx_reputation_form_level_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
  113. ('bx_reputation_level', @sName, 'do_cancel', '_bx_reputation_form_level_input_do_cancel', '', 0, 'button', '_bx_reputation_form_level_input_sys_do_cancel', '', '', 0, 0, 0, 'a:2:{s:7:"onclick";s:45:"$(''.bx-popup-applied:visible'').dolPopupHide()";s:5:"class";s:22:"bx-def-margin-sec-left";}', '', '', '', '', '', '', '', 1, 0);
  114. INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES
  115. ('bx_reputation_level_add', 'name', 2147483647, 1, 1),
  116. ('bx_reputation_level_add', 'title', 2147483647, 1, 2),
  117. ('bx_reputation_level_add', 'icon', 2147483647, 1, 3),
  118. ('bx_reputation_level_add', 'points_in', 2147483647, 1, 4),
  119. ('bx_reputation_level_add', 'points_out', 2147483647, 1, 5),
  120. ('bx_reputation_level_add', 'controls', 2147483647, 1, 6),
  121. ('bx_reputation_level_add', 'do_submit', 2147483647, 1, 7),
  122. ('bx_reputation_level_add', 'do_cancel', 2147483647, 1, 8),
  123. ('bx_reputation_level_edit', 'title', 2147483647, 1, 1),
  124. ('bx_reputation_level_edit', 'icon', 2147483647, 1, 2),
  125. ('bx_reputation_level_edit', 'points_in', 2147483647, 1, 3),
  126. ('bx_reputation_level_edit', 'points_out', 2147483647, 1, 4),
  127. ('bx_reputation_level_edit', 'controls', 2147483647, 1, 5),
  128. ('bx_reputation_level_edit', 'do_submit', 2147483647, 1, 6),
  129. ('bx_reputation_level_edit', 'do_cancel', 2147483647, 1, 7);
  130. -- STUDIO PAGE & WIDGET
  131. INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
  132. (3, @sName, '_bx_reputation', '_bx_reputation', 'bx_reputation@modules/boonex/reputation/|std-icon.svg');
  133. SET @iPageId = LAST_INSERT_ID();
  134. SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
  135. SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
  136. INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
  137. (@iPageId, @sName, '{url_studio}module.php?name=bx_reputation', '', 'bx_reputation@modules/boonex/reputation/|std-icon.svg', '_bx_reputation', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
  138. INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
  139. (@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));