source: branches/mvc/Application/View/User.php

Last change on this file was 47, checked in by chronos, 10 years ago
  • Odstraněno: Zbytečná PHP ukončovací značka "?>" z konce všech souborů.
File size: 7.6 KB
Line 
1<?php
2
3class UserView extends Module
4{
5 var $OptionsFormClass = array(
6 'Title' => 'Základní nastavení',
7 'Table' => 'User',
8 'SubmitText' => 'Uložit',
9 'Items' => array(
10 'Login' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => ''),
11 'Password' => array('Type' => 'Password', 'Caption' => 'Heslo', 'Default' => ''),
12 'Name' => array('Type' => 'String', 'Caption' => 'Zobrazované jméno', 'Default' => ''),
13 'Email' => array('Type' => 'String', 'Caption' => 'E-mail', 'Default' => ''),
14 //'PhoneNumber' => array('Type' => 'String', 'Caption' => 'Telefón', 'Default' => ''),
15 //'ICQ' => array('Type' => 'String', 'Caption' => 'ICQ', 'Default' => ''),
16 ),
17 );
18 var $RegisterFormClass = array(
19 'Title' => 'Registrace uživatele',
20 'SubmitText' => 'Registrovat',
21 'Table' => 'User',
22 'Items' => array(
23 'Login' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => ''),
24 'Password' => array('Type' => 'Password', 'Caption' => 'Heslo', 'Default' => ''),
25 'Password2' => array('Type' => 'Password', 'Caption' => 'Potvrzení hesla', 'Default' => ''),
26 'Name' => array('Type' => 'String', 'Caption' => 'Zobrazované jméno', 'Default' => ''),
27 'Email' => array('Type' => 'String', 'Caption' => 'E-mail', 'Default' => ''),
28 //'PhoneNumber' => array('Type' => 'String', 'Caption' => 'Telefón', 'Default' => ''),
29 //'ICQ' => array('Type' => 'String', 'Caption' => 'ICQ', 'Default' => ''),
30 ),
31 );
32 var $PasswordRecoveryFormClass = array(
33 'Title' => 'Obnova hesla',
34 'SubmitText' => 'Obnovit',
35 'Table' => '',
36 'Items' => array(
37 'Name' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => ''),
38 'Email' => array('Type' => 'String', 'Caption' => 'E-mail', 'Default' => ''),
39 ),
40 );
41 var $LoginFormClass = array(
42 'Title' => 'Přihlášení uživatele',
43 'SubmitText' => 'Přihlásit',
44 'Table' => '',
45 'Items' => array(
46 'Username' => array('Type' => 'String', 'Caption' => 'Přihlašovací jméno', 'Default' => ''),
47 'Password' => array('Type' => 'Password', 'Caption' => 'Heslo', 'Default' => ''),
48 ),
49 );
50
51 function Login()
52 {
53 global $Config;
54
55 $Form = new Form($this->System, $this->LoginFormClass);
56 $Form->OnSubmit = '?Module=User&amp;Action=LoginFinish';
57 $Output = $Form->ShowEditForm();
58 $Output .= '<div class="Centred">';
59 if($Config['System']['UserRegistrationEnabled'])
60 $Output .= '<a href="?Module=User&amp;Action=Register">Registrovat se</a> ';
61 $Output .= '<a href="?Module=User&amp;Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
62 return($Output);
63 }
64
65 function LoginFinish()
66 {
67 $Form = new Form($this->System, $this->LoginFormClass);
68 $Form->OnSubmit = '?Module=User&amp;Action=LoginFinish';
69 $Form->LoadValuesFromForm();
70 $Result = $this->System->Modules['User']->Login($Form->Values['Username'], $Form->Values['Password']);
71 $Page = new PageView($this->System);
72 $Output = $Page->SystemMessage('Přihlášení', $Result);
73 if($Result <> $this->System->Translate('UserLoggedIn'))
74 {
75 $Form->Values['Password'] = '';
76 $Output .= $Form->ShowEditForm();
77 $Output .= '<div class="Centred"><a href="?Module=User&amp;Action=UserRegister">Registrovat se</a> '.
78 '<a href="?Module=User&amp;Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
79 }
80 return($Output);
81 }
82
83 function RegisterSave()
84 {
85 global $Config;
86
87 if($Config['System']['UserRegistrationEnabled'])
88 {
89 $Form = new Form($this->System, $this->RegisterFormClass, array());
90 $Form->LoadValuesFromForm();
91 $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']);
92 $Page = new PageView($this->System);
93 $Output = $Page->SystemMessage('Registrace nového účtu', $Result);
94 if($Result <> $this->System->Translate('UserRegistrated'))
95 {
96 $Form->OnSubmit = '?Module=User&amp;Action=UserRegisterSave';
97 $Output = $Form->ShowEditForm();
98 }
99 } else $Output = 'Registrace nových účtů nejsou povoleny.';
100 return($Output);
101 }
102
103 function PasswordRecoveryConfirm()
104 {
105 $Page = new PageView($this->System);
106 $Output = $Page->SystemMessage('Obnova hesla', $this->System->Modules['User']->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
107 $Output .= $this->LoginForm();
108 return($Output);
109 }
110
111 function PasswordRecoveryFinish()
112 {
113 $Form = new Form($this->System, $this->PasswordRecoveryFormClass);
114 $Form->LoadValuesFromForm();
115 $Result = $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
116 $Page = new PageView($this->System);
117 $Output = $Page->SystemMessage('Obnova hesla', $Result);
118 if($Result <> $this->System->Translate('UserPasswordRecoverySuccess'))
119 {
120 $Output .= $Form->ShowEditForm();
121 }
122 return($Output);
123 }
124
125 function PasswordRecovery()
126 {
127 $Form = new Form($this->System, $this->PasswordRecoveryFormClass);
128 $Form->OnSubmit = '?Module=User&amp;Action=PasswordRecovery2';
129 $Output = $Form->ShowEditForm();
130 return($Output);
131 }
132
133 function Logout()
134 {
135 $Page = new PageView($this->System);
136 $Output = $Page->SystemMessage('Odhlášení', $this->System->Modules['User']->Logout());
137 $Output .= $this->Login();
138 return($Output);
139 }
140
141 function Options()
142 {
143 $UserOptions = new Form($this->System, $this->OptionsFormClass);
144 $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
145 $UserOptions->OnSubmit = '?Module=User&amp;Action=UserOptionsSave';
146 $Output = $UserOptions->ShowEditForm();
147 return($Output);
148 }
149
150 function OptionsSave()
151 {
152 $UserOptions = new Form($this->System, $this->OptionsFormClass, array());
153 $UserOptions->LoadValuesFromForm();
154 $UserOptions->SaveValuesToDatabase($this->System->Modules['User']->User['Id']);
155 $Page = new PageView($this->System);
156 $Output = $Page->SystemMessage('Nastavení', 'Nastavení uloženo.');
157 $this->System->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $UserOptions->Values['Name']);
158 $UserOptions->LoadValuesFromDatabase($this->System->Modules['User']->User['Id']);
159 $UserOptions->OnSubmit = '?Module=User&amp;Action=UserOptionsSave';
160 $Output .= $UserOptions->ShowEditForm();
161 return($Output);
162 }
163
164 function Register()
165 {
166 global $Config;
167
168 if($Config['System']['UserRegistrationEnabled'])
169 {
170 $Form = new Form($this->System, $this->RegisterFormClass);
171 $Form->LoadValuesFromForm();
172 $Form->OnSubmit = '?Module=User&amp;Action=UserRegisterSave';
173 $Output = 'Vyplňte správně požadované údaje. Na zadaný email vám bude zaslán aktivační email.';
174 $Output .= $Form->ShowEditForm();
175 } else $Output = 'Registrace nových účtů nejsou povoleny.';
176 return($Output);
177 }
178
179 function RegisterConfirm()
180 {
181 global $Config;
182
183 if($Config['System']['UserRegistrationEnabled'])
184 {
185 $Page = new PageView($this->System);
186 $Output = $Page->SystemMessage('Potvrzení registrace', $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));
187 $Output .= $this->ShowLoginForm();
188 } else $Output = 'Registrace nových účtů nejsou povoleny.';
189 return($Output);
190 }
191}
Note: See TracBrowser for help on using the repository browser.