CREATE DATABASE `pbs` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE pbs;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

CREATE TABLE IF NOT EXISTS `pbs_group` (
  `groupID` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `description` varchar(140) COLLATE utf8_unicode_ci,
  PRIMARY KEY (`groupID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `pbs_rightcategory` (
  `rightcategoryID` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`rightcategoryID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `pbs_right` (
  `rightID` int(11) NOT NULL AUTO_INCREMENT,
  `rightcategoryID` int(11) NOT NULL,
  `shortcut` varchar(10) COLLATE utf8_unicode_ci NOT NULL UNIQUE,
  `title` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `description` varchar(300) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`rightID`),
  KEY `rightcategoryID` (`rightcategoryID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_right`
  ADD CONSTRAINT `pbs_right_ibfk_1` FOREIGN KEY (`rightcategoryID`) REFERENCES `pbs_rightcategory` (`rightcategoryID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_role` (
  `roleID` int(11) NOT NULL AUTO_INCREMENT,
  `groupID` int(11) NOT NULL,
  `title` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `description` varchar(140) COLLATE utf8_unicode_ci DEFAULT NULL,
  `inheritance` tinyint(1) NOT NULL,
  PRIMARY KEY (`roleID`),
  KEY `groupID` (`groupID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;

ALTER TABLE `pbs_role`
  ADD CONSTRAINT `pbs_role_ibfk_1` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_rightroles` (
  `roleID` int(11) NOT NULL,
  `rightID` int(11) NOT NULL,
  PRIMARY KEY (`roleID`,`rightID`),
  KEY `roleID` (`roleID`),
  KEY `rightID` (`rightID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_rightroles`
  ADD CONSTRAINT `pbs_rightroles_ibfk_1` FOREIGN KEY (`roleID`) REFERENCES `pbs_role` (`roleID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_rightroles_ibfk_2` FOREIGN KEY (`rightID`) REFERENCES `pbs_right` (`rightID`) ON DELETE CASCADE;
  

CREATE TABLE IF NOT EXISTS `pbs_groupgroups` (
  `parentID` int(11) NOT NULL,
  `groupID` int(11) NOT NULL,
  PRIMARY KEY (`parentID`,`groupID`),
  KEY `parentID` (`parentID`),
  KEY `groupID` (`groupID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_groupgroups`
  ADD CONSTRAINT `pbs_groupgroups_ibfk_1` FOREIGN KEY (`parentID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_groupgroups_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_person` (
  `personID` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(30) COLLATE utf8_unicode_ci,
  `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `firstname` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
  `street` varchar(30) COLLATE utf8_unicode_ci,
  `housenumber` varchar(30) COLLATE utf8_unicode_ci,
  `city` varchar(30) COLLATE utf8_unicode_ci,
  `postalcode` varchar(30) COLLATE utf8_unicode_ci,
  `logindate` varchar(14) COLLATE utf8_unicode_ci,
  `registerdate` varchar(14) COLLATE utf8_unicode_ci NOT NULL,
  `email` varchar(30) COLLATE utf8_unicode_ci NOT NULL UNIQUE,
  `login` varchar(30) COLLATE utf8_unicode_ci,
  `password` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  `password_salt` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`personID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `pbs_grouprequest` (
  `grouprequestID` int(11) NOT NULL AUTO_INCREMENT,
  `groupID` int(11) NOT NULL,
  `personID` int(11) NOT NULL,
  `time` varchar(14) NOT NULL,
  PRIMARY KEY (`grouprequestID`),
  KEY `groupID` (`groupID`),
  KEY `personID` (`personID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_grouprequest`
  ADD CONSTRAINT `pbs_grouprequest_ibfk_1` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_grouprequest_ibfk_2` FOREIGN KEY (`personID`) REFERENCES `pbs_person` (`personID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_membership` (
  `membershipID` int(11) NOT NULL AUTO_INCREMENT,
  `groupID` int(11) NOT NULL,
  `roleID` int(11) NOT NULL,
  `personID` int(11) NOT NULL,
  PRIMARY KEY (`membershipID`),
  KEY `groupID` (`groupID`),
  KEY `roleID` (`roleID`),
  KEY `personID` (`personID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_membership`
  ADD CONSTRAINT `pbs_membership_ibfk_1` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_membership_ibfk_2` FOREIGN KEY (`personID`) REFERENCES `pbs_person` (`personID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_membership_ibfk_3` FOREIGN KEY (`roleID`) REFERENCES `pbs_role` (`roleID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_config` (
  `configID` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(30) NOT NULL,
  `groupID` int(11) NOT NULL,
  `membershipID` int(11),
  `shellscript` text NOT NULL,
  `created` VARCHAR(14) NOT NULL,
  PRIMARY KEY (`configID`),
  KEY `groupID` (`groupID`),
  KEY `membershipID` (`membershipID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_config`
  ADD CONSTRAINT `pbs_config_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_config_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE;

  
CREATE TABLE IF NOT EXISTS `pbs_bootos` (
  `bootosID` int(11) NOT NULL AUTO_INCREMENT,
  `configID` int(11),
  `groupID` int(11) NOT NULL,
  `membershipID` int(11),
  `title` varchar(30) NOT NULL,
  `description` varchar(140),
  `path_init` varchar(140) NOT NULL,
  `path_kernel` varchar(140) NOT NULL,
  `defaultkcl` varchar(255),
  `created` VARCHAR(14) NOT NULL,
  `expires` VARCHAR(14),
  `public` int(11) NOT NULL,
  PRIMARY KEY (`bootosID`),
  KEY `configID` (`configID`),
  KEY `groupID` (`groupID`),
  KEY `membershipID` (`membershipID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_bootos`
  ADD CONSTRAINT `pbs_bootos_ibfk_1` FOREIGN KEY (`configID`) REFERENCES `pbs_config` (`configID`) ON DELETE SET NULL,
  ADD CONSTRAINT `pbs_bootos_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_bootos_ibfk_3` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE SET NULL;

CREATE TABLE IF NOT EXISTS `pbs_bootmenu` (
  `bootmenuID` int(11) NOT NULL AUTO_INCREMENT,
  `membershipID` int(11),
  `groupID` int(11) NOT NULL,
  `title` varchar(30) NOT NULL,
  `created` varchar(14) NOT NULL,
  PRIMARY KEY (`bootmenuID`),
  KEY `groupID` (`groupID`),
  KEY `membershipID` (`membershipID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_bootmenu`
  ADD CONSTRAINT `pbs_bootmenu_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE SET NULL,
  ADD CONSTRAINT `pbs_bootmenu_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_bootmenuentries` (
  `bootmenuentriesID` int(11) NOT NULL AUTO_INCREMENT,
  `bootosID` int(11) NOT NULL,
  `bootmenuID` int(11) NOT NULL,
  `title` varchar(30) NOT NULL,
  `kcl` varchar(255),
  `kclappend` varchar(255),
  `configID` int(11),
  `order` int(11) NOT NULL,
  PRIMARY KEY (`bootmenuentriesID`),
  KEY `bootosID` (`bootosID`),
  KEY `bootmenuID` (`bootmenuID`),
  KEY `configID` (`configID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_bootmenuentries`
  ADD CONSTRAINT `pbs_bootmenuentries_ibfk_1` FOREIGN KEY (`bootmenuID`) REFERENCES `pbs_bootmenu` (`bootmenuID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_bootmenuentries_ibfk_2` FOREIGN KEY (`bootosID`) REFERENCES `pbs_bootos` (`bootosID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_bootmenuentries_ibfk_3` FOREIGN KEY (`configID`) REFERENCES `pbs_config` (`configID`) ON DELETE SET NULL;

CREATE TABLE IF NOT EXISTS `pbs_preboot` (
  `prebootID` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(30) NOT NULL,  
  `membershipID` int(11),
  `groupID` int(11) NOT NULL,
  `path_preboot` varchar(140) NOT NULL, 
  PRIMARY KEY (`prebootID`),
  KEY `membershipID` (`membershipID`),
  KEY `groupID` (`groupID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_preboot`
  ADD CONSTRAINT `pbs_preboot_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE SET NULL,
  ADD CONSTRAINT `pbs_preboot_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE;


CREATE TABLE IF NOT EXISTS `pbs_bootiso` (
  `bootisoID` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(30) NOT NULL,  
  `membershipID` int(11),
  `groupID` int(11) NOT NULL,
  `prebootID` int(11) NOT NULL,    
  `serialnumber` varchar(30) NOT NULL UNIQUE,
  `created` VARCHAR(14) NOT NULL,
  `expires` VARCHAR(14),
  `public` int(11) NOT NULL,
  PRIMARY KEY (`bootisoID`),
  KEY `membershipID` (`membershipID`),
  KEY `groupID` (`groupID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;


ALTER TABLE `pbs_bootiso`
  ADD CONSTRAINT `pbs_bootiso_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE SET NULL,
  ADD CONSTRAINT `pbs_bootiso_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_bootiso_ibfk_3` FOREIGN KEY (`prebootID`) REFERENCES `pbs_preboot` (`prebootID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_client` (
  `clientID` int(11) NOT NULL AUTO_INCREMENT,
  `macadress` varchar(17) NOT NULL,
  `hardwarehash` varchar(32),
  PRIMARY KEY (`clientID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
ALTER TABLE `pbs_client` ADD `groupID` INT NOT NULL AFTER `clientID` ;
ALTER TABLE `pbs_client` ADD UNIQUE (`macadress`);
ALTER TABLE `pbs_client`
  ADD CONSTRAINT `pbs_client_ibfk_1` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_session` (
  `sessionID` int(11) NOT NULL AUTO_INCREMENT,
  `clientID` int(11),
  `bootosID` int(11),
  `time` varchar(14) NOT NULL,
  `ip` varchar(15) NOT NULL,
  `ip6` varchar(45),
  PRIMARY KEY (`sessionID`),
  KEY `clientID` (`clientID`),
  KEY `bootosID` (`bootosID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
ALTER TABLE `pbs_session` ADD `bootisoID` INT AFTER `bootosID`; 
ALTER TABLE `pbs_session` ADD `alphasessionID` VARCHAR( 16 ) NOT NULL AFTER `sessionID`, ADD UNIQUE (`alphasessionID`) ;
ALTER TABLE `pbs_session` ADD `bootmenuentryID` INT AFTER `clientID` ;
ALTER TABLE `pbs_session` ADD `membershipID` INT NULL AFTER `bootisoID` ;


ALTER TABLE `pbs_session`
  ADD CONSTRAINT `pbs_session_ibfk_1` FOREIGN KEY (`clientID`) REFERENCES `pbs_client` (`clientID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_session_ibfk_2` FOREIGN KEY (`bootosID`) REFERENCES `pbs_bootos` (`bootosID`) ON DELETE SET NULL,
  ADD CONSTRAINT `pbs_session_ibfk_3` FOREIGN KEY (`bootisoID`) REFERENCES `pbs_bootiso` (`bootisoID`) ON DELETE SET NULL,
  ADD CONSTRAINT `pbs_session_ibfk_4` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_pool` (
  `poolID` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(30) NOT NULL,
  `description` varchar(140),
  `location` varchar(30),
  PRIMARY KEY (`poolID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
ALTER TABLE `pbs_pool` ADD `groupID` INT NOT NULL AFTER `poolID`;
ALTER TABLE `pbs_pool`
  ADD CONSTRAINT `pbs_pool_ibfk_1` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_poolentries` (
  `poolID` int(11) NOT NULL,
  `clientID` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
ALTER TABLE `pbs_poolentries` ADD `poolentriesID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;

ALTER TABLE `pbs_poolentries`
  ADD CONSTRAINT `pbs_poolentries_ibfk_1` FOREIGN KEY (`poolID`) REFERENCES `pbs_pool` (`poolID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_poolentries_ibfk_2` FOREIGN KEY (`clientID`) REFERENCES `pbs_client` (`clientID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_filter` (
  `filterID` int(11) NOT NULL AUTO_INCREMENT,
  `membershipID` int(11),
  `groupID` int(11) NOT NULL,
  `bootmenuID` int(11) NOT NULL,
  `title` varchar(30) NOT NULL,
  `description` varchar(140),  
  `created` varchar(14) NOT NULL,
  `priority` int(11) NOT NULL,
  PRIMARY KEY (`filterID`),
  KEY `membershipID` (`membershipID`),
  KEY `groupID` (`groupID`),
  KEY `bootmenuID` (`bootmenuID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

ALTER TABLE `pbs_filter`
  ADD CONSTRAINT `pbs_filter_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`),
  ADD CONSTRAINT `pbs_filter_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_filter_ibfk_3` FOREIGN KEY (`bootmenuID`) REFERENCES `pbs_bootmenu` (`bootmenuID`) ON DELETE CASCADE;



CREATE TABLE IF NOT EXISTS `pbs_filtertype` (
  `filtertypeID` int(11) NOT NULL AUTO_INCREMENT,
  `filtertypename` varchar(30) NOT NULL,
  PRIMARY KEY (`filtertypeID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `pbs_filterentries` (
  `filterID` int(11) NOT NULL,
  `filtertypeID` int(11) NOT NULL,
  `filtervalue` varchar(140) NOT NULL,
  `filtervalue2` varchar(140) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
ALTER TABLE  `pbs_filterentries` CHANGE  `filtervalue2`  `filtervalue2` VARCHAR( 140 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL;
ALTER TABLE `pbs_filterentries` ADD `filterentriesID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; 
ALTER TABLE `pbs_filterentries`
  ADD CONSTRAINT `pbs_filterentries_ibfk_1` FOREIGN KEY (`filterID`) REFERENCES `pbs_filter` (`filterID`) ON DELETE CASCADE,
  ADD CONSTRAINT `pbs_filterentries_ibfk_2` FOREIGN KEY (`filtertypeID`) REFERENCES `pbs_filtertype` (`filtertypeID`) ON DELETE CASCADE;

CREATE TABLE IF NOT EXISTS `pbs_passwordrecovery` (
  `personID` int(11) NOT NULL,
  `recoveryID` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`personID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE `pbs_passwordrecovery`
  ADD CONSTRAINT `pbs_passwordrecovery_ibfk_1` FOREIGN KEY (`personID`) REFERENCES `pbs_person` (`personID`) ON DELETE CASCADE;

-- Insert Filtertypes
INSERT INTO `pbs_filtertype` (`filtertypeID`, `filtertypename`) VALUES
(1, 'IP'),
(2, 'MAC'),
(3, 'PoolID'),
(4, 'BootIso'),
(5, 'Membership'),
(6, 'Group'),
(7, 'Time'),
(8, 'Client'),
(9, 'Hardwarehash'),
(10, 'Weekday'),
(11, 'Date');

-- Insert rightcategorys
INSERT INTO `pbs_rightcategory` (`rightcategoryID`, `title`) VALUES
(1, 'Person'),
(2, 'Group'),
(3, 'Role'),
(4, 'BootMedia'),
(5, 'Preboot'),
(6, 'Config'),
(7, 'BootOs'),
(8, 'BootMenu'),
(9, 'Client'),
(10, 'Pool'),
(11, 'Filter');

-- Insert rights
INSERT INTO `pbs`.`pbs_right` (`rightID`, `rightcategoryID`, `shortcut`, `title`, `description`) VALUES 
	-- Person
	-- Personenübersicht anzeigen
(NULL, '1', 'pso', 'Show overview of persons', NULL),
	-- Eigene Personendetails ändern
(NULL, '1', 'peod', 'Edit own profiledetails', NULL),
	-- Eigene Personendetails anzeigen
(NULL, '1', 'psod', 'Show own profiledetails', NULL),
	-- Eigene Identität vom System löschen
(NULL, '1', 'pdo', 'Delete own account', NULL),
	-- Person löschen
(NULL, '1', 'pd', 'Delete account of other', NULL),
	-- Personendetails anderer anzeigen
(NULL, '1', 'psood', 'Show other profiledetails', NULL),
	-- Personendetails anderer ändern
(NULL, '1', 'peoa', 'Edit account from other', NULL),
	-- Person sperren
(NULL, '1', 'psa', 'Suspend account', NULL),


	-- Gruppen
	-- Gruppenübersicht anzeigen
(NULL, '2', 'gso', 'Show overview of groups', NULL),
	-- Gruppendetails der eigenen Gruppe anzeigen
(NULL, '2', 'gsdo', 'Show details of own group', NULL),
	-- Gruppendetails anderer Gruppen anzeigen
(NULL, '2', 'gsdog', 'Show details of other group', NULL),
	-- Mitglieder einer Gruppe Anzeigen
(NULL, '2', 'gsmg', 'Show members of group', NULL),
	-- Gruppe erstellen
(NULL, '2', 'gc', 'Create group', NULL),
	-- Gruppe löschen	
(NULL, '2', 'gd', 'Delete group', NULL),
	-- Gruppe mit allen Untergruppen löschen
(NULL, '2', 'gdlwc', 'Delete group with all child groups', NULL),
	-- Gruppenanfragen stellen
(NULL, '2', 'grm', 'Request membership', NULL),
	-- Gruppenanfragen akzeptieren
(NULL, '2', 'gam', 'Accept membership request', NULL),
	-- Gruppenanfragen ablehnen	
(NULL, '2', 'gdm', 'Decline membership request', NULL),
	-- Gruppe verlassen	
(NULL, '2', 'gl', 'Leave Group', NULL),
	-- Mitgliedschaften aus eigenen Gruppen entfernen
(NULL, '2', 'gdmo', 'Delete membership in own group', NULL),
	-- Mitgliedschaften aus anderen Gruppen entfernen
(NULL, '2', 'gdmog', 'Delete membership in other group', NULL),
	-- Gruppenmitgliedschaft sperren
(NULL, '2', 'gsm', 'Suspend membership', NULL),

	-- Rollen
	-- Neue Rollen anlegen
(NULL, '3', 'ra', 'Add role', NULL),
	-- Rollen anzeigen
(NULL, '3', 'rdd', 'Display details of role', NULL),
	-- Rollen löschen
(NULL, '3', 'rd', 'Delete role', NULL),
	-- Rollen von Personen ändern
(NULL, '3', 'rcr', 'Change role of membership', NULL),
	-- Recht zu Rolle hinzufügen
(NULL, '3', 'rar', 'Add right to role', NULL),
	-- Recht von Rolle löschen
(NULL, '3', 'rrr', 'Remove right of role', NULL),
	-- Rolle vererbbar machen
(NULL, '3', 'rir', 'Inherit role', NULL),

	-- BootMedien
	-- BootMedien Admin-Übersicht anzeigen
(NULL, '4', 'bai', 'Show admin interface of BootMedia', NULL),
	-- BootMedien User-Übersicht anzeigen
(NULL, '4', 'bui', 'Show user interface of BootMedia', NULL),
	-- BootMedien anlegen
(NULL, '4', 'bc', 'Create new BootMedia', NULL),
	-- BootMedien editieren
(NULL, '4', 'be', 'Edit BootMedia', NULL),
	-- BootMedien löschen
(NULL, '4', 'bd', 'Delete BootMedia', NULL),
	-- BootMedien herunterladen
(NULL, '4', 'bdld', 'Download BootMedia', NULL),
	-- BootMedien-Metadata (Description, Title) ändern
(NULL, '4', 'bem', 'Edit metadata (Description, Title) of a BootMedia', NULL),

	-- Preboot
	-- Preboot übersicht anzeigen
(NULL, '5', 'pro', 'Show overview of preboots', NULL),
	-- Preboot anlegen
(NULL, '5', 'prc', 'Create preboot', NULL),
	-- Preboot editieren
(NULL, '5', 'pre', 'Edit preboot', NULL),
	-- Preboot löschen
(NULL, '5', 'prd', 'Delete preboot', NULL),
	-- Preboot updaten
(NULL, '5', 'pru', 'Update preboot', NULL),
	-- Preboot-Metadata (Description, Title) ändern
(NULL, '5', 'prem', 'Edit metadata (Description, Title) of a preboot', NULL),

	-- Config
	-- Config Admin-Übersicht anzeigen
(NULL, '6', 'csai', 'Show admin overview of config', NULL),
	-- Config User-Übersicht anzeigen
(NULL, '6', 'csui', 'Show user overview of config', NULL),
	-- Config anlegen
(NULL, '6', 'cc', 'Create config', NULL),
	-- Config editieren
(NULL, '6', 'ce', 'Edit config', NULL),
	-- Config löschen
(NULL, '6', 'cd', 'Delete config', NULL),
	-- Config updaten
(NULL, '6', 'cu', 'Update config', NULL),
	-- Config-Metadata (Description, Title) ändern
(NULL, '6', 'cem', 'Edit metadata (Description, Title) of config', NULL),

	-- BootOs
	-- BootOs anlegen
(NULL, '7', 'boc', 'Create BootOs', NULL),
	-- BootOS Admin-Übersicht anzeigen
(NULL, '7', 'boai', 'Show admin interface of BootOs', NULL),
	-- BootOs User-Übersicht anzeigen
(NULL, '7', 'boui', 'Show user interface of BootOs', NULL),
	-- BootOs editieren
(NULL, '7', 'boe', 'Edit BootOs', NULL),
	-- BootOs löschen
(NULL, '7', 'bod', 'Delete BootOs', NULL),
	-- BootOs updaten
(NULL, '7', 'bou', 'Update BootOs', NULL),
	-- BootOs-Metadata (Description, Title) ändern
(NULL, '7', 'boem', 'Edit metadata (Description, Title) of BootOs', NULL),

	-- BootMenu
	-- BootMenu Admin-Übersicht anzeigen
(NULL, '8', 'booai', 'Show admin interface of BootMenu', NULL),
	-- User-BootMenu anzeigen
(NULL, '8', 'booui', 'Show user interface of BootMenu', NULL),
	-- BootMenu anlegen
(NULL, '8', 'booc', 'Create BootMenu', NULL),
	-- BootMenu löschen
(NULL, '8', 'bood', 'Delete BootMenu', NULL),
	-- Bootmenu editieren
(NULL, '8', 'booe', 'Edit BootMenu', NULL),
	-- BootmenuEintrag löschen
(NULL, '8', 'boode', 'Delete entry of BootMenu', NULL),
	-- BootmenuEintrag hinzufügen
(NULL, '8', 'booae', 'Add entry to a BootMenu', NULL),
	-- BootmenuEintrag editieren
(NULL, '8', 'booee', 'Edit an entry of a BootMenu', NULL),
	-- BootmenuEintrag-Metadata (Description, Title) ändern
(NULL, '8', 'booeem', 'Edit metadata (Description, Title) of an entry of a BootMenu', NULL),

	-- Client
	-- Client Übersicht ansehen
(NULL, '9', 'clo', 'Show overview of Clients', NULL),
	-- Clients manuell anlegen
(NULL, '9', 'cla', 'Add new Clients', NULL),
	-- Clients bearbeiten
(NULL, '9', 'cle', 'Edit Clients', NULL),
	-- Clients löschen
(NULL, '9', 'cld', 'Delete Clients', NULL),

	-- Pool
	-- Pool Übersicht anzeigen
(NULL, '10', 'poo', 'Show overview of Pool', NULL),
	-- Pools anlegen
(NULL, '10', 'poc', 'Create new Pool', NULL),
	-- Pools bearbeiten
(NULL, '10', 'poe', 'Edit Pool', NULL),
	-- Pools löschen
(NULL, '10', 'pod', 'Delete Pool', NULL),
	-- Clients aus Pool entfernen
(NULL, '10', 'pouc', 'Unlink client to pool', NULL),
	-- Clients zu Pool hinzufügen
(NULL, '10', 'polc', 'Link client to pool', NULL),
	-- Übersicht an nicht zugewiesene Clients anzeigen
(NULL, '10', 'posuc', 'Show unlinked Clients', NULL),

	-- Filter
	-- Filter Übersicht ansehen
(NULL, '11', 'fo', 'Show overview of Filter', NULL),
	-- Filter anlegen
(NULL, '11', 'fa', 'Create new Filter', NULL),
	-- Filter bearbeiten
(NULL, '11', 'fe', 'Edit Filter', NULL),
	-- Filterpriorität ändern
(NULL, '11', 'fefp', 'Edit Filterpriority', NULL),
	-- Filter löschen
(NULL, '11', 'fd', 'Delete Filter', NULL),
	-- FilterEinträge hinzufügen
(NULL, '11', 'ffa', 'Add additional Filterentry to a Filter', NULL),
	-- FilterEinträge editieren
(NULL, '11', 'ffe', 'Edit Filterentry of a Filter', NULL),
	-- FilterEinträge löschen
(NULL, '11', 'ffd', 'Delete Filterentry of a Filter', NULL);

-- Adding Super-User
INSERT INTO `pbs`.`pbs_group` (`groupID` ,`title` ,`description`)VALUES 
(1, 'OpenSLX', 'This is the OpenSLX-Group');
INSERT INTO `pbs`.`pbs_role` (`roleID`, `groupID`, `title`, `description`, `inheritance`) VALUES (1, '1', 'SuperAdmin', 'The SuperAdmin', 0);
INSERT INTO `pbs`.`pbs_rightroles` (`roleID`, `rightID`) VALUES
(1, 1),(1, 2),(1, 3),(1, 4),(1, 5),(1, 6),(1, 7),(1, 8),(1, 9),(1, 10),(1, 11),(1, 12),(1, 13),(1, 14),(1, 15),(1, 16),(1, 17),(1, 18),(1, 19),(1, 20),(1, 21),(1, 22),(1, 23),(1, 24),(1, 25),(1, 26),(1, 27),(1, 28),(1, 29),(1, 30),(1, 31),(1, 32),(1, 33),(1, 34),(1, 35),(1, 36),(1, 37),(1, 38),(1, 39),(1, 40),(1, 41),(1, 42),(1, 43),(1, 44),(1, 45),(1, 46),(1, 47),(1, 48),(1, 49),(1, 50),(1, 51),(1, 52),(1, 53),(1, 54),(1, 55),(1, 56),(1, 57),(1, 58),(1, 59),(1, 60),(1, 61),(1, 62),(1, 63),(1, 64),(1, 65),(1, 66),(1, 67),(1, 68),(1, 69),(1, 70),(1, 71),(1, 72),(1, 73),(1, 74),(1, 75),(1, 76),(1, 77),(1, 78),(1, 79),(1, 80),(1, 81),(1, 82),(1, 83),(1, 84);
