source: trunk/Modules/IS/ModuleIS.pas

Last change on this file was 151, checked in by chronos, 9 months ago
File size: 3.4 KB
Line 
1unit ModuleIS;
2
3interface
4
5uses
6 Classes, SysUtils, ModularSystem, SqlDatabase, ModuleBase, Generics;
7
8type
9
10 { TModuleIS }
11
12 TModuleIS = class(TModule)
13 private
14 public
15 ModuleBase: TModuleBase;
16 constructor Create(Owner: TComponent); override;
17 destructor Destroy; override;
18 procedure Start; override;
19 procedure Stop; override;
20 procedure Install; override;
21 procedure Uninstall; override;
22 procedure Upgrade; override;
23 end;
24
25
26implementation
27
28uses
29 Core, PagePortal;
30
31{ TModuleIS }
32
33constructor TModuleIS.Create(Owner: TComponent);
34begin
35 inherited;
36 Identification := 'IS';
37 Title := 'Data management';
38 Version := '1.0';
39 License := 'GNU/LGPL v3';
40 Author := 'Chronosoft';
41 Dependencies.Add('Base');
42end;
43
44destructor TModuleIS.Destroy;
45begin
46 inherited;
47end;
48
49procedure TModuleIS.Start;
50begin
51 BeforeStart;
52 ModuleBase := TModuleBase(Manager.FindModuleByName('Base'));
53 //ModuleBase.Pages.RegisterPage(TWebPagePortal, WebPagePortal, 'portal');
54 AfterStart;
55end;
56
57procedure TModuleIS.Stop;
58begin
59 BeforeStop;
60 //ModuleBase.Pages.UnregisterPage('portal');
61 ModuleBase := nil;
62 AfterStop;
63end;
64
65procedure TModuleIS.Install;
66var
67 DbRows: TDbRows;
68 Data: TDictionaryStringString;
69begin
70 try
71 DbRows := TDbRows.Create;
72 Data := TDictionaryStringString.Create;
73
74 Core.Core.CommonDatabase.Query(DbRows,
75 'CREATE TABLE IF NOT EXISTS `User` (' +
76 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
77 ' `Name` varchar(255) NOT NULL,' +
78 ' `FullName` varchar(255) NOT NULL,' +
79 ' `Password` varchar(255) NOT NULL,' +
80 ' `Salt` varchar(255) NOT NULL,' +
81 ' `Email` varchar(255) NOT NULL,' +
82 ' `RegistrationTime` datetime NOT NULL,' +
83 ' PRIMARY KEY (`Id`)' +
84 ') ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
85
86 Data.Add('Id', '1');
87 Data.Add('Name', 'anonymous');
88 Data.Add('FullName', 'Anonymous');
89 Data.Add('RegistrationTime', 'NOW()');
90 Data.Add('Password', '');
91 Data.Add('Salt', '');
92 Data.Add('Email', '');
93 Core.Core.CommonDatabase.Insert('User', Data);
94
95 Core.Core.CommonDatabase.Query(DbRows,
96 'CREATE TABLE IF NOT EXISTS `UserOnline` (' +
97 ' `Id` int(11) NOT NULL AUTO_INCREMENT,' +
98 ' `User` int(11) NOT NULL DEFAULT ''0'',' +
99 ' `ActivityTime` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',' +
100 ' `LoginTime` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',' +
101 ' `SessionId` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
102 ' `IpAddress` varchar(16) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
103 ' `HostName` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
104 ' `ScriptName` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
105 ' PRIMARY KEY (`Id`),' +
106 ' KEY `User` (`User`)' +
107 ') ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
108 finally
109 Data.Free;
110 DbRows.Free;
111 end;
112 inherited Install;
113end;
114
115procedure TModuleIS.Uninstall;
116var
117 DbRows: TDbRows;
118begin
119 inherited Uninstall;
120 try
121 DbRows := TDbRows.Create;
122 Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `User`');
123 Core.Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `UserOnline`');
124 finally
125 DbRows.Free;
126 end;
127end;
128
129procedure TModuleIS.Upgrade;
130begin
131 inherited;
132end;
133
134end.
135
Note: See TracBrowser for help on using the repository browser.