##
##	testimonial structure
##

# module
INSERT INTO `cms__module`(`moduleID`,`name`) VALUES (18,'module.testimonial' );

# panel
INSERT INTO `cms__panel`(`panelID`,`moduleID`,`name`,`exclusive`,`status`,`parameters`) VALUES (56,18,'panel.testimonial.testimonial','false','active','{itemID:null}' );
INSERT INTO `cms__panel`(`panelID`,`moduleID`,`name`,`exclusive`,`status`,`parameters`) VALUES (57,18,'panel.testimonial.admin.item','true','active',NULL );
INSERT INTO `cms__panel`(`panelID`,`moduleID`,`name`,`exclusive`,`status`,`parameters`) VALUES (65,18,'panel.testimonial.admin.testimonial','true','active',NULL );

# panel variant
INSERT INTO `cms__panel_variant`(`panelVariantID`,`panelID`,`name`,`parameters`,`type`,`status`) VALUES (288,56,'testimonial',NULL,'local','active' );
INSERT INTO `cms__panel_variant`(`panelVariantID`,`panelID`,`name`,`parameters`,`type`,`status`) VALUES (289,57,'testimonial ITEM ADMIN',NULL,'local','active' );
INSERT INTO `cms__panel_variant`(`panelVariantID`,`panelID`,`name`,`parameters`,`type`,`status`) VALUES (303,65,'testimonial ADMIN',NULL,'local','active' );

# column_has_panels
INSERT INTO `cms__column_has_panels`(`columnID`,`panelID`,`maxPerColumn`) VALUES (17,57,NULL);
INSERT INTO `cms__column_has_panels`(`columnID`,`panelID`,`maxPerColumn`) VALUES (17,56,NULL );
INSERT INTO `cms__column_has_panels`(`columnID`,`panelID`,`maxPerColumn`) VALUES (17,65,NULL );

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

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

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

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

# file
INSERT INTO `cms__file`(`fileID`,`folderID`,`name`,`alias`,`url`,`className`,`status`,`activeFrom`,`activeTo`,`type`,`createDate`,`modifyDate`,`position`) VALUES (2254,7,'Testimonial item admin','admin.testimonial.item','/admin/testimonial/item',NULL,'active',NULL,NULL,'page','2017-07-19 14:32:49','2017-07-19 14:32:49',4);
INSERT INTO `cms__file`(`fileID`,`folderID`,`name`,`alias`,`url`,`className`,`status`,`activeFrom`,`activeTo`,`type`,`createDate`,`modifyDate`,`position`) VALUES (2283,7,'Testimonial admin','admin.testimonial','/admin/testimonial',NULL,'active',NULL,NULL,'page','2017-07-21 14:21:00','2017-07-21 14:21:00',9 );

# file_page
INSERT INTO `cms__file_page`(`fileID`,`layoutID`,`title`,`keywords`,`description`,`editMode`,`editData`) VALUES (2254,2,'Vélemények','vélemények','vélemények','published',NULL);
INSERT INTO `cms__file_page`(`fileID`,`layoutID`,`title`,`keywords`,`description`,    `editMode`,`editData`) VALUES (2283,2,'Testimonial adminisztráció','admin',    'admin','published',NULL);

# file_page_has_panels
INSERT INTO `cms__file_page_has_panels`(`phpID`,`fileID`,`columnID`,`panelVariantID`,`position`) VALUES (1771,2254,17,289,1);
INSERT INTO `cms__file_page_has_panels`(`fileID`,`columnID`,`panelVariantID`,`position`) VALUES (2283,17,303,1);
INSERT INTO `cms__file_page_has_panels`(`fileID`,`columnID`,`panelVariantID`,`position`) VALUES (2254,82,144,1 );
INSERT INTO `cms__file_page_has_panels`(`fileID`,`columnID`,`panelVariantID`,`position`) VALUES (2283,82,144,1 );

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

# tables
-- CREATE TABLE "testimonial__item" ---------------------------
CREATE TABLE `testimonial__item` (
	`itemID` Int( 11 ) UNSIGNED AUTO_INCREMENT NOT NULL,
	`imageFileID` Int( 11 ) UNSIGNED NULL,
	`name` VarChar( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
	`content` Text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
	`company` VarChar( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
	`title` VarChar( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
	`status` Enum( 'active', 'inactive' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'active',
	`position` Int( 11 ) UNSIGNED NOT NULL DEFAULT '0',
	`testimonialID` Int( 11 ) UNSIGNED NOT NULL,
	PRIMARY KEY ( `itemID` ),
	CONSTRAINT `unique_itemID` UNIQUE( `itemID` ) )
CHARACTER SET = utf8
COLLATE = utf8_general_ci
ENGINE = InnoDB
AUTO_INCREMENT = 10;
-- -------------------------------------------------------------

-- CREATE LINK "lnk_testimonial__testimonial_testimonial__item"
ALTER TABLE `testimonial__item`
	ADD CONSTRAINT `lnk_testimonial__testimonial_testimonial__item` FOREIGN KEY ( `testimonialID` )
	REFERENCES `testimonial__testimonial`( `testimonialID` )
	ON DELETE Cascade
	ON UPDATE Cascade;
-- -------------------------------------------------------------

-- CREATE LINK "lnk_cms__file_testimonial__item" ---------------
ALTER TABLE `testimonial__item`
	ADD CONSTRAINT `lnk_cms__file_testimonial__item` FOREIGN KEY ( `imageFileID` )
	REFERENCES `cms__file`( `fileID` )
	ON DELETE Cascade
	ON UPDATE Cascade;
-- -------------------------------------------------------------

-- CREATE INDEX "cms__file_testimonial__item" -----------------
CREATE INDEX `cms__file_testimonial__item` USING BTREE ON `testimonial__item`( `imageFileID` );
-- -------------------------------------------------------------

-- CREATE INDEX "index_testimonialID" -------------------------
CREATE INDEX `index_testimonialID` USING BTREE ON `testimonial__item`( `testimonialID` );
-- -------------------------------------------------------------

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

# folder
INSERT INTO `cms__folder`(`folderID`, `parentID`,`name`,`url`,`alias`,`defaultFileID`,`position`,`createDate`,`modifyDate`) VALUES (914,7,'Testimonials mappa','/admin/testimonials-folder','testimonials.folder',NULL,4,'2017-07-20 13:46:59','2017-07-20 13:46:59');

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

# site
-- CREATE FIELD "testimonialFolderID" -------------------------
ALTER TABLE `cms__site` ADD COLUMN `testimonialFolderID` Int( 255 ) UNSIGNED NULL;
-- -------------------------------------------------------------

-- CREATE INDEX "index_testimonialFolderID" -------------------
CREATE INDEX `index_testimonialFolderID` ON `cms__site`( `testimonialFolderID` );
-- -------------------------------------------------------------

ALTER TABLE `cms__site`
	ADD CONSTRAINT `lnk_cms__folder_cms__site` FOREIGN KEY ( `testimonialFolderID` )
	REFERENCES `cms__folder`( `folderID` )
	ON DELETE Set NULL
	ON UPDATE Cascade;

