Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

userwithaddress.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: userwithaddress.php 9662 2002-07-08 15:16:41Z bf $
5 //
6 // Created on: <10-ct-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( "classes/ezhttptool.php" );
32 // include_once( "ezsession/classes/ezsession.php" );
33 // include_once( "classes/eztexttool.php" );
34
35 $ini =& eZINI::instance( 'site.ini' );
36 $Language = $ini->variable( "eZUserMain", "Language" );
37 $SelectCountry = $ini->variable( "eZUserMain", "SelectCountry" );
38 $SelectRegion = $ini->variable( "eZUserMain", "SelectRegion" );
39 $AnonymousUserGroup = $ini->variable( "eZUserMain", "AnonymousUserGroup" );
40 $ForceSSL = $ini->variable( "eZUserMain", "ForceSSL" );
41 $AutoCookieLogin = eZHTTPTool::getVar( "AutoCookieLogin" );
42
43 $session =& eZSession::globalSession();
44
45 // include_once( "ezuser/classes/ezuser.php" );
46 // include_once( "ezuser/classes/ezusergroup.php" );
47 // include_once( "ezaddress/classes/ezaddress.php" );
48 // include_once( "ezaddress/classes/ezcountry.php" );
49 // include_once( "ezmail/classes/ezmail.php" );
50
51 $user =& eZUser::currentUser();
52
53 // set SSL mode and redirect if not already in SSL mode.
54 if ( ( $ForceSSL == "enabled" ) )
55 {
56 // force SSL if supposed to
57 if ( $SERVER_PORT != '443' )
58 {
59 $session->setVariable( "SSLMode", "enabled" );
60 eZHTTPTool::header("Location: https://" . $HTTP_HOST . $REQUEST_URI );
61 // eZHTTPTool::header("Location: https://" . $HTTP_HOST . "/user/userwithaddress/edit/" . $user->id() );
62 // print( "<font color=\"#333333\">Start: Location: https://" . $HTTP_HOST . $REQUEST_URI . "</font>" );
63 exit();
64 }
65 }
66 elseif ( $ForceSSL == "disabled" )
67 {
68 if ( $SERVER_PORT == '443' )
69 {
70 $session->setVariable( "SSLMode", "disabled" );
71 eZHTTPTool::header("Location: http://" . $HTTP_HOST . "/user/userwithaddress/edit/" . $user->id() );
72 exit();
73 }
74 }
75
76 $VerifyPassword = eZHTTPTool::getVar( "VerifyPassword" );
77 $Password = eZHTTPTool::getVar( "Password" );
78 $Email = eZHTTPTool::getVar( "Email" );
79 $Login = eZHTTPTool::getVar( "Login" );
80 $FirstName = eZHTTPTool::getVar( "FirstName" );
81 $LastName = eZHTTPTool::getVar( "LastName" );
82
83 $t = new eZTemplate( "kernel/ezuser/user/" . $ini->variable( "eZUserMain", "TemplateDir" ),
84 "kernel/ezuser/user/intl/", $Language, "userwithaddress.php" );
85
86 $t->setAllStrings();
87
88 $t->set_file( "user_edit_tpl", "userwithaddress.tpl" );
89
90 $t->set_block( "user_edit_tpl", "required_fields_error_tpl", "required_fields_error" );
91 $t->set_block( "user_edit_tpl", "user_exists_error_tpl", "user_exists_error" );
92 $t->set_block( "user_edit_tpl", "password_error_tpl", "password_error" );
93 $t->set_block( "user_edit_tpl", "missing_address_error_tpl", "missing_address_error" );
94 $t->set_block( "user_edit_tpl", "address_actions_tpl", "address_actions" );
95
96 $t->set_block( "user_edit_tpl", "address_tpl", "address" );
97 $t->set_block( "address_tpl", "main_address_tpl", "main_address" );
98 $t->set_block( "address_tpl", "delete_address_tpl", "delete_address" );
99 $t->set_block( "address_tpl", "country_tpl", "country" );
100 $t->set_block( "country_tpl", "country_option_tpl", "country_option" );
101
102 $t->set_block( "address_tpl", "region_tpl", "region" );
103 $t->set_block( "region_tpl", "region_option_tpl", "region_option" );
104
105 $t->set_block( "user_edit_tpl", "errors_item_tpl", "errors_item" );
106 $t->set_var( "errors_item", "" );
107
108 $t->set_block( "user_edit_tpl", "login_item_tpl", "login_item" );
109 $t->set_block( "user_edit_tpl", "disabled_login_item_tpl", "disabled_login_item" );
110
111 // Info templates
112 $t->set_block( "user_edit_tpl", "info_item_tpl", "info_item" );
113 $t->set_block( "info_item_tpl", "info_updated_tpl", "info_updated" );
114
115 // Error templates
116 $t->set_block( "errors_item_tpl", "error_login_tpl", "error_login" );
117 $t->set_block( "errors_item_tpl", "error_login_exists_tpl", "error_login_exists" );
118 $t->set_block( "errors_item_tpl", "error_first_name_tpl", "error_first_name" );
119 $t->set_block( "errors_item_tpl", "error_last_name_tpl", "error_last_name" );
120 $t->set_block( "errors_item_tpl", "error_email_tpl", "error_email" );
121 $t->set_block( "errors_item_tpl", "error_email_not_valid_tpl", "error_email_not_valid" );
122 $t->set_block( "errors_item_tpl", "error_password_match_tpl", "error_password_match" );
123 $t->set_block( "errors_item_tpl", "error_password_too_short_tpl", "error_password_too_short" );
124 $t->set_block( "errors_item_tpl", "error_password_not_entered_tpl", "error_password_not_entered" );
125
126 $t->set_block( "errors_item_tpl", "error_address_street1_tpl", "error_address_street1" );
127 $t->set_block( "errors_item_tpl", "error_address_street2_tpl", "error_address_street2" );
128 $t->set_block( "errors_item_tpl", "error_address_zip_tpl", "error_address_zip" );
129 $t->set_block( "errors_item_tpl", "error_address_place_tpl", "error_address_place" );
130
131 $t->set_block( "errors_item_tpl", "error_missing_address_tpl", "error_missing_address" );
132 $t->set_block( "errors_item_tpl", "error_missing_country_tpl", "error_missing_country" );
133
134 $t->set_block( "errors_item_tpl", "error_missing_region_tpl", "error_missing_region" );
135
136 $t->set_block( "user_edit_tpl", "new_user_tpl", "new_user" );
137 $t->set_block( "user_edit_tpl", "edit_user_tpl", "edit_user" );
138 $t->set_block( "user_edit_tpl", "edit_user_info_tpl", "edit_user_info" );
139
140 $t->set_block( "user_edit_tpl", "ok_button_tpl", "ok_button" );
141 $t->set_block( "user_edit_tpl", "submit_button_tpl", "submit_button" );
142
143 $t->set_var( "error_login", "" );
144 $t->set_var( "error_login_exists", "" );
145 $t->set_var( "error_first_name", "" );
146 $t->set_var( "error_last_name", "" );
147 $t->set_var( "error_email", "" );
148 $t->set_var( "error_email_not_valid", "" );
149 $t->set_var( "error_password_match", "" );
150 $t->set_var( "error_password_too_short", "" );
151 $t->set_var( "error_password_not_entered", "" );
152 $t->set_var( "error_missing_country", "" );
153
154 $t->set_var( "error_address_place", "" );
155 $t->set_var( "error_address_zip", "" );
156 $t->set_var( "error_address_street1", "" );
157 $t->set_var( "error_address_street2", "" );
158
159 $t->set_var( "first_name_value", "$FirstName" );
160 $t->set_var( "last_name_value", "$LastName" );
161 $t->set_var( "login_value", "$Login" );
162 $t->set_var( "email_value", "$Email" );
163 $t->set_var( "password_value", "$Password" );
164 $t->set_var( "verify_password_value", "$VerifyPassword" );
165 $t->set_var( "address_actions", "" );
166
167
168 $t->set_var( "back_url", "/user/edit" );
169 $t->set_var( "skip_url", "/user/account" );
170
171 if ( $AutoCookieLogin == "on" )
172 {
173 $t->set_var( "is_cookie_selected", "checked" );
174 }
175
176 if( isset($NoAddress) && $NoAddress == true )
177 {
178 $t->set_var( "no_address", "no" );
179 }
180 else
181 {
182 $t->set_var( "no_address", "" );
183 }
184
185 $user =& eZUser::currentUser();
186
187 $t->set_var( "ok_button", "" );
188 $t->set_var( "submit_button", "" );
189 $t->set_var( "new_user", "" );
190 $t->set_var( "edit_user", "" );
191 $t->set_var( "edit_user_info", "" );
192 if ( is_a( $user, "eZUser" ) )
193 {
194 $t->parse( "submit_button", "submit_button_tpl" );
195 $t->parse( "edit_user", "edit_user_tpl" );
196 $t->parse( "edit_user_info", "edit_user_info_tpl" );
197 }
198 else
199 {
200 $t->parse( "ok_button", "ok_button_tpl" );
201 $t->parse( "new_user", "new_user_tpl" );
202 }
203
204 // Defaults
205 $user_insert = false;
206 $Signature = '';
207 // Set error checking.
208 $error = false;
209 $nameCheck = true;
210 $emailCheck = true;
211 $firstNameCheck = true;
212 $lastNameCheck = true;
213 $loginCheck = true;
214 $passwordCheck = true;
215 $street1Check = true;
216 $street2Check = false;
217 $zipCheck = true;
218 $placeCheck = true;
219 $addressCheck = true;
220 $realAddressID = array();
221 $RealAddressID = array();
222
223 // If the user is trying to buy without having a address
224 if ( isset( $MissingAddress ) && $MissingAddress == true )
225 {
226 $t->parse( "error_missing_address", "error_missing_address_tpl" );
227
228 $t->parse( "errors_item", "errors_item_tpl" );
229
230 $t->set_var( "action_value", "update" );
231 }
232 else
233 {
234 $t->set_var( "error_missing_address", "" );
235 $t->set_var( "action_value", "update" );
236 }
237
238 // If the user is trying to buy without having a address
239 if ( isset( $MissingCountry ) && $MissingCountry == true )
240 {
241 $t->parse( "error_missing_country", "error_missing_country_tpl" );
242
243 $t->parse( "errors_item", "errors_item_tpl" );
244
245 $t->set_var( "action_value", "update" );
246 }
247 else
248 {
249 $t->set_var( "error_missing_country", "" );
250 $t->set_var( "action_value", "update" );
251 }
252 // If the user is trying to buy without having a address
253 if ( isset( $MissingRegion ) && $MissingRegion == true )
254 {
255 $t->parse( "error_missing_region", "error_missing_region_tpl" );
256
257 $t->parse( "errors_item", "errors_item_tpl" );
258
259 $t->set_var( "action_value", "update" );
260 }
261 else
262 {
263 $t->set_var( "error_missing_region", "" );
264 $t->set_var( "action_value", "update" );
265 }
266 // Check for errors when inserting, updating and inserting a new address
267 if ( isset( $OK ) or isset( $OK_x ) )
268 {
269 if ( $loginCheck )
270 {
271 if ( !is_a( $user, "eZUser" ) and $Login == "" )
272 {
273 $t->parse( "error_login", "error_login_tpl" );
274 $error = true;
275 }
276 else if ( !is_a( $user, "eZUser" ) )
277 {
278 if ( eZUser::exists( $Login ) == true )
279 {
280 $t->parse( "error_login_exists", "error_login_exists_tpl" );
281 $error = true;
282 }
283 }
284 }
285
286 if ( $firstNameCheck and $FirstName == "" )
287 {
288 $t->parse( "error_first_name", "error_first_name_tpl" );
289 $error = true;
290 }
291
292 if ( $lastNameCheck and $LastName == "" )
293 {
294 $t->parse( "error_last_name", "error_last_name_tpl" );
295 $error = true;
296 }
297
298 if ( $emailCheck )
299 {
300 if( $Email == "" )
301 {
302 $t->parse( "error_email", "error_email_tpl" );
303 $error = true;
304 }
305 else
306 {
307 if( eZMail::validate( $Email ) == false )
308 {
309 $t->parse( "error_email_not_valid", "error_email_not_valid_tpl" );
310 $error = true;
311 }
312 }
313 }
314
315 if ( $passwordCheck )
316 {
317 if ( $Password != $VerifyPassword )
318 {
319 $t->parse( "error_password_match", "error_password_match_tpl" );
320 $error = true;
321
322 }
323 if ( strlen( $VerifyPassword ) < 2 )
324 {
325 $t->parse( "error_password_too_short", "error_password_too_short_tpl" );
326 $error = true;
327 }
328 //if ( $Password == "dummy" or $VerifyPassword == "dummy" )
329 //{
330 // $t->parse( "error_password_not_entered", "error_password_not_entered_tpl" );
331 // $error = true;
332 //}
333 }
334 if ( $addressCheck )
335 {
336 if( !isset( $AddressID ) )
337 $AddressID = array();
338
339 for( $i=0; $i < count ( $AddressID ); $i++ )
340 {
341 if ( $ini->variable( "eZUserMain", "RequireAddress" ) == "enabled" )
342 {
343 if ( count( $AddressID ) == 0 )
344 {
345 $t->parse( "error_missing_address", "error_missing_address_tpl" );
346 $error = true;
347 }
348 }
349
350 if ( $street1Check )
351 {
352 if ( $Street1[$i] == "" )
353 {
354 $t->parse( "error_address_street1", "error_address_street1_tpl" );
355 $error = true;
356 }
357 }
358
359 if ( $street2Check )
360 {
361 if ( $Street2[$i] == "" )
362 {
363 $t->parse( "error_address_street2", "error_address_street2_tpl" );
364 $error = true;
365 }
366 }
367
368 if ( $zipCheck )
369 {
370 if ( $Zip[$i] == "" )
371 {
372 $t->parse( "error_address_zip", "error_address_zip_tpl" );
373 $error = true;
374 }
375 }
376
377 if ( $placeCheck )
378 {
379 if ( $Place[$i] == "" )
380 {
381 $t->parse( "error_address_place", "error_address_place_tpl" );
382 $error = true;
383 }
384 }
385 }
386 }
387
388 if( $error == true )
389 {
390 $t->parse( "errors_item", "errors_item_tpl" );
391 }
392 }
393 else
394 {
395 $Password = false;
396 $VerifyPassword = false;
397 }
398
399 // Add a new address
400 if ( isset( $NewAddress ) )
401 {
402 if ( !isset( $AddressID ) )
403 $AddressID = array();
404
405 if ( !isset( $CountryID ) )
406 $CountryID = array();
407
408 if ( !isset( $RegionID ) )
409 $RegionID = array();
410
411 if ( count( $AddressID ) > 0 )
412 $AddressID[] = $AddressID[count( $AddressID ) - 1] + 1;
413 else
414 $AddressID = array( 1 );
415 $Street1[] = "";
416 $Street2[] = "";
417 $Zip[] = "";
418 $Phone[] = "";
419 $Place[] = "";
420 $country_id = $ini->variable( "eZUserMain", "DefaultCountry" );
421 if ( count( $CountryID ) > 0 and is_numeric( $CountryID[count( $CountryID ) - 1] ) )
422 $CountryID[] = $CountryID[count( $CountryID ) - 1];
423 else
424 $CountryID[] = $country_id;
425
426 $region_id = $ini->variable( "eZUserMain", "DefaultRegion" );
427
428 if ( count( $RegionID ) > 0 and is_numeric( $RegionID[count($RegionID)-1] ) )
429 $RegionID[] = $RegionID[count($RegionID)-1];
430 else
431 $RegionID[] = $region_id;
432
433 if ( !isset( $MainAddressID ) && isset( $RealAddressID[0] ) && count( $AddressID ) > 0 )
434 $MainAddressID = $RealAddressID[0];
435 }
436
437 // Insert a user with address
438 if ( ( isset( $OK ) or isset( $OK_x ) ) and $error == false )
439 {
440 $new_user = false;
441 if ( !is_a( $user, "eZUser" ) )
442 $new_user = true;
443
444 if ( $new_user )
445 {
446 $user_insert = new eZUser();
447 $user_insert->setLogin( $Login );
448 }
449 else
450 {
451 $user_insert = $user;
452 }
453
454 if ( $new_user or $Password != "dummy" )
455 $user_insert->setPassword( $Password );
456
457 $user_insert->setEmail( $Email );
458 $user_insert->setFirstName( $FirstName );
459 $user_insert->setLastName( $LastName );
460 $user_insert->setSignature( $Signature );
461
462 if ( isset( $InfoSubscription ) && (string)$InfoSubscription == "on" )
463 $user_insert->setInfoSubscription( true );
464 else
465 $user_insert->setInfoSubscription( false );
466
467 if ( $AutoCookieLogin == "on" )
468 $user_insert->setCookieLogin( true );
469 else
470 $user_insert->setCookieLogin( false );
471
472 $user_insert->store();
473
474 // Does only need to add the user to the anonymous group if
475 // it is a new user
476 if ( $new_user )
477 {
478 setType( $AnonymousUserGroup, "integer" );
479 $group = new eZUserGroup( $AnonymousUserGroup );
480 $group->addUser( $user_insert );
481 $user_insert->setGroupDefinition( $group );
482 }
483
484 if ( !isset( $MainAddressID ) )
485 {
486 $mainAddress = eZAddress::mainAddress( $user );
487
488 if ( $mainAddress )
489 $MainAddressID = $mainAddress->id();
490 }
491
492 if ( !isset( $MainAddressID ) && count( $AddressID ) > 0 )
493 $MainAddressID = $AddressID[0];
494
495 // if ( !$new_user )
496 // $user_insert->removeAddresses();
497
498 for ( $i = 0; $i < count( $AddressID ); ++$i )
499 {
500 $address_id = $AddressID[$i];
501
502 if( isset( $_REQUEST["RealAddressID[$i]"] ) )
503 $realAddressID = $_REQUEST["RealAddressID[$i]"];
504 else
505 $realAddressID = false;
506
507 $address = new eZAddress();
508 if ( !$address->get( $realAddressID ) )
509 {
510 $address = new eZAddress();
511 }
512
513 $address->setStreet1( $Street1[$i] );
514 $address->setStreet2( $Street2[$i] );
515 $address->setZip( $Zip[$i] );
516 $address->setPhone( $Phone[$i] );
517 $address->setPlace( $Place[$i] );
518
519 if ( $SelectCountry == "enabled" and isset( $CountryID[$i] ) )
520 {
521 $address->setCountry( $CountryID[$i] );
522 }
523 else
524 {
525 $CountryID = $ini->variable( "eZUserMain", "DefaultCountry" );
526 $address->setCountry( $CountryID );
527 }
528
529 if ( $SelectRegion == "enabled" and isset( $RegionID[$i] ) )
530 {
531 $address->setRegion( $RegionID[$i] );
532 }
533 else
534 {
535 $RegionID = $ini->variable( "eZUserMain", "DefaultRegion" );
536 $address->setRegion( $RegionID );
537 }
538
539 $address->store();
540
541 // set correct ID
542 if ( !is_numeric( $realAddressID ) )
543 $RealAddressID[$i] = $address->id();
544
545 //if ( $MainAddressID == $RealAddressID[$i] )
546 $main_id = $MainAddressID;
547
548 if ( count ( $AddressID ) == 1 )
549 $main_id = $address->id();
550
551 // add address if new
552 if ( !is_numeric( $realAddressID ) )
553 $user_insert->addAddress( $address );
554 }
555
556 if ( count( $AddressID ) > 0 )
557 eZAddress::setMainAddress( $main_id, $user_insert );
558
559 $user_insert->loginUser( $user_insert );
560
561 if ( $user_insert->cookieLogin() == true )
562 {
563 $user_insert->setCookieValues();
564 }
565
566 if ( !$new_user )
567 $Updated = true;
568
569 // if( $RedirectURL == "" )
570 // $RedirectURL = $REQUEST_URI;
571 if( $RedirectURL == "" )
572 {
573 // $RedirectURL = $session->variable( "RedirectURL" );
574 $RedirectURL = "/user/account/";
575 }
576 if ( isset( $RedirectURL ) && ( $RedirectURL != "" ) )
577 {
578 $session->setVariable( "RedirectURL", "$RedirectURL" );
579 eZHTTPTool::header( "Location: $RedirectURL" );
580 exit();
581 }
582 if ( !is_a( $user, "eZUser" ) )
583 {
584 eZHTTPTool::header( "Location: /" );
585 exit();
586 }
587 }
588
589 $info_array = array();
590 $t->set_var( "info_item", "" );
591 if ( isset( $Updated ) )
592 {
593 $info_array[] = "info_updated";
594 }
595
596 if ( count( $info_array ) > 0 )
597 {
598 foreach( $info_array as $info )
599 {
600 $t->parse( $info, $info . "_tpl" );
601 }
602 $t->parse( "info_item", "info_item_tpl" );
603 }
604
605 $t->set_var( "readonly", "" );
606 $cookieCheck = "";
607
608 if ( is_a( $user_insert, "eZUser" ) )
609 $user = $user_insert;
610
611 // Fill in variables which are not set for current user,
612 // this is done the first the page loads
613 if ( is_a( $user, "eZUser" ) )
614 {
615 if ( !isset( $UserID ) )
616 $UserID = $user->id();
617 if ( !isset( $Login ) )
618 $Login = $user->Login();
619 if ( !isset( $Email ) )
620 $Email = $user->Email();
621 if ( !isset( $FirstName ) )
622 $FirstName = $user->FirstName();
623 if ( !isset( $LastName ) )
624 $LastName = $user->LastName();
625
626 $cookieCheck = "";
627 if ( $user->cookieLogin() == true )
628 {
629 $cookieCheck = "checked";
630 }
631 else
632 {
633 }
634
635 if ( !isset( $AddressID ) )
636 {
637 if ( !isset( $AddressID ) )
638 $AddressID = array();
639 if ( !isset( $Street1 ) )
640 $Street1 = array();
641 if ( !isset( $Street2 ) )
642 $Street2 = array();
643 if ( !isset( $Zip ) )
644 $Zip = array();
645 if ( !isSet( $Phone ) )
646 $Phone = array();
647 if ( !isSet( $Place ) )
648 $Place = array();
649 if ( !isset( $CountryID ) )
650 $CountryID = array();
651
652 if ( !isset( $RegionID ) )
653 $RegionID = array();
654 $mainAddress = eZAddress::mainAddress( $user );
655
656 $addressArray = $user->addresses();
657
658 $i = 0;
659 foreach ( $addressArray as $address )
660 {
661 if ( ( is_a( $mainAddress, "eZAddress" ) ) and ( $address->id() == $mainAddress->id() ) and !isset( $MainAddressID ) )
662 {
663 // $MainAddressID = $i + 1;
664 $MainAddressID = $address->id();
665 }
666 if ( !isset( $AddressID[$i] ) )
667 $AddressID[$i] = $i + 1;
668 if ( !isset( $RealAddressID[$i] ) )
669 $RealAddressID[$i] = $address->id();
670 if ( !isset( $Street1[$i] ) )
671 $Street1[$i] = $address->street1();
672 if ( !isset( $Street2[$i] ) )
673 $Street2[$i] = $address->street2();
674 if ( !isset( $Zip[$i] ) )
675 $Zip[$i] = $address->zip();
676 if ( !isset( $Phone[$i] ) )
677 $Phone[$i] = $address->phone();
678 if ( !isSet( $Place[$i] ) )
679 $Place[$i] = $address->place();
680 if ( !isset( $CountryID[$i] ) )
681 {
682 $country = $address->country();
683 if ( $country )
684 {
685 $CountryID[$i] = $country->id();
686 }
687 }
688
689 if ( !isset( $RegionID[$i] ) )
690 {
691 $region = $address->region();
692 if ( $region )
693 { // region object does not return region objects just id, feature addition,
694 // but only cause i hacked it for testing. badd comment!.
695 $RegionID[$i] = $region->id();
696 // $RegionID[$i] = $region;
697 }
698 }
699 ++$i;
700 }
701 }
702
703 $t->set_var( "first_name_value", $FirstName );
704 $t->set_var( "last_name_value", $LastName );
705 $t->set_var( "login_value", $Login );
706 $t->set_var( "email_value", $Email );
707 $t->set_var( "password_value", $Password );
708 $t->set_var( "verify_password_value", $VerifyPassword );
709 $t->set_var( "address_actions", "" );
710 }
711 else
712 {
713 $UserID = false;
714 // $LastName = false;
715 // $FirstName = false;
716 // $Login = false;
717 // $Email = false;
718
719 if ( $ini->variable( "eZUserMain", "RequireFirstAddress" ) == "enabled" )
720 {
721 if ( !isset( $AddressID ) )
722 $AddressID = array( 1 );
723 if ( !isset( $Street1 ) )
724 $Street1 = array( "" );
725 if ( !isset( $Street2 ) )
726 $Street2 = array( "" );
727 if ( !isset( $Zip ) )
728 $Zip = array( "" );
729 if ( !isset( $Place ) )
730 $Place = array( "" );
731 if ( !isset( $CountryID ) )
732 $CountryID = array( $ini->variable( "eZUserMain", "DefaultCountry" ) );
733 if ( !isset( $RegionID ) )
734 $RegionID = array( $ini->variable( "eZUserMain", "DefaultRegion" ) );
735 if ( !isset( $MainAddressID ) )
736 {
737 $MainAddressID = 1;
738 }
739 }
740 else
741 {
742 if ( !isset( $AddressID ) )
743 $AddressID = array();
744 }
745 }
746
747 if ( !isset( $DeleteAddressArrayID ) )
748 $DeleteAddressArrayID = array();
749
750 $t->set_var( "login_value", $Login );
751 $t->set_var( "disabled_login_item", "" );
752 $t->set_var( "login_item", "" );
753 if ( is_a( $user, "eZUser" ) )
754 {
755 $t->parse( "disabled_login_item", "disabled_login_item_tpl" );
756 }
757 else
758 {
759 $t->parse( "login_item", "login_item_tpl" );
760 }
761
762 if ( is_a( $user, "eZUser" ) and $Password == "" )
763 $Password = "dummy";
764 if ( is_a( $user, "eZUser" ) and $VerifyPassword == "" )
765 $VerifyPassword = "dummy";
766
767 $t->set_var( "password_value", $Password );
768 $t->set_var( "verify_password_value", $VerifyPassword );
769 $t->set_var( "email_value", $Email );
770
771 $t->set_var( "first_name_value", $FirstName );
772 $t->set_var( "last_name_value", $LastName );
773 $t->set_var( "is_cookie_selected", "$cookieCheck" );
774
775 if( ( is_a( $user, "eZUser" ) ) and $user->infoSubscription() == true )
776 $InfoSubscription = "checked";
777 else
778 $InfoSubscription = "";
779
780 $t->set_var( "info_subscription", $InfoSubscription );
781
782 if ( is_a( $user, "eZUser" ) )
783 $t->set_var( "readonly", "disabled" );
784
785 $t->set_var( "address", "" );
786
787 if ( $SelectCountry == "enabled" )
788 $countryList =& eZCountry::getAllArray();
789
790 if ( $SelectRegion == "enabled" )
791 $regionList =& eZRegion::getAllArray();
792
793 // Make sure the MainAddressID is set to something sensible
794 $deleted = false;
795 for ( $i = 0; $i < count( $AddressID ); ++$i )
796 {
797 $address_id = $AddressID[$i];
798 $variable = "DeleteAddressButton$address_id";
799 if ( in_array( $AddressID[$i], $DeleteAddressArrayID ) or isset( $$variable ) )
800 {
801 if ( $RealAddressID[$i] == $MainAddressID )
802 {
803 $deleted = true;
804 }
805 }
806 }
807
808 if ( $deleted )
809 {
810 for ( $i = 0; $i < count( $AddressID ); ++$i )
811 {
812 $address_id = $AddressID[$i];
813 $variable = "DeleteAddressButton$address_id";
814 if ( !in_array( $AddressID[$i], $DeleteAddressArrayID ) and !isset( $$variable ) )
815 {
816 $MainAddressID = $RealAddressID[$i];
817 break;
818 }
819 }
820 }
821
822 // Check if we will add delete buttons
823 $checkArray = array_diff( $AddressID, $DeleteAddressArrayID );
824 if ( count ( $checkArray ) == 1 )
825 {
826 $t->set_var( "delete_address", "" );
827 $t->set_var( "main_address", "" );
828 }
829 else
830 {
831 $t->parse( "main_address", "main_address_tpl" );
832 $t->parse( "delete_address", "delete_address_tpl" );
833 }
834
835
836 if ( count( $DeleteAddressArrayID ) )
837 {
838 // delete addresses
839 foreach ( $DeleteAddressArrayID as $aid )
840 {
841 $delete_address = new eZAddress( $RealAddressID[$aid-1] );
842 if ( $user )
843 $user->removeAddress( $delete_address );
844 }
845 }
846
847 // Render addresses
848 if ( $ini->variable( "eZUserMain", "UserWithAddress" ) == "enabled" )
849 {
850 for ( $i = 0; $i < count( $AddressID ); ++$i )
851 {
852 $address_id = $AddressID[$i];
853 $variable = "DeleteAddressButton$address_id";
854 if ( !in_array( $AddressID[$i], $DeleteAddressArrayID ) and !isset( $$variable ) )
855 {
856 if ( isset( $MainAddressID ) && is_numeric( $MainAddressID ) )
857 {
858 if( isset( $RealAddressID[$i] ) )
859 {
860 $t->set_var( "is_checked", $RealAddressID[$i] == $MainAddressID ? "checked" : "" );
861 }
862 else
863 {
864 $t->set_var( "is_checked", "" );
865 }
866
867 }
868
869 if ( count ( $checkArray ) == 1 )
870 {
871 $t->set_var( "delete_address", "" );
872 $t->set_var( "main_address", "" );
873 }
874 else
875 {
876 if( isset( $RealAddressID[$i] ) )
877 {
878 $t->set_var( "address_id", $RealAddressID[$i] );
879 }
880 else
881 {
882 $t->set_var( "address_id", "" );
883 }
884 $t->parse( "main_address", "main_address_tpl" );
885 $t->set_var( "address_id", $AddressID[$i] );
886 $t->parse( "delete_address", "delete_address_tpl" );
887 }
888 $t->set_var( "address_id", $AddressID[$i] );
889
890 $t->set_var( "real_address_id", isset( $RealAddressID[$i] ) ? $RealAddressID[$i] : false );
891
892 $t->set_var( "street1_value", $Street1[$i] );
893 $t->set_var( "street2_value", $Street2[$i] );
894
895
896 $t->set_var( "zip_value", $Zip[$i] );
897 $t->set_var( "place_value", $Place[$i] );
898
899 $t->set_var( "phone_value", $Phone[$i]);
900
901 $t->set_var( "country", "" );
902 if ( $SelectCountry == "enabled" )
903 {
904 $t->set_var( "country_option", "" );
905 foreach ( $countryList as $country )
906 {
907 $t->set_var( "is_selected", $country["ID"] == $CountryID[$i] ? "selected" : "" );
908
909 $t->set_var( "country_id", $country["ID"] );
910 $t->set_var( "country_name", $country["Name"] );
911 $t->parse( "country_option", "country_option_tpl", true );
912 }
913 $t->parse( "country", "country_tpl" );
914 }
915
916 $t->set_var( "region", "" );
917 if ( $SelectRegion == "enabled" )
918 {
919 $t->set_var( "region_option", "" );
920 $t->set_var( "specialFormId",$i);
921 foreach ( $regionList as $region )
922 {
923 if( isset( $RegionID[$i] ) )
924 $t->set_var( "is_selected", $region["ID"] == $RegionID[$i] ? "selected" : "" );
925 else
926 $t->set_var( "is_selected", "" );
927 $t->set_var( "region_id", $region["ID"] );
928 $t->set_var( "region_name", $region["Name"] );
929 $t->parse( "region_option", "region_option_tpl", true );
930 }
931 $t->parse( "region", "region_tpl" );
932 }
933 $t->set_var( "address_number", $i + 1 );
934
935 $t->parse( "address", "address_tpl", true );
936 }
937 }
938 $t->parse( "address_actions", "address_actions_tpl" );
939 }
940
941
942 $t->set_var( "global_section_id", $GlobalSectionID );
943
944 $t->set_var( "user_id", $UserID );
945
946 if( isset( $RedirectURL ) )
947 {
948 $t->set_var( "redirect_url", eZTextTool::htmlspecialchars( $RedirectURL ) );
949 }
950 else
951 {
952 $t->set_var( "redirect_url", '' );
953 }
954
955 $t->pparse( "output", "user_edit_tpl" );
956
957 ?>
$i
$i
Definition: admin/adlist.php:91
$group
$group
Definition: admin/articleedit.php:799
$Phone
$Phone
Definition: admin/useredit.php:443
$address
$address
Definition: checkout.php:588
eZAddress
Definition: ezaddress.php:42
eZAddress\setMainAddress
static setMainAddress( $mainAddress, $user)
Definition: ezaddress.php:279
eZAddress\mainAddress
static mainAddress( $user)
Definition: ezaddress.php:318
eZCountry\getAllArray
static & getAllArray()
Definition: ezcountry.php:196
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZHTTPTool\getVar
static getVar( $name, $onlyCheckPost=false)
Definition: ezhttptool.php:55
eZMail\validate
static validate( $address)
Definition: ezmail.php:599
eZRegion\getAllArray
static & getAllArray()
Definition: ezregion.php:199
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
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
eZUser\exists
static exists( $login)
Definition: ezuser.php:556
$addressArray
$addressArray
Definition: customerview.php:94
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$RedirectURL
$RedirectURL
Definition: ezforum/user/userlogin.php:91
exit
exit
Definition: folder.php:81
$NoAddress
$NoAddress
Definition: frame.php:368
$country
$country
Definition: paypal.php:46
$region
$region
Definition: paypal.php:45
$mainAddress
$mainAddress
Definition: step2.php:32
$countryList
$countryList
Definition: step2.php:42
$REQUEST_URI
$REQUEST_URI
Definition: storestats.php:32
$UserID
$UserID
Definition: todoedit.php:122
$deleted
$deleted
Definition: userwithaddress.php:794
$SelectCountry
$SelectCountry
Definition: userwithaddress.php:37
$emailCheck
$emailCheck
Definition: userwithaddress.php:210
$t
$t
Definition: userwithaddress.php:83
$AnonymousUserGroup
$AnonymousUserGroup
Definition: userwithaddress.php:39
$placeCheck
$placeCheck
Definition: userwithaddress.php:218
$street1Check
$street1Check
Definition: userwithaddress.php:215
$Email
$Email
Definition: userwithaddress.php:78
$InfoSubscription
else $InfoSubscription
Definition: userwithaddress.php:778
$user
$user
Definition: userwithaddress.php:51
$loginCheck
$loginCheck
Definition: userwithaddress.php:213
$VerifyPassword
if(( $ForceSSL=="enabled")) elseif( $ForceSSL=="disabled") $VerifyPassword
Definition: userwithaddress.php:76
$LastName
$LastName
Definition: userwithaddress.php:81
$info_array
if(isset( $NewAddress)) if((isset( $OK) or isset( $OK_x)) and $error==false) $info_array
Definition: userwithaddress.php:589
$AutoCookieLogin
$AutoCookieLogin
Definition: userwithaddress.php:41
$ForceSSL
$ForceSSL
Definition: userwithaddress.php:40
$RealAddressID
$RealAddressID
Definition: userwithaddress.php:221
$SelectRegion
$SelectRegion
Definition: userwithaddress.php:38
$checkArray
for( $i=0; $i< count( $AddressID);++$i) if( $deleted) $checkArray
Definition: userwithaddress.php:823
$FirstName
$FirstName
Definition: userwithaddress.php:80
$Language
$Language
Definition: userwithaddress.php:36
$ini
$ini
Definition: userwithaddress.php:35
$cookieCheck
$cookieCheck
Definition: userwithaddress.php:606
$user_insert
$user_insert
Definition: userwithaddress.php:205
$street2Check
$street2Check
Definition: userwithaddress.php:216
$nameCheck
$nameCheck
Definition: userwithaddress.php:209
$realAddressID
$realAddressID
Definition: userwithaddress.php:220
$session
$session
Definition: userwithaddress.php:43
$zipCheck
$zipCheck
Definition: userwithaddress.php:217
$passwordCheck
$passwordCheck
Definition: userwithaddress.php:214
$firstNameCheck
$firstNameCheck
Definition: userwithaddress.php:211
$Password
$Password
Definition: userwithaddress.php:77
$Signature
$Signature
Definition: userwithaddress.php:206
$error
$error
Definition: userwithaddress.php:208
$Login
$Login
Definition: userwithaddress.php:79
$addressCheck
$addressCheck
Definition: userwithaddress.php:219
$lastNameCheck
$lastNameCheck
Definition: userwithaddress.php:212
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.