##
##	Faq structure
##

# module
INSERT INTO `cms__module`(`moduleID`,`name`) VALUES (20,'module.faq' );

# panel
INSERT INTO `cms__panel`(`panelID`,`moduleID`,`name`,`exclusive`,`status`,`parameters`) VALUES (61,20,'panel.faq.faq','false','active','{faqID:null}' );
INSERT INTO `cms__panel`(`panelID`,`moduleID`,`name`,`exclusive`,`status`,`parameters`) VALUES (62,20,'panel.faq.admin.faq','true','active',NULL );
INSERT INTO `cms__panel`(`panelID`,`moduleID`,`name`,`exclusive`,`status`,`parameters`) VALUES (63,20,'panel.faq.admin.item','true','active',NULL );

# panel variant
INSERT INTO `cms__panel_variant`(`panelVariantID`,`panelID`,`name`,`parameters`,`type`,`status`) VALUES (294,61,'FAQ',NULL,'local','active' );
INSERT INTO `cms__panel_variant`(`panelVariantID`,`panelID`,`name`,`parameters`,`type`,`status`) VALUES (295,62,'FAQ ADMIN',NULL,'local','active' );
INSERT INTO `cms__panel_variant`(`panelVariantID`,`panelID`,`name`,`parameters`,`type`,`status`) VALUES (296,63,'FAQ ITEM ADMIN',NULL,'local','active' );

# column_has_panels
INSERT INTO `cms__column_has_panels`(`columnID`,`panelID`,`maxPerColumn`) VALUES (17,63,NULL);
INSERT INTO `cms__column_has_panels`(`columnID`,`panelID`,`maxPerColumn`) VALUES (17,62,1);

# role
INSERT INTO `cms__role`(`roleID`,`moduleID`,`name`,`description`) VALUES ('faq.user',20,'','' );
INSERT INTO `cms__role`(`roleID`,`moduleID`,`name`,`description`) VALUES ('faq.admin',20,'','');
INSERT INTO `cms__role`(`roleID`,`moduleID`,`name`,`description`) VALUES ('faq.guest',20,'','' );

#resource
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.admin.faq.create', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.admin.faq.createAction', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.admin.faq.index', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.admin.faq.indexAction', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.admin.faq.modify', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.admin.faq.modifyAction', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.admin.faq.delete', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.admin.faq.deleteAction', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.faq.index', 20, NULL, NULL );
INSERT INTO `cms__resource`( `resourceID`, `moduleID`, `name`, `description` ) VALUES ( 'faq.faq.indexAction', 20, NULL, NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.faq.activate',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.faq.activateAction',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.faq.deactivate',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.faq.deactivateAction',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.faq.manage',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.faq.manageAction',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.index',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.indexAction',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.create',20,NULL,NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.createAction',20,NULL,NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.modify',20,NULL,NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.modifyAction',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.delete',20,    NULL,NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.deleteAction',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.activate',    20,NULL,    NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.activateAction',20,NULL,NULL );
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.deactivateAction',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.deactivate',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,    `moduleID`,    `name`,`description`) VALUES ('faq.admin.item.order',20,NULL,NULL);
INSERT INTO `cms__resource`(`resourceID`,`moduleID`,`name`,`description`) VALUES ('faq.admin.item.orderAction',20,NULL,NULL );

# role_has_resource
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.admin.faq.index' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.admin.faq.indexAction' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.admin.faq.modify' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.admin.faq.modifyAction' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.admin.faq.delete' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.admin.faq.deleteAction' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.admin.faq.create' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.admin.faq.createAction' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.faq.index' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.admin', 'faq.faq.indexAction' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.user', 'faq.faq.index' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.user', 'faq.faq.indexAction' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.guest', 'faq.faq.index' );
INSERT INTO `cms__role_has_resources`( `roleID`, `resourceID` ) VALUES ( 'faq.guest', 'faq.faq.indexAction' );
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.faq.activate');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.faq.activateAction');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.faq.deactivate');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.faq.deactivateAction' );
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.faq.manage');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.faq.manageAction' );
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.index' );
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.indexAction');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.modify');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.modifyAction');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.create');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.createAction');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.delete' );
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.deleteAction');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.activate');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.activateAction');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.deactivateAction');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.deactivate');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin', 'faq.admin.item.orderAction');
INSERT INTO `cms__role_has_resources`(`roleID`,`resourceID`) VALUES ('faq.admin','faq.admin.item.order' );

# group_has_roles
INSERT INTO `cms__group_has_roles`( `groupID`, `roleID` ) VALUES ( 1, 'faq.admin' );
INSERT INTO `cms__group_has_roles`( `groupID`, `roleID` ) VALUES ( 2, 'faq.user' );
INSERT INTO `cms__group_has_roles`( `groupID`, `roleID` ) VALUES ( 3, 'faq.guest' );

