/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

INSERT IGNORE INTO `engine4_core_menuitems` (`name`, `module`, `label`, `plugin`, `params`, `menu`, `submenu`, `order`) VALUES
('core_admin_main_plugins_poke', 'poke', 'Poke & Actions', '', '{"route":"admin_default","module":"poke","controller":"manageactions"}', 'core_admin_main_plugins', '', 999),
("poke_admin_main_manageactions", "poke", "Manage Poke & Actions", "", '{"route":"admin_default","module":"poke","controller":"manageactions"}', "poke_admin_main", "", 2);

CREATE TABLE IF NOT EXISTS `engine4_poke_manageactions` (
	`manageaction_id` int(11) NOT NULL AUTO_INCREMENT,
	`name` varchar(128) NOT NULL,
	`slug` VARCHAR(64) NOT NULL,
	`icon` VARCHAR(255) NULL DEFAULT NULL,
	`enabled` tinyint(1) NOT NULL,
	`order` INT(11) NOT NULL DEFAULT "0",
	PRIMARY KEY (`manageaction_id`),
	KEY `enabled` (`enabled`),
	KEY `order` (`order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci ;

INSERT IGNORE INTO `engine4_poke_manageactions` (`manageaction_id`, `name`, `slug`, `icon`, `enabled`, `order`) VALUES
(1, 'Poke', 'poke', NULL, 1, 1),
(2, 'Call', 'call', NULL, 1, 2),
(3, 'Wink', 'wink', NULL, 1, 3),
(4, 'Slap', 'slap', NULL, 1, 4),
(5, 'Kiss', 'kiss', NULL, 1, 5),
(6, 'Hug', 'hug', NULL, 1, 6),
(7, 'High five', 'high-five', NULL, 1, 7),
(8, 'Smirk', 'smirk', NULL, 1, 8),
(9, 'Heart', 'heart', NULL, 1, 9),
(10, 'Flower', 'flower', NULL, 1, 10),
(11, 'Coffee', 'coffee', NULL, 1, 11),
(12, 'Pizza', 'pizza', NULL, 1, 12),
(13, 'Cake', 'cake', NULL, 1, 13),
(14, 'Beer', 'beer', NULL, 1, 14),
(15, 'Star', 'star', NULL, 1, 15),
(16, 'Punch', 'punch', NULL, 1, 16),
(17, 'Gift', 'gift', NULL, 1, 17),
(18, 'Angel', 'angel', NULL, 1, 18),
(19, 'Cat', 'cat', NULL, 1, 19),
(20, 'Cash', 'cash', NULL, 1, 20);

CREATE TABLE IF NOT EXISTS `engine4_poke_pokes` (
	`poke_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
	`poster_id` int(11) unsigned NOT NULL,
	`receiver_id` int(11) unsigned NOT NULL,
	`creation_date` datetime NOT NULL,
	`manageaction_id` int(11) NOT NULL,
	`modified_date` datetime NOT NULL,
	`notification_id` INT(11) NOT NULL DEFAULT "0",
	PRIMARY KEY (`poke_id`),
  KEY `poster_id` (`poster_id`),
	KEY `receiver_id` (`receiver_id`),
	KEY `creation_date` (`creation_date`),
	KEY `manageaction_id` (`manageaction_id`),
	KEY `notification_id` (`notification_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci ;

INSERT IGNORE INTO `engine4_activity_notificationtypes` (`type`, `module`, `body`, `is_request`, `handler`, `default`) VALUES
("poke", "poke", '{item:$subject} has sent you {var:$pokeActionText}.', 1, "poke.index.request-poke", 1),
("poke_back", "poke", '{item:$subject} {var:$pokeBackActionText}.', 0, "", 1);


INSERT IGNORE INTO `engine4_authorization_permissions`
SELECT
  level_id as `level_id`,
  'user' as `type`,
  'pokeAction' as `name`,
  5 as `value`,
  '["owner_network","registered","network","member","owner"]' as `params`
FROM `engine4_authorization_levels` WHERE `type` NOT IN('public');

INSERT IGNORE INTO `engine4_authorization_allow` (`resource_id`, `resource_type`, `action`, `role`, `role_id`, `value`, `params`) SELECT engine4_users.user_id, 'user', 'pokeAction', 'member', '0', '1', '' FROM engine4_users;
