install.sql 12 KB

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