install.sql 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. `user_id` int(11) NOT NULL DEFAULT '0',
  24. `event_id` int(11) NOT NULL DEFAULT '0',
  25. PRIMARY KEY (`user_id`)
  26. );
  27. CREATE TABLE IF NOT EXISTS `bx_notifications_handlers` (
  28. `id` int(11) NOT NULL auto_increment,
  29. `group` varchar(64) NOT NULL default '',
  30. `type` enum('insert','update','delete') NOT NULL DEFAULT 'insert',
  31. `alert_unit` varchar(64) NOT NULL default '',
  32. `alert_action` varchar(64) NOT NULL default '',
  33. `content` text NOT NULL,
  34. `privacy` varchar(64) NOT NULL default '',
  35. `priority` int(11) NOT NULL default '0',
  36. PRIMARY KEY (`id`),
  37. UNIQUE `handler` (`group`, `type`),
  38. UNIQUE `alert` (`alert_unit`, `alert_action`)
  39. );
  40. CREATE TABLE IF NOT EXISTS `bx_notifications_settings` (
  41. `id` int(11) NOT NULL auto_increment,
  42. `group` varchar(64) NOT NULL default '',
  43. `handler_id` int(11) NOT NULL DEFAULT '0',
  44. `delivery` enum('site','email','push') NOT NULL DEFAULT 'site',
  45. `type` enum('personal','follow_member','follow_context','other') NOT NULL DEFAULT 'personal',
  46. `title` varchar(64) NOT NULL default '',
  47. `value` tinyint(4) NOT NULL default '1',
  48. `active` tinyint(4) NOT NULL default '1',
  49. `order` int(11) NOT NULL default '0',
  50. PRIMARY KEY (`id`),
  51. UNIQUE `setting` (`handler_id`, `type`, `delivery`)
  52. );
  53. CREATE TABLE IF NOT EXISTS `bx_notifications_settings2users` (
  54. `id` int(11) NOT NULL auto_increment,
  55. `user_id` int(11) NOT NULL DEFAULT '0',
  56. `setting_id` int(11) NOT NULL DEFAULT '0',
  57. `active` tinyint(4) NOT NULL default '1',
  58. PRIMARY KEY (`id`),
  59. UNIQUE `setting` (`setting_id`, `user_id`)
  60. );
  61. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  62. ('profile', 'delete', 'profile', 'delete', '');
  63. -- Mentions
  64. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`, `priority`) VALUES
  65. ('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);
  66. SET @iHandlerId = LAST_INSERT_ID();
  67. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  68. ('mention', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_mention_added_personal', 1),
  69. ('mention', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_mention_added_personal', 1),
  70. ('mention', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_mention_added_personal', 1);
  71. -- Friendship
  72. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  73. ('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";}');
  74. SET @iHandlerId = LAST_INSERT_ID();
  75. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  76. ('friendship', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_friendship_added_personal', 2),
  77. ('friendship', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_friendship_added_personal', 2),
  78. ('friendship', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_friendship_added_personal', 2);
  79. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  80. ('friendship', 'delete', 'sys_profiles_friends', 'connection_removed', '');
  81. -- Subscription
  82. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  83. ('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";}');
  84. SET @iHandlerId = LAST_INSERT_ID();
  85. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  86. ('subscription', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_subscription_added_personal', 3),
  87. ('subscription', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_subscription_added_personal', 3),
  88. ('subscription', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_subscription_added_personal', 3);
  89. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  90. ('subscription', 'delete', 'sys_profiles_subscriptions', 'connection_removed', '');
  91. -- Comments
  92. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  93. ('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";}');
  94. SET @iHandlerId = LAST_INSERT_ID();
  95. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  96. ('comment', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_comment_added_personal', 1),
  97. ('comment', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_comment_added_personal', 1),
  98. ('comment', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_comment_added_personal', 1);
  99. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  100. ('comment', 'delete', 'comment', 'deleted', '');
  101. -- Comments Actions (Like, Reaction, Score Up\Down)
  102. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  103. ('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";}', '');
  104. SET @iHandlerId = LAST_INSERT_ID();
  105. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  106. ('vote', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_doVote_personal', 4),
  107. ('vote', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_doVote_personal', 4),
  108. ('vote', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_doVote_personal', 4),
  109. ('vote', @iHandlerId, 'site', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 1),
  110. ('vote', @iHandlerId, 'email', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 1),
  111. ('vote', @iHandlerId, 'push', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 1),
  112. ('vote', @iHandlerId, 'site', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 1),
  113. ('vote', @iHandlerId, 'email', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 1),
  114. ('vote', @iHandlerId, 'push', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 1);
  115. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  116. ('sys_cmts_vote', 'delete', 'sys_cmts', 'undoVote', '');
  117. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  118. ('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";}', '');
  119. SET @iHandlerId = LAST_INSERT_ID();
  120. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  121. ('vote', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_doVote_personal', 5),
  122. ('vote', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_doVote_personal', 5),
  123. ('vote', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_doVote_personal', 5),
  124. ('vote', @iHandlerId, 'site', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 2),
  125. ('vote', @iHandlerId, 'email', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 2),
  126. ('vote', @iHandlerId, 'push', 'follow_member', '_bx_ntfs_alert_action_doVote_follow_member', 2),
  127. ('vote', @iHandlerId, 'site', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 2),
  128. ('vote', @iHandlerId, 'email', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 2),
  129. ('vote', @iHandlerId, 'push', 'follow_context', '_bx_ntfs_alert_action_doVote_follow_context', 2);
  130. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
  131. ('sys_cmts_reaction', 'delete', 'sys_cmts_reactions', 'undoVote', '');
  132. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  133. ('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";}', '');
  134. SET @iHandlerId = LAST_INSERT_ID();
  135. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  136. ('score_up', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_doVoteUp_personal', 6),
  137. ('score_up', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_doVoteUp_personal', 6),
  138. ('score_up', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_doVoteUp_personal', 6),
  139. ('score_up', @iHandlerId, 'site', 'follow_member', '_bx_ntfs_alert_action_doVoteUp_follow_member', 3),
  140. ('score_up', @iHandlerId, 'email', 'follow_member', '_bx_ntfs_alert_action_doVoteUp_follow_member', 3),
  141. ('score_up', @iHandlerId, 'push', 'follow_member', '_bx_ntfs_alert_action_doVoteUp_follow_member', 3),
  142. ('score_up', @iHandlerId, 'site', 'follow_context', '_bx_ntfs_alert_action_doVoteUp_follow_context', 3),
  143. ('score_up', @iHandlerId, 'email', 'follow_context', '_bx_ntfs_alert_action_doVoteUp_follow_context', 3),
  144. ('score_up', @iHandlerId, 'push', 'follow_context', '_bx_ntfs_alert_action_doVoteUp_follow_context', 3);
  145. INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`) VALUES
  146. ('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";}', '');
  147. SET @iHandlerId = LAST_INSERT_ID();
  148. INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES
  149. ('score_down', @iHandlerId, 'site', 'personal', '_bx_ntfs_alert_action_doVoteDown_personal', 7),
  150. ('score_down', @iHandlerId, 'email', 'personal', '_bx_ntfs_alert_action_doVoteDown_personal', 7),
  151. ('score_down', @iHandlerId, 'push', 'personal', '_bx_ntfs_alert_action_doVoteDown_personal', 7),
  152. ('score_down', @iHandlerId, 'site', 'follow_member', '_bx_ntfs_alert_action_doVoteDown_follow_member', 4),
  153. ('score_down', @iHandlerId, 'email', 'follow_member', '_bx_ntfs_alert_action_doVoteDown_follow_member', 4),
  154. ('score_down', @iHandlerId, 'push', 'follow_member', '_bx_ntfs_alert_action_doVoteDown_follow_member', 4),
  155. ('score_down', @iHandlerId, 'site', 'follow_context', '_bx_ntfs_alert_action_doVoteDown_follow_context', 4),
  156. ('score_down', @iHandlerId, 'email', 'follow_context', '_bx_ntfs_alert_action_doVoteDown_follow_context', 4),
  157. ('score_down', @iHandlerId, 'push', 'follow_context', '_bx_ntfs_alert_action_doVoteDown_follow_context', 4);
  158. CREATE TABLE IF NOT EXISTS `bx_notifications_queue` (
  159. `id` int(11) NOT NULL auto_increment,
  160. `profile_id` int(11) NOT NULL DEFAULT '0',
  161. `event_id` int(11) NOT NULL DEFAULT '0',
  162. `delivery` varchar(64) NOT NULL default '',
  163. `content` text NOT NULL,
  164. `date` int(11) NOT NULL default '0',
  165. PRIMARY KEY (`id`)
  166. );
  167. -- STUDIO PAGE & WIDGET
  168. INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
  169. (3, @sName, '_bx_ntfs', '_bx_ntfs', 'bx_notifications@modules/boonex/notifications/|std-icon.svg');
  170. SET @iPageId = LAST_INSERT_ID();
  171. SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
  172. SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
  173. INSERT INTO `sys_std_widgets` (`page_id`, `module`, `type`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
  174. (@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";}');
  175. INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
  176. (@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));