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