Changeset 105 for trunk/Modules/User
- Timestamp:
- Oct 9, 2012, 1:58:45 PM (12 years ago)
- Location:
- trunk/Modules/User
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/UModuleUser.pas
r103 r105 6 6 7 7 uses 8 Classes, SysUtils, UModularSystem, SpecializedDictionary; 8 Classes, SysUtils, UModularSystem, SpecializedDictionary, UUser, 9 UModuleBase, UWebPage; 9 10 10 11 type 11 12 12 { TModuleUser } 13 13 14 14 TModuleUser = class(TModule) 15 private 16 UserControlPage: TWebPage; //TUserControlPage; 15 17 public 18 User: TWebUser; 19 UserOnline: TWebOnlineUser; 20 ModuleBase: TModuleBase; 16 21 constructor Create(Owner: TComponent); override; 17 22 destructor Destroy; override; … … 21 26 procedure Uninstall; override; 22 27 procedure Upgrade; override; 28 procedure LoadUserInfo; 23 29 end; 24 30 … … 27 33 28 34 uses 29 UCore, U UserControlPage, USqlDatabase;35 UCore, USqlDatabase, UUserControlPage; 30 36 31 37 { TModuleUser } … … 39 45 License := 'GNU/LGPL v3'; 40 46 Author := 'Chronosoft'; 47 Dependencies.Add('Base'); 41 48 end; 42 49 … … 48 55 procedure TModuleUser.Start; 49 56 begin 50 Core.Pages.RegisterPage(TUserControlPage, UserControlPage, 'uzivatel'); 57 BeforeStart; 58 ModuleBase := TModuleBase(Manager.FindModuleByName('Base')); 59 UserControlPage := TUserControlPage.Create(nil); 60 ModuleBase.Pages.RegisterPage(UserControlPage, 'uzivatel'); 51 61 //RegisterPage(TUserControlPage, UserControlPage, ''); 52 inherited; 62 User := TWebUser.Create; 63 //User.Database := Database; 64 UserOnline := TWebOnlineUser.Create; 65 //UserOnline.Database := Database; 66 AfterStart; 53 67 end; 54 68 55 69 procedure TModuleUser.Stop; 56 70 begin 57 inherited; 58 Core.Pages.UnregisterPage('uzivatel'); 71 BeforeStop; 72 FreeAndNil(User); 73 FreeAndNil(UserOnline); 74 ModuleBase.Pages.UnregisterPage(UserControlPage); 75 FreeAndNil(UserControlPage); 76 ModuleBase := nil; 77 AfterStop; 59 78 end; 60 79 … … 183 202 end; 184 203 204 procedure TModuleUser.LoadUserInfo; 205 begin 206 User.HandlerData := ModuleBase.HandlerData; 207 UserOnline.HandlerData := ModuleBase.HandlerData; 208 UserOnline.Update; 209 User.Id := UserOnline.User; 210 User.Load; 211 end; 212 213 214 185 215 end. 186 216 -
trunk/Modules/User/UUserControlPage.pas
r103 r105 7 7 uses 8 8 Classes, SysUtils, FileUtil, UWebPage, UHTTPServer, UHtmlClasses, UXmlClasses, 9 UWebObjects ;9 UWebObjects, UModuleUser, UModuleBase; 10 10 11 11 type … … 21 21 procedure HandleProfile(HandlerData: THTTPHandlerData); 22 22 public 23 { public declarations } 24 end; 23 ModuleUser: TModuleUser; 24 ModuleBase: TModuleBase; 25 end; 25 26 26 27 var … … 47 48 else PageName := ''; 48 49 with HtmlDocument.Body do begin 49 LoadUserInfo;50 ModuleUser.LoadUserInfo; 50 51 if PageName = '' then PageName := 'prihlaseni'; 51 52 if PageName = 'prihlaseni' then HandleLogin(HandlerData) … … 91 92 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 92 93 Text := 'Přihlášení uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value; 93 UserId := User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,94 UserId := ModuleUser.User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 94 95 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value); 95 96 if UserId = -1 then begin 96 97 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 97 98 Text := '<br/>Chybné jméno nebo heslo'; 98 end else UserOnline.Login(UserId);99 end else ModuleUser.UserOnline.Login(UserId); 99 100 Form.Free; 100 101 end else … … 149 150 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 150 151 Text := 'Registrace uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value; 151 User.Add(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,152 ModuleUser.User.Add(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 152 153 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value, 153 154 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value); 154 UserId := User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,155 UserId := ModuleUser.User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value, 155 156 TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value); 156 if UserId <> -1 then UserOnline.Login(UserId);157 if UserId <> -1 then ModuleUser.UserOnline.Login(UserId); 157 158 Form.Free; 158 159 end else SubItems.AddNew(Form); … … 163 164 begin 164 165 with TWebSession(HandlerData), Core, HtmlDocument.Body do begin 165 UserOnline.Logout;166 ModuleUser.UserOnline.Logout; 166 167 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 167 168 Text := 'Uživatel odhlášen'; … … 185 186 Hint := 'Zadejte vaše přihlašovací jméno'; 186 187 Required := True; 187 Value.Value := User.Name;188 Value.Value := ModuleUser.User.Name; 188 189 end; 189 190 with AddNewItem do begin … … 200 201 Required := True; 201 202 ItemType := fitText; 202 Value.Value := User.Email;203 Value.Value := ModuleUser.User.Email; 203 204 end; 204 205 with AddNewItem do begin … … 208 209 Required := False; 209 210 ItemType := fitText; 210 Value.Value := User.FullName;211 Value.Value := ModuleUser.User.FullName; 211 212 end; 212 213 end; … … 218 219 with THtmlString(SubItems.AddNew(THtmlString.Create)) do 219 220 Text := 'Profil uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value + ' uložen'; 220 User.Name := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value;221 User.FullName := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('FullName').Value.Value;222 User.Email := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value;223 User.Save;221 ModuleUser.User.Name := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value; 222 ModuleUser.User.FullName := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('FullName').Value.Value; 223 ModuleUser.User.Email := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value; 224 ModuleUser.User.Save; 224 225 Form.Free; 225 226 end else SubItems.AddNew(Form);
Note:
See TracChangeset
for help on using the changeset viewer.