Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

addressedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: addressedit.php 9518 2002-05-08 11:51:36Z vl $
5 //
6 // Created on: <06-Nov-2000 16:55:56 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/ezlog.php" );
32 // include_once( "classes/ezhttptool.php" );
33 // include_once( "classes/eztexttool.php" );
34
35
36 $ini =& eZINI::instance( 'site.ini' );
37 $Language = $ini->variable( "eZUserMain", "Language" );
38 $SelectCountry = $ini->variable( "eZUserMain", "SelectCountry" );
39 $AnonymousUserGroup = $ini->variable( "eZUserMain", "AnonymousUserGroup" );
40
41 // include_once( "ezuser/classes/ezuser.php" );
42 // include_once( "ezuser/classes/ezusergroup.php" );
43 // include_once( "ezaddress/classes/ezaddress.php" );
44 // include_once( "ezaddress/classes/ezcountry.php" );
45
46 if ( $Action == "Insert" )
47 {
48 // check for valid data
49 if (
50 $Street1 != "" &&
51 $Zip != "" &&
52 $Place != "" )
53 {
54 $user =& eZUser::currentUser();
55
56 if ( $user )
57 {
58 $address = new eZAddress();
59 $address->setStreet1( $Street1 );
60 $address->setStreet2( $Street2 );
61 $address->setZip( $Zip );
62 $address->setPlace( $Place );
63 $address->setRegion( $Region );
64
65 if ( isset( $CountryID ) )
66 {
67 $country = new eZCountry( $CountryID );
68 $address->setCountry( $country );
69 }
70
71 $address->store();
72
73 // add the address to the user.
74 $user->addAddress( $address );
75
76 eZPBLog::writeNotice( "Anonyous user added address: (" . $user->login() . ") from IP: $REMOTE_ADDR" );
77
78 if ( ( isset( $RedirectURL ) ) && ( $RedirectURL != "" ) )
79 {
80 eZHTTPTool::header( "Location: $RedirectURL" );
81 exit();
82 }
83
84 eZHTTPTool::header( "Location: /" );
85 exit();
86 }
87 else
88 {
89 $UserExistsError = true;
90 }
91 }
92 else
93 {
94 $Error = true;
95 }
96 }
97
98
99 if ( $Action == "Update" )
100 {
101 // check for valid data
102 if ( $Login != "" &&
103 $Email != "" &&
104 $FirstName != "" &&
105 $LastName != "" )
106 {
107 $user = new eZUser();
108 $user->get( $UserID );
109
110 if ( $Password )
111 {
112 if ( ( $Password == $VerifyPassword ) && ( strlen( $VerifyPassword ) > 2 ) )
113 {
114 $user->setPassword( $Password );
115 }
116 else
117 {
118 $PasswordError = true;
119 }
120 }
121
122 $user->setEmail( $Email );
123 $user->setFirstName( $FirstName );
124 $user->setLastName( $LastName );
125
126 $address = new eZAddress();
127 $address->get( $AddressID );
128 $address->setStreet1( $Street1 );
129 $address->setStreet2( $Street2 );
130 $address->setZip( $Zip );
131 $address->setPlace( $Place );
132 $address->setRegion( $Region );
133 if ( isset( $CountryID ) )
134 {
135 $country = new eZCountry( $CountryID );
136 $address->setCountry( $country );
137 }
138
139 $address->store();
140
141 if ( !$PasswordError )
142 $user->store();
143
144
145 if ( isset( $RedirectURL ) && ( $RedirectURL != "" ) )
146 {
147 eZHTTPTool::header( "Location: $RedirectURL" );
148 exit();
149 }
150 eZHTTPTool::header( "Location: /" );
151 exit();
152 }
153 else
154 {
155 $Error = true;
156 }
157 }
158
159
160
161 $t = new eZTemplate( "kernel/ezuser/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
162 "kernel/ezuser/user/intl/", $Language, "addressedit.php" );
163
164 $t->setAllStrings();
165
166 $t->set_file( array(
167 "user_edit_tpl" => "addressedit.tpl"
168 ) );
169
170 $t->set_var( "readonly", "" );
171 $action_value = "insert";
172
173 if ( $Action == "Update" )
174 $action_value = "update";
175
176 if ( $Action == "Edit" )
177 {
178 $user =& eZUser::currentUser();
179 if ( !$user )
180 eZHTTPTool::header( "Location: /" );
181 $UserID = $user->id();
182 $user->get( $user->id() );
183 $Login = $user->Login( );
184 $Email = $user->Email( );
185 $FirstName = $user->FirstName( );
186 $LastName = $user->LastName( );
187
188 $t->set_var( "readonly", "readonly" );
189
190
191 // print out the addresses
192 // Dosent work with multiplie addresses.
193
194 $addressArray = $user->addresses();
195
196 foreach ( $addressArray as $address )
197 {
198 $Street1 = $address->street1();
199 $Street2 = $address->street2();
200 $Zip = $address->zip();
201 $Place = $address->place();
202 $Region = $address->region();
203
204 $t->set_var( "address_id", $address->id() );
205
206 // $country = $address->country();
207 // $t->set_var( "country", $country->name() );
208 }
209
210 $action_value = "update";
211
212 }
213
214
215 $t->set_block( "user_edit_tpl", "required_fields_error_tpl", "required_fields_error" );
216 $t->set_block( "user_edit_tpl", "user_exists_error_tpl", "user_exists_error" );
217 $t->set_block( "user_edit_tpl", "password_error_tpl", "password_error" );
218
219 $t->set_block( "user_edit_tpl", "country_tpl", "country" );
220 $t->set_block( "country_tpl", "country_option_tpl", "country_option" );
221
222 if ( $Error == true )
223 {
224 $t->parse( "required_fields_error", "required_fields_error_tpl" );
225 }
226 else
227 {
228 $t->set_var( "required_fields_error", "" );
229 }
230
231 if ( $UserExistsError == true )
232 {
233 $t->parse( "user_exists_error", "user_exists_error_tpl" );
234 }
235 else
236 {
237 $t->set_var( "user_exists_error", "" );
238 }
239
240 if ( $PasswordError == true )
241 {
242 $t->parse( "password_error", "password_error_tpl" );
243 }
244 else
245 {
246 $t->set_var( "password_error", "" );
247 }
248
249 $t->set_var( "login_value", $Login );
250 $t->set_var( "password_value", $Password );
251 $t->set_var( "verify_password_value", $VerifyPassword );
252 $t->set_var( "email_value", $Email );
253
254 $t->set_var( "first_name_value", $FirstName );
255 $t->set_var( "last_name_value", $LastName );
256
257 $t->set_var( "street1_value", $Street1 );
258 $t->set_var( "street2_value", $Street2 );
259
260 $t->set_var( "zip_value", $Zip );
261
262 $t->set_var( "place_value", $Place );
263
264 $t->set_var( "region_value", $Region );
265
266 if ( $SelectCountry == "enabled" )
267 {
268 $ezcountry = new eZCountry();
269 $countryList =& $ezcountry->getAllArray();
270
271 foreach ( $countryList as $country )
272 {
273 if ( $Action == "Edit" )
274 {
275 $countryID = $address->country();
276
277 if ( $country["ID"] == $countryID->id() )
278 {
279 $t->set_var( "is_selected", "selected" );
280 }
281 else
282 $t->set_var( "is_selected", "" );
283 }
284
285 $t->set_var( "country_id", $country["ID"] );
286 $t->set_var( "country_name", $country["Name"] );
287 $t->parse( "country_option", "country_option_tpl", true );
288 }
289 $t->parse( "country", "country_tpl" );
290 }
291 else
292 {
293 $t->set_var( "country", "" );
294 }
295
296
297
298 $t->set_var( "action_value", $action_value );
299 $t->set_var( "user_id", $UserID );
300
301 $t->set_var( "redirect_url", eZTextTool::htmlspecialchars( $RedirectURL ) );
302
303 $t->pparse( "output", "user_edit_tpl" );
304
305 ?>
$SelectCountry
$SelectCountry
Definition: addressedit.php:38
$AnonymousUserGroup
$AnonymousUserGroup
Definition: addressedit.php:39
$Language
$Language
Definition: addressedit.php:37
$ini
$ini
Definition: addressedit.php:36
$t
if( $Action=="Insert") if( $Action=="Update") $t
Definition: addressedit.php:161
$action_value
$action_value
Definition: addressedit.php:171
$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
$Login
$Login
Definition: admin/useredit.php:445
$address
$address
Definition: checkout.php:588
eZAddress
Definition: ezaddress.php:42
eZCountry
Definition: ezcountry.php:39
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZPBLog\writeNotice
static writeNotice( $notice)
Definition: ezpblog.php:166
eZTemplate
Definition: eztemplate.php:107
eZTextTool\htmlspecialchars
static htmlspecialchars( $string)
Definition: eztexttool.php:144
eZUser
Definition: ezuser.php:76
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$Action
$Action
Definition: companysearch.php:80
$addressArray
$addressArray
Definition: customerview.php:94
$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
$country
$country
Definition: paypal.php:46
$countryList
$countryList
Definition: step2.php:42
$UserID
$UserID
Definition: todoedit.php:122
$user
$user
Definition: user/adlist.php:39
$VerifyPassword
if(( $ForceSSL=="enabled")) elseif( $ForceSSL=="disabled") $VerifyPassword
Definition: userwithaddress.php:76
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.