Changeset 890 for trunk/Modules/User/User.php
- Timestamp:
- Dec 29, 2020, 11:11:12 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/User.php
r887 r890 25 25 function DoInstall(): void 26 26 { 27 $this->Database->query("CREATE TABLE IF NOT EXISTS `User` ( 28 `Id` int(11) NOT NULL AUTO_INCREMENT, 29 `Login` varchar(64) NOT NULL, 30 `Name` varchar(128) NOT NULL, 31 `Password` varchar(255) NOT NULL, 32 `Salt` varchar(255) NOT NULL, 33 `Email` varchar(128) NOT NULL DEFAULT '', 34 `LastIpAddress` varchar(16) NOT NULL DEFAULT '', 35 `LastLoginTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 36 `RegistrationTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 37 `Locked` tinyint(1) NOT NULL DEFAULT '0', 38 `InitPassword` varchar(255) NOT NULL, 39 PRIMARY KEY (`Id`), 40 UNIQUE KEY `Name` (`Login`), 41 UNIQUE KEY `Nick` (`Name`) 42 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 43 $this->Database->query("CREATE TABLE IF NOT EXISTS `UserOnline` ( 44 `Id` int(11) NOT NULL AUTO_INCREMENT, 45 `User` int(11) DEFAULT NULL COMMENT 'User.Id', 46 `ActivityTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 47 `LoginTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', 48 `SessionId` varchar(255) NOT NULL DEFAULT '', 49 `IpAddress` varchar(16) NOT NULL DEFAULT '', 50 `HostName` varchar(255) NOT NULL DEFAULT '', 51 `ScriptName` varchar(255) NOT NULL, 52 `StayLogged` INT NOT NULL, 53 `StayLoggedHash` VARCHAR(40) NOT NULL, 54 PRIMARY KEY (`Id`), 55 KEY `User` (`User`) 56 ) ENGINE=MEMORY DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 57 $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionGroup` ( 58 `Id` int(11) NOT NULL AUTO_INCREMENT, 59 `Description` varchar(255) NOT NULL DEFAULT '', 60 PRIMARY KEY (`Id`) 61 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 62 63 $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionGroupAssignment` ( 64 `Id` int(11) NOT NULL AUTO_INCREMENT, 65 `Group` int(11) NOT NULL DEFAULT '0', 66 `AssignedGroup` int(11) DEFAULT NULL, 67 `AssignedOperation` int(11) DEFAULT NULL, 68 PRIMARY KEY (`Id`), 69 KEY `Group` (`Group`), 70 KEY `AssignedGroup` (`AssignedGroup`), 71 KEY `AssignedOperation` (`AssignedOperation`) 72 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 73 74 $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionOperation` ( 75 `Id` int(11) NOT NULL AUTO_INCREMENT, 76 `Module` int(11) NOT NULL, 77 `Operation` varchar(128) NOT NULL DEFAULT '', 78 `Item` varchar(64) NOT NULL DEFAULT '', 79 `ItemId` int(11) NOT NULL DEFAULT '0', 80 PRIMARY KEY (`Id`), 81 KEY `Module` (`Module`), 82 KEY `Operation` (`Operation`), 83 KEY `Item` (`Item`), 84 KEY `ItemId` (`ItemId`) 85 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 86 87 $this->Database->query("CREATE TABLE IF NOT EXISTS `PermissionUserAssignment` ( 88 `Id` int(11) NOT NULL AUTO_INCREMENT, 89 `User` int(11) DEFAULT NULL, 90 `AssignedGroup` int(11) DEFAULT NULL, 91 `AssignedOperation` int(11) DEFAULT NULL, 92 PRIMARY KEY (`Id`), 93 KEY `User` (`User`), 94 KEY `AssignedGroup` (`AssignedGroup`), 95 KEY `AssignedOperation` (`AssignedOperation`) 96 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 97 98 $this->Database->query("ALTER TABLE `PermissionGroupAssignment` 99 ADD CONSTRAINT `PermissionGroupAssignment_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `PermissionGroup` (`Id`), 100 ADD CONSTRAINT `PermissionGroupAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `PermissionGroup` (`Id`), 101 ADD CONSTRAINT `PermissionGroupAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `PermissionOperation` (`Id`);"); 102 103 $this->Database->query("ALTER TABLE `PermissionOperation` 104 ADD CONSTRAINT `PermissionOperation_ibfk_1` FOREIGN KEY (`Module`) REFERENCES `Module` (`Id`);"); 105 106 $this->Database->query("ALTER TABLE `PermissionUserAssignment` 107 ADD CONSTRAINT `PermissionUserAssignment_ibfk_2` FOREIGN KEY (`AssignedGroup`) REFERENCES `PermissionGroup` (`Id`), 108 ADD CONSTRAINT `PermissionUserAssignment_ibfk_3` FOREIGN KEY (`AssignedOperation`) REFERENCES `PermissionOperation` (`Id`), 109 ADD CONSTRAINT `PermissionUserAssignment_ibfk_4` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);"); 27 $this->InstallModel(User::GetDesc()); 28 $this->InstallModel(UserOnline::GetDesc()); 29 $this->InstallModel(PermissionGroup::GetDesc()); 30 $this->InstallModel(PermissionOperation::GetDesc()); 31 $this->InstallModel(PermissionGroupAssignment::GetDesc()); 32 $this->InstallModel(PermissionUserAssignment::GetDesc()); 110 33 } 111 34 112 35 function DoUninstall(): void 113 36 { 114 $this->Database->query('DROP TABLE `PermissionUserAssignment`'); 115 $this->Database->query('DROP TABLE `PermissionGroupAssignment`'); 116 $this->Database->query('DROP TABLE `PermissionGroup`'); 117 $this->Database->query('DROP TABLE `PermissionOperation`'); 118 $this->Database->query('DROP TABLE `UserOnline`'); 119 $this->Database->query('DROP TABLE `User`'); 120 } 121 122 function DoUpgrade(): void 123 { 124 /* 125 126 if ($this->InstalledVersion == '1.0') { 127 $this->System->Database->Query('SELECT * FROM User WHERE Id=1'); 128 $this->InstalledVersion = '1.1'; 129 } 130 */ 37 $this->UninstallModel(PermissionUserAssignment::GetDesc()); 38 $this->UninstallModel(PermissionGroupAssignment::GetDesc()); 39 $this->UninstallModel(PermissionOperation::GetDesc()); 40 $this->UninstallModel(PermissionGroup::GetDesc()); 41 $this->UninstallModel(UserOnline::GetDesc()); 42 $this->UninstallModel(User::GetDesc()); 131 43 } 132 44
Note:
See TracChangeset
for help on using the changeset viewer.