install.sql 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. SET @sName = 'bx_notifications';
  2. -- TABLES
  3. CREATE TABLE IF NOT EXISTS `bx_notifications_events` (
  4. `id` int(11) NOT NULL auto_increment,
  5. `owner_id` int(11) NOT NULL default '0',
  6. `type` varchar(255) NOT NULL,
  7. `action` varchar(255) NOT NULL,
  8. `object_id` text NOT NULL,
  9. `object_owner_id` int(11) NOT NULL default '0',
  10. `object_privacy_view` varchar(32) NOT NULL default '3',
  11. `subobject_id` int(11) NOT NULL default '0',
  12. `content` text NOT NULL,
  13. `source` varchar(32) NOT NULL default '',
  14. `allow_view_event_to` varchar(32) NOT NULL default '3',
  15. `date` int(11) NOT NULL default '0',
  16. `processed` tinyint(4) NOT NULL default '0',
  17. `active` tinyint(4) NOT NULL default '1',
  18. PRIMARY KEY (`id`),
  19. KEY `owner_id` (`owner_id`),
  20. KEY `object_owner_id` (`object_owner_id`)
  21. );
  22. CREATE TABLE IF NOT EXISTS `bx_notifications_events2users` (
  23. `id` int(11) NOT NULL auto_increment,
  24. `user_id` int(11) NOT NULL DEFAULT '0',
  25. `event_id` int(11) NOT NULL DEFAULT '0',
  26. `clicked` tinyint(4) NOT NULL default '0',
  27. PRIMARY KEY (`id`),
  28. UNIQUE `event` (`user_id`, `event_id`)
  29. );
  30. CREATE TABLE IF NOT EXISTS `bx_notifications_read` (
  31. `user_id` int(11) NOT NULL DEFAULT '0',
  32. `event_id` int(11) NOT NULL DEFAULT '0',
  33. PRIMARY KEY (`user_id`)
  34. );
  35. CREATE TABLE IF NOT EXISTS `bx_notifications_handlers` (
  36. `id` int(11) NOT NULL auto_increment,
  37. `group` varchar(64) NOT NULL default '',
  38. `type` enum('insert','update','delete') NOT NULL DEFAULT 'insert',
  39. `alert_unit` varchar(64) NOT NULL default '',
  40. `alert_action` varchar(64) NOT NULL default '',
  41. `content` text NOT NULL,
  42. `privacy` varchar(64) NOT NULL default '',
  43. `priority` int(11) NOT NULL default '0',
  44. PRIMARY KEY (`id`),
  45. UNIQUE `handler` (`group`, `type`),
  46. UNIQUE `alert` (`alert_unit`, `alert_action`)
  47. );
  48. CREATE TABLE IF NOT EXISTS `bx_notifications_settings` (
  49. `id` int(11) NOT NULL auto_increment,
  50. `group` varchar(64) NOT NULL default '',
  51. `handler_id` int(11) NOT NULL DEFAULT '0',
  52. `delivery` enum('site','email','push') NOT NULL DEFAULT 'site',
  53. `type` enum('personal','follow_member','follow_context','other') NOT NULL DEFAULT 'personal',
  54. `title` varchar(64) NOT NULL default '',
  55. `value` tinyint(4) NOT NULL default '1',
  56. `active` tinyint(4) NOT NULL default '1',
  57. `order` int(11) NOT NULL default '0',
  58. PRIMARY KEY (`id`),
  59. UNIQUE `setting` (`handler_id`, `type`, `delivery`)
  60. );
  61. CREATE TABLE IF NOT EXISTS `bx_notifications_settings2users` (
  62. `id` int(11) NOT NULL auto_increment,
  63. `user_id` int(11) NOT NULL DEFAULT '0',
  64. `setting_id` int(11) NOT NULL DEFAULT '0',
  65. `active` tinyint(4) NOT NULL default '1',
  66. PRIMARY KEY (`id`),
  67. UNIQUE `setting` (`setting_id`, `user_id`)
  68. );
  69. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  70. ('profile', 'delete', 'profile', 'delete', '');
  71. -- Mentions
  72. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`, `priority`) VALUES
  73. ('mention', 'insert', 'meta_mention', 'added', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:30:"get_notifications_post_mention";s:12:"module_class";s:20:"TemplServiceMetatags";}', '', 1);
  74. SET @iHandlerId = LAST_INSERT_ID();
  75. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  76. ('mention', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_mention_added_personal', 1),
  77. ('mention', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_mention_added_personal', 1),
  78. ('mention', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_mention_added_personal', 1);
  79. -- Friendship
  80. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  81. ('friendship', 'insert', 'sys_profiles_friends', 'connection_added', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:33:"get_notifications_post_friendship";s:12:"module_class";s:23:"TemplServiceConnections";}');
  82. SET @iHandlerId = LAST_INSERT_ID();
  83. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  84. ('friendship', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_friendship_added_personal', 2),
  85. ('friendship', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_friendship_added_personal', 2),
  86. ('friendship', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_friendship_added_personal', 2);
  87. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  88. ('friendship', 'delete', 'sys_profiles_friends', 'connection_removed', '');
  89. -- Subscription
  90. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  91. ('subscription', 'insert', 'sys_profiles_subscriptions', 'connection_added', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:22:"get_notifications_post";s:12:"module_class";s:23:"TemplServiceConnections";}');
  92. SET @iHandlerId = LAST_INSERT_ID();
  93. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  94. ('subscription', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_subscription_added_personal', 3),
  95. ('subscription', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_subscription_added_personal', 3),
  96. ('subscription', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_subscription_added_personal', 3);
  97. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  98. ('subscription', 'delete', 'sys_profiles_subscriptions', 'connection_removed', '');
  99. -- Comments
  100. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  101. ('comment', 'insert', 'comment', 'added', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:31:"get_notifications_comment_added";s:12:"module_class";s:17:"TemplCmtsServices";}');
  102. SET @iHandlerId = LAST_INSERT_ID();
  103. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  104. ('comment', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_comment_added_personal', 1),
  105. ('comment', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_comment_added_personal', 1),
  106. ('comment', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_comment_added_personal', 1);
  107. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  108. ('comment', 'delete', 'comment', 'deleted', '');
  109. -- Comments Actions (Like, Reaction, Score Up\Down)
  110. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  111. ('sys_cmts_vote', 'insert', 'sys_cmts', 'doVote', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:22:"get_notifications_vote";s:12:"module_class";s:17:"TemplCmtsServices";}', '');
  112. SET @iHandlerId = LAST_INSERT_ID();
  113. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  114. ('vote', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_doVote_personal', 4),
  115. ('vote', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_doVote_personal', 4),
  116. ('vote', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_doVote_personal', 4),
  117. ('vote', @iHandlerId, 'site', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 1),
  118. ('vote', @iHandlerId, 'email', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 1),
  119. ('vote', @iHandlerId, 'push', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 1),
  120. ('vote', @iHandlerId, 'site', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 1),
  121. ('vote', @iHandlerId, 'email', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 1),
  122. ('vote', @iHandlerId, 'push', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 1);
  123. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  124. ('sys_cmts_vote', 'delete', 'sys_cmts', 'undoVote', '');
  125. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  126. ('sys_cmts_reaction', 'insert', 'sys_cmts_reactions', 'doVote', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:26:"get_notifications_reaction";s:12:"module_class";s:17:"TemplCmtsServices";}', '');
  127. SET @iHandlerId = LAST_INSERT_ID();
  128. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  129. ('vote', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_doVote_personal', 5),
  130. ('vote', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_doVote_personal', 5),
  131. ('vote', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_doVote_personal', 5),
  132. ('vote', @iHandlerId, 'site', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 2),
  133. ('vote', @iHandlerId, 'email', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 2),
  134. ('vote', @iHandlerId, 'push', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 2),
  135. ('vote', @iHandlerId, 'site', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 2),
  136. ('vote', @iHandlerId, 'email', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 2),
  137. ('vote', @iHandlerId, 'push', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 2);
  138. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  139. ('sys_cmts_reaction', 'delete', 'sys_cmts_reactions', 'undoVote', '');
  140. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  141. ('sys_cmts_score_up', 'insert', 'sys_cmts', 'doVoteUp', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:26:"get_notifications_score_up";s:12:"module_class";s:17:"TemplCmtsServices";}', '');
  142. SET @iHandlerId = LAST_INSERT_ID();
  143. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  144. ('score_up', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_doVoteUp_personal', 6),
  145. ('score_up', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_doVoteUp_personal', 6),
  146. ('score_up', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_doVoteUp_personal', 6),
  147. ('score_up', @iHandlerId, 'site', 'follow_member', '_bx_ntfs_alert_action_doVoteUp_follow_member', 3),
  148. ('score_up', @iHandlerId, 'email', 'follow_member', '_bx_ntfs_alert_action_doVoteUp_follow_member', 3),
  149. ('score_up', @iHandlerId, 'push', 'follow_member', '_bx_ntfs_alert_action_doVoteUp_follow_member', 3),
  150. ('score_up', @iHandlerId, 'site', 'follow_context', '_bx_ntfs_alert_action_doVoteUp_follow_context', 3),
  151. ('score_up', @iHandlerId, 'email', 'follow_context', '_bx_ntfs_alert_action_doVoteUp_follow_context', 3),
  152. ('score_up', @iHandlerId, 'push', 'follow_context', '_bx_ntfs_alert_action_doVoteUp_follow_context', 3);
  153. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  154. ('sys_cmts_score_down', 'insert', 'sys_cmts', 'doVoteDown', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:28:"get_notifications_score_down";s:12:"module_class";s:17:"TemplCmtsServices";}', '');
  155. SET @iHandlerId = LAST_INSERT_ID();
  156. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  157. ('score_down', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_doVoteDown_personal', 7),
  158. ('score_down', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_doVoteDown_personal', 7),
  159. ('score_down', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_doVoteDown_personal', 7),
  160. ('score_down', @iHandlerId, 'site', 'follow_member', '_bx_ntfs_alert_action_doVoteDown_follow_member', 4),
  161. ('score_down', @iHandlerId, 'email', 'follow_member', '_bx_ntfs_alert_action_doVoteDown_follow_member', 4),
  162. ('score_down', @iHandlerId, 'push', 'follow_member', '_bx_ntfs_alert_action_doVoteDown_follow_member', 4),
  163. ('score_down', @iHandlerId, 'site', 'follow_context', '_bx_ntfs_alert_action_doVoteDown_follow_context', 4),
  164. ('score_down', @iHandlerId, 'email', 'follow_context', '_bx_ntfs_alert_action_doVoteDown_follow_context', 4),
  165. ('score_down', @iHandlerId, 'push', 'follow_context', '_bx_ntfs_alert_action_doVoteDown_follow_context', 4);
  166. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  167. ('sys_cmts_object_reported', 'insert', 'sys_cmts', 'reported_content', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:34:"get_notifications_comment_reported";s:12:"module_class";s:17:"TemplCmtsServices";}', '');
  168. SET @iHandlerId = LAST_INSERT_ID();
  169. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  170. ('action_required', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_reported_content_personal', 8),
  171. ('action_required', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_reported_content_personal', 8),
  172. ('action_required', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_reported_content_personal', 8);
  173. CREATE TABLE IF NOT EXISTS `bx_notifications_queue` (
  174. `id` int(11) NOT NULL auto_increment,
  175. `profile_id` int(11) NOT NULL DEFAULT '0',
  176. `event_id` int(11) NOT NULL DEFAULT '0',
  177. `delivery` varchar(64) NOT NULL default '',
  178. `content` text NOT NULL,
  179. `date` int(11) NOT NULL default '0',
  180. PRIMARY KEY (`id`)
  181. );
  182. -- STUDIO PAGE & WIDGET
  183. INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
  184. (3, @sName, '_bx_ntfs', '_bx_ntfs', 'bx_notifications@modules/boonex/notifications/|std-icon.svg');
  185. SET @iPageId = LAST_INSERT_ID();
  186. SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
  187. SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
  188. INSERT INTO `sys_std_widgets` (`page_id`, `module`, `type`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
  189. (@iPageId, @sName, 'extensions', '{url_studio}module.php?name=bx_notifications', '', 'bx_notifications@modules/boonex/notifications/|std-icon.svg', '_bx_ntfs', '', '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";}');
  190. INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
  191. (@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));