enable.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. SET @sName = 'bx_reputation';
  2. -- SETTINGS
  3. SET @iTypeOrder = (SELECT MAX(`order`) FROM `sys_options_types` WHERE `group` = 'modules');
  4. INSERT INTO `sys_options_types`(`group`, `name`, `caption`, `icon`, `order`) VALUES
  5. ('modules', @sName, '_bx_reputation', 'bx_reputation@modules/boonex/reputation/|std-icon.svg', IF(ISNULL(@iTypeOrder), 1, @iTypeOrder + 1));
  6. SET @iTypeId = LAST_INSERT_ID();
  7. INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order`)
  8. VALUES (@iTypeId, @sName, '_bx_reputation', 10);
  9. SET @iCategId = LAST_INSERT_ID();
  10. INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
  11. ('bx_reputation_enable_multilevel', '', @iCategId, '_bx_reputation_option_enable_multilevel', 'checkbox', '', '', '', 1),
  12. ('bx_reputation_leaderboard_limit', '10', @iCategId, '_bx_reputation_option_leaderboard_limit', 'digit', '', '', '', 11),
  13. ('bx_reputation_history_limit', '20', @iCategId, '_bx_reputation_option_history_limit', 'digit', '', '', '', 13),
  14. ('bx_reputation_actions_limit', '20', @iCategId, '_bx_reputation_option_actions_limit', 'digit', '', '', '', 15);
  15. -- PAGE: leaderboard
  16. INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES
  17. ('bx_reputation_leaderboard', '_bx_reputation_page_title_sys_leaderboard', '_bx_reputation_page_title_leaderboard', @sName, 8, 2147483647, 1, 'leaderboard', 'page.php?i=leaderboard', '', '', '', 0, 1, 0, '', '');
  18. INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES
  19. ('bx_reputation_leaderboard', 2, @sName, '_bx_reputation_page_block_title_leaderboard_week', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:21:"get_block_leaderboard";s:6:"params";a:1:{i:0;i:7;}}', 0, 1, 1),
  20. ('bx_reputation_leaderboard', 3, @sName, '_bx_reputation_page_block_title_leaderboard_month', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:21:"get_block_leaderboard";s:6:"params";a:1:{i:0;i:30;}}', 0, 1, 1),
  21. ('bx_reputation_leaderboard', 4, @sName, '_bx_reputation_page_block_title_leaderboard_all_time', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:21:"get_block_leaderboard";}', 0, 1, 1);
  22. -- PAGE: history
  23. INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES
  24. ('bx_reputation_history', '_bx_reputation_page_title_sys_history', '_bx_reputation_page_title_history', @sName, 13, 2147483647, 1, 'points-history', 'page.php?i=points-history', '', '', '', 0, 1, 0, '', '');
  25. INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES
  26. ('bx_reputation_history', 2, @sName, '_bx_reputation_page_block_title_summary', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:17:"get_block_summary";}', 0, 1, 1),
  27. ('bx_reputation_history', 3, @sName, '_bx_reputation_page_block_title_history', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:17:"get_block_history";}', 0, 1, 1);
  28. -- PAGES: add page block on home
  29. SET @iPBCellHome = 2;
  30. SET @iPBOrderHome = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_pages_blocks` WHERE `object` = 'sys_home' AND `cell_id` = @iPBCellHome ORDER BY `order` DESC LIMIT 1);
  31. INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `tabs`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES
  32. ('sys_home', @iPBCellHome, @sName, '_bx_reputation_page_block_title_system_summary', '_bx_reputation_page_block_title_summary', 13, 0, 2147483644, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:17:"get_block_summary";}', 0, 0, 1, @iPBOrderHome + 1);
  33. -- PAGES: add page block to profiles modules (trigger* page objects are processed separately upon modules enable/disable)
  34. SET @iPBCellProfile = 3;
  35. INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES
  36. ('trigger_page_profile_view_entry', @iPBCellProfile, @sName, '_bx_reputation_page_block_title_system_summary', '_bx_reputation_page_block_title_summary', 13, 2147483647, 'service', 'a:3:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:17:"get_block_summary";s:6:"params";a:1:{i:0;s:12:"{profile_id}";}}', 0, 0, 1, 0);
  37. -- PAGE: service blocks
  38. SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = '' AND `cell_id` = 0 ORDER BY `order` DESC LIMIT 1);
  39. INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES
  40. ('', 0, @sName, '', '_bx_reputation_page_block_title_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:17:"get_block_actions";}', 0, 1, IFNULL(@iBlockOrder, 0) + 1),
  41. ('', 0, @sName, '', '_bx_reputation_page_block_title_levels', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:16:"get_block_levels";}', 0, 1, IFNULL(@iBlockOrder, 0) + 2);
  42. -- MENU: add to site menu
  43. SET @iSiteMenuOrder = (SELECT `order` FROM `sys_menu_items` WHERE `set_name` = 'sys_site' AND `active` = 1 AND `order` < 9999 ORDER BY `order` DESC LIMIT 1);
  44. INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES
  45. ('sys_site', @sName, 'leaderboard', '_bx_reputation_menu_item_title_system_leaderboard', '_bx_reputation_menu_item_title_leaderboard', 'page.php?i=leaderboard', '', '', 'star col-red3', '', 2147483647, 1, 1, IFNULL(@iSiteMenuOrder, 0) + 1);
  46. -- GRIDS: administration tools
  47. INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
  48. ('bx_reputation_handlers', 'Sql', 'SELECT * FROM `bx_reputation_handlers` WHERE 1 ', 'bx_reputation_handlers', 'id', '', 'active', '', 20, NULL, 'start', '', 'type,alert_unit,alert_action', '', 'like', 'reports', '', 192, 'BxReputationGridHandlers', 'modules/boonex/reputation/classes/BxReputationGridHandlers.php');
  49. INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
  50. ('bx_reputation_handlers', 'checkbox', '_sys_select', '2%', 0, '', '', 1),
  51. ('bx_reputation_handlers', 'switcher', '_bx_reputation_grid_column_title_hdr_active', '8%', 0, 0, '', 2),
  52. ('bx_reputation_handlers', 'alert_unit', '_bx_reputation_grid_column_title_hdr_alert_unit', '25%', 0, 0, '', 3),
  53. ('bx_reputation_handlers', 'alert_action', '_bx_reputation_grid_column_title_hdr_alert_action', '21%', 0, 0, '', 4),
  54. ('bx_reputation_handlers', 'points_active', '_bx_reputation_grid_column_title_hdr_points_active', '12%', 0, 0, '', 5),
  55. ('bx_reputation_handlers', 'points_passive', '_bx_reputation_grid_column_title_hdr_points_passive', '12%', 0, 0, '', 6),
  56. ('bx_reputation_handlers', 'actions', '', '20%', 0, 0, '', 7);
  57. INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon_only`, `confirm`, `order`) VALUES
  58. ('bx_reputation_handlers', 'bulk', 'activate', '_bx_reputation_grid_action_title_hdr_activate', '', 0, 0, 1),
  59. ('bx_reputation_handlers', 'bulk', 'deactivate', '_bx_reputation_grid_action_title_hdr_deactivate', '', 0, 0, 2),
  60. ('bx_reputation_handlers', 'single', 'edit', '_bx_reputation_grid_action_title_hdr_edit', 'pencil-alt', 1, 0, 1);
  61. -- GRIDS: levels
  62. INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `override_class_name`, `override_class_file`) VALUES
  63. ('bx_reputation_levels', 'Sql', 'SELECT * FROM `bx_reputation_levels` WHERE 1 ', 'bx_reputation_levels', 'id', 'order', 'active', '', 20, NULL, 'start', '', 'name', 'title', 'like', '', '', 'BxReputationGridLevels', 'modules/boonex/reputation/classes/BxReputationGridLevels.php');
  64. INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
  65. ('bx_reputation_levels', 'order', '', '1%', 0, 0, '', 1),
  66. ('bx_reputation_levels', 'switcher', '', '9%', 0, 0, '', 2),
  67. ('bx_reputation_levels', 'icon', '_bx_reputation_grid_column_title_lvl_icon', '5%', 0, 0, '', 3),
  68. ('bx_reputation_levels', 'title', '_bx_reputation_grid_column_title_lvl_title', '35%', 1, 16, '', 4),
  69. ('bx_reputation_levels', 'points_in', '_bx_reputation_grid_column_title_lvl_points_in', '10%', 0, 0, '', 5),
  70. ('bx_reputation_levels', 'points_out', '_bx_reputation_grid_column_title_lvl_points_out', '10%', 0, 0, '', 6),
  71. ('bx_reputation_levels', 'date', '_bx_reputation_grid_column_title_lvl_date', '10%', 0, 0, '', 7),
  72. ('bx_reputation_levels', 'actions', '', '20%', 0, 0, '', 8);
  73. INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon_only`, `confirm`, `order`) VALUES
  74. ('bx_reputation_levels', 'independent', 'add', '_bx_reputation_grid_action_title_lvl_add', '', 0, 0, 1),
  75. ('bx_reputation_levels', 'single', 'edit', '_bx_reputation_grid_action_title_lvl_edit', 'pencil-alt', 1, 0, 1),
  76. ('bx_reputation_levels', 'single', 'delete', '_bx_reputation_grid_action_title_lvl_delete', 'remove', 1, 1, 2);
  77. -- ALERTS
  78. INSERT INTO `sys_alerts_handlers` (`name`, `class`, `file`, `service_call`) VALUES
  79. (@sName, 'BxReputationAlertsResponse', 'modules/boonex/reputation/classes/BxReputationAlertsResponse.php', '');
  80. SET @iHandler := LAST_INSERT_ID();
  81. INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
  82. ('profile', 'delete', @iHandler),
  83. ('sys_profiles_friends', 'connection_added', @iHandler),
  84. ('sys_profiles_friends', 'connection_removed', @iHandler),
  85. ('sys_profiles_subscriptions', 'connection_added', @iHandler),
  86. ('sys_profiles_subscriptions', 'connection_removed', @iHandler);