Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezaddress.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezaddress.php,v 1.19.2.1 2001/12/05 14:14:01 br Exp $
5 //
6 // Definition of eZAddress class
7 //
8 // Created on: <07-Oct-2000 12:34:13 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
36 // include_once( "classes/ezdb.php" );
37 // include_once( "ezaddress/classes/ezcountry.php" );
38 // include_once( "ezaddress/classes/ezregion.php" );
39 // include_once( "ezaddress/classes/ezaddresstype.php" );
40
41 class eZAddress
42 {
46 function __construct( $id = "" )
47 {
48 $this->PhoneID = 0;
49 $this->AddressTypeID = 0;
50 if ( $id != "" )
51 {
52 $this->ID = $id;
53 $this->get( $this->ID );
54 }
55 }
56
60 function store()
61 {
62 $db =& eZDB::globalDatabase();
63 $db->begin();
64
65 $ret = false;
66 $res = array();
67
68 if ( $this->CountryID <= 0 )
69 $country_id = 0;
70 else
71 $country_id = "$this->CountryID";
72
73 if ( $this->RegionID <= 0 )
74 $region_id = 0;
75 else
76 $region_id = "$this->RegionID";
77
78 $street1 = $db->escapeString( $this->Street1 );
79 $street2 = $db->escapeString( $this->Street2 );
80 $name = $db->escapeString( $this->Name );
81 $place = $db->escapeString( $this->Place );
82 if ( !isset( $this->ID ) )
83 {
84 $db->lock( "eZAddress_Address" );
85 $this->ID = $db->nextID( "eZAddress_Address", "ID" );
86 $query = "INSERT INTO eZAddress_Address
87 (ID, Street1, Street2, Zip, Place, CountryID, RegionID, AddressTypeID, Name, Phone)
88 VALUES
89 ('$this->ID',
90 '$street1',
91 '$street2',
92 '$this->Zip',
93 '$place',
94 '$country_id',
95 '$region_id',
96 '$this->AddressTypeID',
97 '$name',
98 '$this->Phone')";
99
100 $res[] = $db->query( $query );
101 $db->unlock();
102 $ret = true;
103 }
104 else
105 {
106 $res[] = $db->query( "UPDATE eZAddress_Address
107 SET Street1='$street1',
108 Street2='$street2',
109 Zip='$this->Zip',
110 Phone='$this->Phone',
111 Place='$place',
112 AddressTypeID='$this->AddressTypeID',
113 Name='$name',
114 CountryID='$country_id',
115 RegionID='$region_id'
116 WHERE ID='$this->ID'" );
117 $ret = true;
118 }
119
120 eZDB::finish( $res, $db );
121 return $ret;
122 }
123
127 function get( $id="" )
128 {
129 $ret = false;
130 $db =& eZDB::globalDatabase();
131 if ( $id != "" )
132 {
133 $db->array_query( $address_array, "SELECT * FROM eZAddress_Address WHERE ID='$id'" );
134 if ( count( $address_array ) > 1 )
135 {
136 die( "Error: addresses with the same ID was found in the database. This shouldent happen." );
137 }
138 else if ( count( $address_array ) == 1 )
139 {
140 $this->ID =& $address_array[0][$db->fieldName( "ID" )];
141 $this->Street1 =& $address_array[0][$db->fieldName( "Street1" )];
142 $this->Street2 =& $address_array[0][$db->fieldName( "Street2" )];
143 $this->Zip =& $address_array[0][$db->fieldName( "Zip" )];
144 $this->Phone =& $address_array[0][$db->fieldName( "Phone" )];
145 $this->Place =& $address_array[0][$db->fieldName( "Place" )];
146 $this->CountryID =& $address_array[0][$db->fieldName( "CountryID" )];
147 $this->RegionID =& $address_array[0][$db->fieldName( "RegionID" )];
148 $this->AddressTypeID =& $address_array[0][$db->fieldName( "AddressTypeID" )];
149 $this->Name =& $address_array[0][$db->fieldName( "Name" )];
150 $ret = true;
151 }
152 if ( $this->CountryID == "NULL" )
153 $this->CountryID = -1;
154 if ( $this->RegionID == "NULL" )
155 $this->RegionID = -1;
156 }
157 return $ret;
158 }
159
163 static public function getAll( )
164 {
165 $db =& eZDB::globalDatabase();
166 $address_array = 0;
167
168 $db->array_query( $address_array, "SELECT * FROM eZAddress_Address" );
169
170 return $address_array;
171 }
172
176 static public function delete( $id = false )
177 {
178 if ( !$id )
179 $id = $this->ID;
180 $db =& eZDB::globalDatabase();
181 $db->begin();
182 $res[] = $db->query( "DELETE FROM eZAddress_Address WHERE ID='$id'" );
183 eZDB::finish( $res, $db );
184 }
185
186
190 function &copy( )
191 {
192 $new = $this;
193 $new->unsetID();
194 $new->store();
195
196 return $new;
197 }
198
202 function unsetID( )
203 {
204 unset( $this->ID );
205 }
206
210 function setStreet1( $value )
211 {
212 $this->Street1 = $value;
213 }
214
218 function setStreet2( $value )
219 {
220 $this->Street2 = $value;
221 }
222
226 function setName( $value )
227 {
228 $this->Name = $value;
229 }
230
234 function setZip( $value )
235 {
236 $this->Zip = $value;
237 }
238
239 function setPhone( $value )
240 {
241 $this->Phone = $value;
242 }
243
247 function setAddressType( $value )
248 {
249 if( is_numeric( $value ) )
250 {
251 $this->AddressTypeID = $value;
252 }
253
254 if( is_a( $value, "eZAddressType" ) )
255 {
256 $this->AddressTypeID = $value->id();
257 }
258 }
259
263 function setAddressTypeID( $value )
264 {
265 if( is_numeric( $value ) )
266 {
267 $this->AddressTypeID = $value;
268 }
269
270 if( is_a( $value, "eZAddressType" ) )
271 {
272 $this->AddressTypeID = $value->id();
273 }
274 }
275
279 static public function setMainAddress( $mainAddress, $user )
280 {
281 if( is_a( $mainAddress, "eZAddressType" ) )
282 $addressID = $mainAddress->id();
283 else
284 $addressID = $mainAddress;
285 if ( is_a ( $user, "eZUser" ) )
286 $userID = $user->id();
287 else
288 $userID = $user;
289
290 $db =& eZDB::globalDatabase();
291
292 $db->array_query( $checkForAddress, "SELECT UserID FROM eZAddress_AddressDefinition
293 WHERE UserID='$userID'" );
294
295 if ( count ( $checkForAddress ) != 0 )
296 {
297 $res[] = $db->query( "UPDATE eZAddress_AddressDefinition SET
298 AddressID='$addressID',
299 UserID='$userID'
300 WHERE UserID='$userID'" );
301 }
302 else
303 {
304 $db->begin();
305 $res[] = $db->query( "INSERT INTO eZAddress_AddressDefinition
306 (AddressID, UserID)
307 VALUES
308 ('$addressID', '$userID')" );
309 $db->unlock();
310 }
311
312 eZDB::finish( $res, $db );
313 }
314
318 static public function mainAddress( $user )
319 {
320 if ( is_a ( $user, "eZUser" ) )
321 $userID = $user->id();
322 else
323 $userID = $user;
324
325 $db =& eZDB::globalDatabase();
326
327 $db->array_query( $addressArray, "SELECT AddressID FROM eZAddress_AddressDefinition
328 WHERE UserID='$userID'", 0, 1 );
329
330 if ( count( $addressArray ) == 1 )
331 {
332 return new eZAddress( $addressArray[0][$db->fieldName( "AddressID" )] );
333 }
334 else
335 {
336 return false;
337 }
338 }
339
343 function id()
344 {
345 return $this->ID;
346 }
347
351 function street1( )
352 {
353 return $this->Street1;
354 }
355
359 function street2( )
360 {
361 return $this->Street2;
362 }
363
367 function name( )
368 {
369 return $this->Name;
370 }
371
375 function zip( )
376 {
377 return $this->Zip;
378 }
379
380 function phone( )
381 {
382 return $this->Phone;
383 }
384
388 function addressTypeID()
389 {
390 return $this->AddressTypeID;
391 }
392
396 function addressType()
397 {
398 $addressType = new eZAddressType( $this->AddressTypeID );
399 return $addressType;
400 }
401
405 function setPlace( $value )
406 {
407 $this->Place = $value;
408 }
409
413 function setCountry( $country )
414 {
415 if ( is_a( $country, "eZCountry" ) )
416 {
417 $this->CountryID = $country->id();
418 }
419 else if ( is_numeric( $country ) )
420 {
421 $this->CountryID = $country;
422 }
423 }
424
428 function setRegion( $region )
429 {
430 if ( is_a( $region, "eZRegion" ) )
431 {
432 $this->RegionID = $region->id();
433 }
434 if ( $region == "" ) {
435 $this->RegionID = "";
436 }
437 else if ( is_numeric( $region ) )
438 {
439 $this->RegionID = $region;
440 }
441 }
442
446 function place()
447 {
448 return $this->Place;
449 }
450
454 function country()
455 {
456 if ( is_numeric( $this->CountryID ) and $this->CountryID > 0 )
457 {
458 return new eZCountry( $this->CountryID );
459 }
460 else
461 return false;
462
463 }
464
468 function region()
469 {
470 if ( is_numeric( $this->RegionID ) and $this->RegionID > 0 )
471 return new eZRegion( $this->RegionID );
472 else
473 return false;
474 }
475
476 var $ID;
477 var $Street1;
478 var $Street2;
479 var $Zip;
480 var $Phone;
481 var $Place;
482 var $RegionID;
483 var $CountryID;
484 var $Name;
485
487 var $AddressTypeID;
488 var $PhoneID;
489 }
490
491 ?>
$userID
else $userID
Definition: appointmentedit.php:121
eZAddressType
Definition: ezaddresstype.php:46
eZAddress
Definition: ezaddress.php:42
eZAddress\setStreet2
setStreet2( $value)
Definition: ezaddress.php:218
eZAddress\phone
phone()
Definition: ezaddress.php:380
eZAddress\street1
street1()
Definition: ezaddress.php:351
eZAddress\setZip
setZip( $value)
Definition: ezaddress.php:234
eZAddress\getAll
static getAll()
Definition: ezaddress.php:163
eZAddress\store
store()
Definition: ezaddress.php:60
eZAddress\street2
street2()
Definition: ezaddress.php:359
eZAddress\setRegion
setRegion( $region)
Definition: ezaddress.php:428
eZAddress\setPhone
setPhone( $value)
Definition: ezaddress.php:239
eZAddress\setPlace
setPlace( $value)
Definition: ezaddress.php:405
eZAddress\place
place()
Definition: ezaddress.php:446
eZAddress\setStreet1
setStreet1( $value)
Definition: ezaddress.php:210
eZAddress\$Place
$Place
Definition: ezaddress.php:481
eZAddress\$Street1
$Street1
Definition: ezaddress.php:477
eZAddress\zip
zip()
Definition: ezaddress.php:375
eZAddress\$Zip
$Zip
Definition: ezaddress.php:479
eZAddress\region
region()
Definition: ezaddress.php:468
eZAddress\addressTypeID
addressTypeID()
Definition: ezaddress.php:388
eZAddress\setMainAddress
static setMainAddress( $mainAddress, $user)
Definition: ezaddress.php:279
eZAddress\setAddressType
setAddressType( $value)
Definition: ezaddress.php:247
eZAddress\__construct
__construct( $id="")
Definition: ezaddress.php:46
eZAddress\$PhoneID
$PhoneID
Definition: ezaddress.php:488
eZAddress\$Street2
$Street2
Definition: ezaddress.php:478
eZAddress\setCountry
setCountry( $country)
Definition: ezaddress.php:413
eZAddress\$ID
$ID
Definition: ezaddress.php:476
eZAddress\unsetID
unsetID()
Definition: ezaddress.php:202
eZAddress\setAddressTypeID
setAddressTypeID( $value)
Definition: ezaddress.php:263
eZAddress\id
id()
Definition: ezaddress.php:343
eZAddress\$RegionID
$RegionID
Definition: ezaddress.php:482
eZAddress\addressType
addressType()
Definition: ezaddress.php:396
eZAddress\setName
setName( $value)
Definition: ezaddress.php:226
eZAddress\mainAddress
static mainAddress( $user)
Definition: ezaddress.php:318
eZAddress\$AddressTypeID
$AddressTypeID
Relation to an eZAddressTypeID.
Definition: ezaddress.php:487
eZAddress\name
name()
Definition: ezaddress.php:367
eZAddress\$Name
$Name
Definition: ezaddress.php:484
eZAddress\$Phone
$Phone
Definition: ezaddress.php:480
eZAddress\country
country()
Definition: ezaddress.php:454
eZAddress\copy
& copy()
Definition: ezaddress.php:190
eZAddress\$CountryID
$CountryID
Definition: ezaddress.php:483
eZCountry
Definition: ezcountry.php:39
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZRegion
Definition: ezregion.php:39
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$addressArray
$addressArray
Definition: customerview.php:94
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$country
$country
Definition: paypal.php:46
$region
$region
Definition: paypal.php:45
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
$mainAddress
$mainAddress
Definition: step2.php:32
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.