Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

user/useredit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: useredit.php 9518 2002-05-08 11:51:36Z vl $
5 //
6 // Created on: <10-Oct-2000 12:52:42 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 require( "kernel/ezuser/user/usercheck.php" );
28
29 // include_once( "classes/INIFile.php" );
30 // include_once( "classes/eztemplate.php" );
31 // include_once( "ezmail/classes/ezmail.php" );
32 // include_once( "classes/ezlog.php" );
33 // include_once( "classes/ezhttptool.php" );
34 // include_once( "classes/eztexttool.php" );
35
36
37 $ini =& eZINI::instance( 'site.ini' );
38 $Language = $ini->variable( "eZUserMain", "Language" );
39 $AnonymousUserGroup = $ini->variable( "eZUserMain", "AnonymousUserGroup" );
40
41 // include_once( "ezuser/classes/ezuser.php" );
42 // include_once( "ezuser/classes/ezusergroup.php" );
43
44 $user =& eZUser::currentUser();
45
46 if ( $Action == "Insert" )
47 {
48 // check for valid data
49 if ( $Login != "" &&
50 $Email != "" &&
51 $FirstName != "" &&
52 $LastName != "" )
53 {
54 $user = new eZUser();
55
56 if ( !$user->exists( $Login ) )
57 {
58 if ( ( $Password == $VerifyPassword ) && ( strlen( $VerifyPassword ) > 3 ) )
59 {
60 if ( eZMail::validate( $Email ) )
61 {
62 $user->setLogin( $Login );
63 $user->setPassword( $Password );
64 $user->setEmail( $Email );
65
66 if ( isset( $InfoSubscription ) && (string)$InfoSubscription == "on" )
67 $user->setInfoSubscription( true );
68 else
69 $user->setInfoSubscription( false );
70
71 $user->setFirstName( $FirstName );
72 $user->setLastName( $LastName );
73
74 $user->store();
75
76 if ( isset( $UserGroups ) )
77 {
78 if ( !is_array( $UserGroups ) )
79 $UserGroups = array( $UserGroups );
80 if ( $AppendAnon )
81 $UserGroups[] = $AnonymousUserGroup;
82 foreach ( $UserGroups as $groupid )
83 {
84 // add user to usergroups
85 setType( $groupid, "integer" );
86
87 $group = new eZUserGroup( $groupid );
88 $group->addUser( $user );
89 }
90 }
91 else
92 {
93 // add user to usergroup
94 setType( $AnonymousUserGroup, "integer" );
95
96 $group = new eZUserGroup( $AnonymousUserGroup );
97 $group->addUser( $user );
98 }
99
100 // log in the user
101 $user->loginUser( $user );
102
103 eZPBLog::writeNotice( "Anonyous user created: $FirstName $LastName ($Login) $Email from IP: $REMOTE_ADDR" );
104 eZPBLog::writeNotice( "User login: $Login from IP: $REMOTE_ADDR" );
105
106 $RedirectURL="/user/withaddress/";
107
108 if ( isSet( $RedirectURL ) && ( $RedirectURL != "" ) )
109 {
110 eZHTTPTool::header( "Location: $RedirectURL" );
111 exit();
112 }
113 else
114 {
115 $redirect = $ini->variable( "eZUserMain", "DefaultRedirect" );
116 eZHTTPTool::header( "Location: $redirect" );
117 exit();
118 }
119 }
120 else
121 {
122 $EmailError = true;
123 }
124 }
125 else
126 {
127 $PasswordError = true;
128 }
129 }
130 else
131 {
132 $UserExistsError = true;
133 }
134 }
135 else
136 {
137 $Error = true;
138 }
139 }
140
141 if ( $Action == "Update" )
142 {
143 $user =& eZUser::currentuser();
144 if ( !$user )
145 {
146 eZHTTPTool::header( "Location: /" );
147 exit();
148 }
149
150 if ( eZMail::validate( $Email ) )
151 {
152 $user->setEmail( $Email );
153 $user->setFirstName( $FirstName );
154 $user->setLastName( $LastName );
155
156 if ( isset( $InfoSubscription ) && (string)$InfoSubscription == "on" )
157 $user->setInfoSubscription( true );
158 else
159 $user->setInfoSubscription( false );
160
161 if ( isset( $Password ) && $Password )
162 {
163 if ( ( $Password == $VerifyPassword ) && ( strlen( $VerifyPassword ) > 3 ) )
164 {
165 if ( ( $Password != "dummy" ) )
166 {
167 $user->setPassword( $Password );
168 }
169 }
170 else
171 {
172 $PasswordError = true;
173 }
174 }
175 if ( isset( $PasswordError ) && $PasswordError == false )
176 {
177 $user->store();
178 }
179 }
180 else
181 {
182 $EmailError = true;
183 }
184
185 if ( $EmailError == false )
186 {
187 if ( isset( $Action ) && $Action == "Insert" || isset( $Action ) && $Action == "Update" )
188 {
189 if ( isset( $RedirectURL ) && ( $RedirectURL != "" ) )
190 {
191 eZHTTPTool::header( "Location: $RedirectURL" );
192 exit();
193 }
194 else
195 {
196 $redirect = $ini->variable( "eZUserMain", "DefaultRedirect" );
197 eZHTTPTool::header( "Location: $redirect" );
198 exit();
199 }
200
201 // $RedirectURL="/user/withaddress/";
202 // eZHTTPTool::header( "Location: /" );
203 exit();
204 }
205 }
206 }
207 $t = new eZTemplate( "kernel/ezuser/user/" . $ini->variable( "eZUserMain", "TemplateDir" ),
208 "kernel/ezuser/user/intl/", $Language, "useredit.php" );
209
210 $t->setAllStrings();
211
212 $t->set_file( "user_edit_tpl", "useredit.tpl" );
213 $t->set_block( "user_edit_tpl", "skip_link_tpl", "skip_link" );
214
215 /*
216 $t->set_file( array(
217 "user_edit_tpl" => "useredit.tpl"
218 ) );
219 */
220
221 if ( !isset( $ModuleName ) )
222 $ModuleName = "user";
223 if ( !isset( $ModuleUserNew ) )
224 $ModuleUserNew = "user";
225
226 $headline = new eZINI( "kernel/ezuser/user/intl/" . $Language . "/useredit.php.ini", false );
227 $t->set_var( "head_line", $headline->variable( "strings", "head_line_insert" ) );
228
229 if ($Action == "New") {
230 $t->set_var( "user_alert_message", $headline->variable( "strings", "user_alert_message" ) );
231 $t->set_var( "user_address_alert_message", "" );
232 $t->set_var( "skip_link", "" );
233 } else {
234 $t->set_var( "user_alert_message", "" );
235 $t->set_var( "user_address_alert_message", "" );
236 $t->set_var( "skip_link", "" );
237 }
238
239 $t->set_var( "module", $ModuleName );
240 $t->set_var( "user_new", $ModuleUserNew );
241
242 $actionValue = "insert";
243
244 if ( isset( $Action ) && $Action == "Edit" )
245 {
246 $user =& eZUser::currentuser();
247 if ( !$user )
248 {
249 eZHTTPTool::header( "Location: /" );
250 exit();
251 }
252 if ( !isset( $UserID ) )
253 {
254 $getUser =& eZUser::currentUser();
255 if ( !$getUser )
256 {
257 eZHTTPTool::header( "Location: /user/login" );
258 exit();
259 }
260 else
261 {
262 $UserID = $getUser->id();
263 }
264 }
265
266 /*
267 if ( $InfoSubscription == "on" )
268 $user->setInfoSubscription( true );
269 else
270 $user->setInfoSubscription( false );
271 */
272
273 if( $user->infoSubscription() )
274 $InfoSubscription = "checked";
275 else
276 $InfoSubscription = "";
277
278 $Login = $user->login();
279 $Email = $user->email();
280 $FirstName = $user->firstName();
281 $LastName = $user->lastName();
282 $Password = "dummy";
283 $VerifyPassword = "dummy";
284 $t->set_var( "read_only", "readonly=readonly" );
285 $actionValue = "update";
286 $headline = new eZINI( "kernel/ezuser/user/intl/" . $Language . "/useredit.php.ini", false );
287 $t->set_var( "head_line", $headline->variable( "strings", "head_line_edit" ) );
288 }
289
290 $t->set_block( "user_edit_tpl", "required_fields_error_tpl", "required_fields_error" );
291 $t->set_block( "user_edit_tpl", "user_exists_error_tpl", "user_exists_error" );
292 $t->set_block( "user_edit_tpl", "password_error_tpl", "password_error" );
293 $t->set_block( "user_edit_tpl", "email_error_tpl", "email_error" );
294
295 $t->set_block( "user_edit_tpl", "login_edit_tpl", "login_edit" );
296 $t->set_block( "user_edit_tpl", "login_view_tpl", "login_view" );
297
298 $t->set_var( "login_edit", "" );
299 $t->set_var( "login_view", "" );
300
301 if ( isset( $Action ) && $Action != "Edit" )
302 {
303 $t->parse( "login_edit", "login_edit_tpl" );
304 }
305 else
306 {
307 $t->parse( "login_view", "login_view_tpl" );
308 }
309
310 if ( isset( $Error ) && $Error == true )
311 {
312 $t->parse( "required_fields_error", "required_fields_error_tpl" );
313 }
314 else
315 {
316 $t->set_var( "required_fields_error", "" );
317 }
318
319 if ( isset( $UserExistsError ) && $UserExistsError == true )
320 {
321 $t->parse( "user_exists_error", "user_exists_error_tpl" );
322 }
323 else
324 {
325 $t->set_var( "user_exists_error", "" );
326 }
327
328 if ( isset( $PasswordError ) && $PasswordError == true )
329 {
330 $t->parse( "password_error", "password_error_tpl" );
331 }
332 else
333 {
334 $t->set_var( "password_error", "" );
335 }
336
337 if ( isset( $EmailError ) && $EmailError == true )
338 {
339 $t->parse( "email_error", "email_error_tpl" );
340 }
341 else
342 {
343 $t->set_var( "email_error", "" );
344 }
345
346 $t->set_var( "user_id", isset( $UserID ) ? $UserID : false );
347 $t->set_var( "login_value", isset( $Login ) ? $Login : false );
348 $t->set_var( "password_value", isset( $Password ) ? $Password : false );
349 $t->set_var( "verify_password_value", isset( $VerifyPassword ) ? $VerifyPassword : false );
350 $t->set_var( "email_value", isset( $Email ) ? $Email : false );
351 $t->set_var( "info_subscription", isset( $InfoSubscription ) ? $InfoSubscription : false );
352
353 $t->set_var( "first_name_value", isset( $FirstName ) ? $FirstName : false );
354 $t->set_var( "last_name_value", isset( $LastName ) ? $LastName : false );
355
356 $t->set_var( "action_value", $actionValue );
357
358 if ( isset( $RedirectURL ) && ( $RedirectURL != "" ) )
359 {
360 $t->set_var( "redirect_url", eZTextTool::htmlspecialchars( $RedirectURL ) );
361 }
362 else
363 {
364 $RedirectURL = $ini->variable( "eZUserMain", "DefaultRedirect" );
365 $t->set_var( "redirect_url", eZTextTool::htmlspecialchars( $RedirectURL ) );
366 }
367
368 $t->pparse( "output", "user_edit_tpl" );
369
370 ?>
$group
$group
Definition: admin/articleedit.php:799
$Password
$Password
Definition: admin/seti.php:21
$Email
$Email
Definition: admin/useredit.php:414
$LastName
$LastName
Definition: admin/useredit.php:416
$FirstName
$FirstName
Definition: admin/useredit.php:415
$InfoSubscription
$InfoSubscription
Definition: admin/useredit.php:419
$Login
$Login
Definition: admin/useredit.php:445
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZMail\validate
static validate( $address)
Definition: ezmail.php:599
eZPBLog\writeNotice
static writeNotice( $notice)
Definition: ezpblog.php:166
eZTemplate
Definition: eztemplate.php:107
eZTextTool\htmlspecialchars
static htmlspecialchars( $string)
Definition: eztexttool.php:144
eZUserGroup
Definition: ezusergroup.php:66
eZUser
Definition: ezuser.php:76
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$Action
$Action
Definition: companysearch.php:80
$ModuleName
$ModuleName
Definition: ezarticle/user/searchsupplier.php:30
$Error
if(isset( $EditButton)) if(!empty( $CancelButton)) if(!empty( $PreviewButton)) if( $Action=="preview") switch( $Action) $Error
Definition: ezforum/user/messageedit.php:134
$RedirectURL
$RedirectURL
Definition: ezforum/user/userlogin.php:91
exit
exit
Definition: folder.php:81
$UserID
$UserID
Definition: todoedit.php:122
$redirect
$redirect
Definition: todoedit.php:100
$AnonymousUserGroup
$AnonymousUserGroup
Definition: user/useredit.php:39
$actionValue
$actionValue
Definition: user/useredit.php:242
$user
$user
Definition: user/useredit.php:44
$headline
$headline
Definition: user/useredit.php:226
$Language
$Language
Definition: user/useredit.php:38
$ini
$ini
Definition: user/useredit.php:37
$t
if( $Action=="Insert") if( $Action=="Update") $t
Definition: user/useredit.php:207
$VerifyPassword
if(( $ForceSSL=="enabled")) elseif( $ForceSSL=="disabled") $VerifyPassword
Definition: userwithaddress.php:76
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.