# file
INSERT INTO `cms__file`(`fileID`,`folderID`,`name`,`alias`,`url`,`className`,`status`,`activeFrom`,`activeTo`,`type`,`createDate`,`modifyDate`,`position`) VALUES (2269,7,'Faq adminisztráció','admin.faq','/admin/faq',NULL,'active',NULL,NULL,'page','2017-07-20 14:32:49','2017-07-20 14:32:49',0);
INSERT INTO `cms__file`(`fileID`,`folderID`,`name`,`alias`,`url`,`className`,`status`,`activeFrom`,`activeTo`,`type`,`createDate`,`modifyDate`,`position`) VALUES (2270,7,'Faq elem adminisztráció','faq.item.admin','/admin/faq/item',NULL,'active',NULL,NULL,'page','2017-07-21 14:21:00','2017-07-21 14:21:00',0 );

# file_page
INSERT INTO `cms__file_page`(`fileID`,`layoutID`,`title`,`keywords`,`description`,`editMode`,`editData`) VALUES (2269,2,'Faq','faq','faq','published',NULL);
INSERT INTO `cms__file_page`(`fileID`,`layoutID`,`title`,`keywords`,`description`,    `editMode`,`editData`) VALUES (    2270,2,'Faq elem adminisztráció','admin',    'admin','published',NULL);

# file_page_has_panels
INSERT INTO `cms__file_page_has_panels`(`fileID`,`columnID`,`panelVariantID`,`position`) VALUES (2269,17,295,1);
INSERT INTO `cms__file_page_has_panels`(`fileID`,`columnID`,`panelVariantID`,`position`) VALUES (2270,82,144,1);
INSERT INTO `cms__file_page_has_panels`(`fileID`,`columnID`,`panelVariantID`,`position`) VALUES (2270,17,296,1);
INSERT INTO `cms__file_page_has_panels`(`fileID`,`columnID`,`panelVariantID`,`position`) VALUES (2269,82,144,1 );

# group_has_files
INSERT INTO `cms__group_has_files`(`groupID`,`fileID`,`permissions`) VALUES (1,2269,'dispatch,view,edit,publish,move,remove' );
INSERT INTO `cms__group_has_files`(`groupID`,`fileID`,`permissions`) VALUES (1,2270,'dispatch,view,edit,publish,move,remove');
INSERT INTO `cms__group_has_files`(`groupID`,`fileID`,`permissions`) VALUES (32,2269,'dispatch' );
INSERT INTO `cms__group_has_files`(`groupID`,`fileID`,`permissions`) VALUES (32,2270,'dispatch' );

# tables
CREATE TABLE `faq__faq` (
	`faqID` Int( 11 ) UNSIGNED AUTO_INCREMENT NOT NULL,
	`status` Enum( 'active', 'inactive' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
	`name` VarChar( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
	PRIMARY KEY ( `faqID` ) )
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ENGINE = InnoDB
AUTO_INCREMENT = 1;

-- CREATE TABLE "faq__item" ------------------------------------
CREATE TABLE `faq__item` (
	`itemID` Int( 11 ) UNSIGNED AUTO_INCREMENT NOT NULL,
	`faqID` Int( 1 ) UNSIGNED NOT NULL,
	`imageFileID` Int( 11 ) UNSIGNED NULL,
	`title` VarChar( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
	`content` Text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
	`position` Int( 11 ) UNSIGNED NOT NULL,
	`status` Enum( 'active', 'inactive' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
	PRIMARY KEY ( `itemID` ) )
ENGINE = InnoDB;
CREATE INDEX `index_faqID` ON `faq__item`( `faqID` );
-- -------------------------------------------------------------
-- CREATE LINK "lnk_cms__file_faq__item" -----------------------
ALTER TABLE `faq__item`
	ADD CONSTRAINT `lnk_cms__file_faq__item` FOREIGN KEY ( `imageFileID` )
	REFERENCES `cms__file`( `fileID` )
	ON DELETE Set NULL
	ON UPDATE Cascade;
-- -------------------------------------------------------------

ALTER TABLE `faq__item`
	ADD CONSTRAINT `faq__faq_faq__item` FOREIGN KEY ( `faqID` )
	REFERENCES `faq__faq`( `faqID` )
	ON DELETE Cascade
	ON UPDATE Cascade;

-- CREATE FIELD "faqFolderID" ----------------------------------
ALTER TABLE `cms__site` ADD COLUMN `faqFolderID` Int( 11 ) UNSIGNED NULL;
-- -------------------------------------------------------------

# folder
INSERT INTO `cms__folder`(`folderID`,`parentID`,`name`,`url`,`alias`,`defaultFileID`,`position`,`createDate`,`modifyDate`) VALUES (916,7,'Faq képek mappa','/admin/faq/images','faq.images',NULL,0,'2017-07-23 14:16:12','2017-07-23 14:16:12');

# group_has_folders
INSERT INTO `cms__group_has_folders`(`groupID`,`folderID`,`permissions`) VALUES (1,916,'view,edit,createFile,createFolder,move,remove');
INSERT INTO `cms__group_has_folders`(`groupID`,`folderID`,`permissions`) VALUES (32,916,'createFile,createFolder');
