Changeset 594 for trunk/Modules/User


Ignore:
Timestamp:
Nov 2, 2013, 11:23:19 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Vylepšena instalace modulu User.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/User/User.php

    r593 r594  
    431431  KEY `User` (`User`)
    432432) ENGINE=MEMORY  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
     433    $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionGroup` (
     434        `Id` int(11) NOT NULL AUTO_INCREMENT,
     435        `Description` varchar(255) NOT NULL DEFAULT '',
     436        PRIMARY KEY (`Id`)
     437    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
     438   
     439    $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionGroupAssignment` (
     440        `Id` int(11) NOT NULL AUTO_INCREMENT,
     441        `Group` int(11) NOT NULL DEFAULT '0',
     442        `AssignedGroup` int(11) DEFAULT NULL,
     443        `AssignedOperation` int(11) DEFAULT NULL,
     444        PRIMARY KEY (`Id`),
     445        KEY `Group` (`Group`),
     446        KEY `AssignedGroup` (`AssignedGroup`),
     447        KEY `AssignedOperation` (`AssignedOperation`)
     448        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
     449   
     450    $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionOperation` (
     451            `Id` int(11) NOT NULL AUTO_INCREMENT,
     452        `Module` int(11) NOT NULL,
     453            `Operation` varchar(128) NOT NULL DEFAULT '',
     454            `Item` varchar(64) NOT NULL DEFAULT '',
     455                `ItemId` int(11) NOT NULL DEFAULT '0',
     456                PRIMARY KEY (`Id`),
     457                    KEY `Module` (`Module`),
     458                    KEY `Operation` (`Operation`),
     459                    KEY `Item` (`Item`),
     460                    KEY `ItemId` (`ItemId`)
     461                    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
     462   
     463    $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionUserAssignment` (
     464                    `Id` int(11) NOT NULL AUTO_INCREMENT,
     465                    `User` int(11) DEFAULT NULL,
     466                    `AssignedGroup` int(11) DEFAULT NULL,
     467                    `AssignedOperation` int(11) DEFAULT NULL,
     468                    PRIMARY KEY (`Id`),
     469                        KEY `User` (`User`),
     470                        KEY `AssignedGroup` (`AssignedGroup`),
     471                            KEY `AssignedOperation` (`AssignedOperation`)
     472                    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
     473   
     474    $this->Database->query("ALTER TABLE `PermissionGroupAssignment`
     475      ADD CONSTRAINT `PermissionGroupAssignment_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `PermissionGroup` (`Id`),
     476      ADD CONSTRAINT `PermissionGroupAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `PermissionGroup` (`Id`),
     477      ADD CONSTRAINT `PermissionGroupAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `PermissionOperation` (`Id`);");
     478   
     479    $this->Database->query("ALTER TABLE `PermissionOperation`
     480      ADD CONSTRAINT `PermissionOperation_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);");
     481   
     482    $this->Database->query("ALTER TABLE `PermissionUserAssignment`
     483      ADD CONSTRAINT `PermissionUserAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `PermissionGroup` (`Id`),
     484      ADD CONSTRAINT `PermissionUserAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `PermissionOperation` (`Id`),
     485      ADD CONSTRAINT `PermissionUserAssignment_ibfk_4` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);");
    433486  }
    434487 
    435488  function DoUninstall()
    436489  {     
     490    $this->Database->query('DROP TABLE `PermissionUserAssignment`');
     491    $this->Database->query('DROP TABLE `PermissionGroupAssignment`');
     492    $this->Database->query('DROP TABLE `PermissionGroup`');
     493    $this->Database->query('DROP TABLE `PermissionOperation`');
    437494    $this->Database->query('DROP TABLE `UserOnline`');
    438495    $this->Database->query('DROP TABLE `User`');
Note: See TracChangeset for help on using the changeset viewer.