  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: customer.php 153 2005-08-04 12:57:59Z hpdl $ |
| |
| 3 | + | $Id: customer.php 184 2005-09-07 14:48:20Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
22 | 22 | | $country_id, |
| |
23 | 23 | | $zone_id; |
| |
24 | 24 | | |
  |
25 | | - | // class constructor |
| |
26 | | - | function osC_Customer() { |
| |
27 | | - | $this->setIsLoggedOn(false); |
| |
| 25 | + | /* Private variables */ |
| |
| 26 | + | |
| |
| 27 | + | var $_is_logged_on = false, |
| |
| 28 | + | $_data = array(); |
| |
| 29 | + | |
| |
| 30 | + | /* Public methods */ |
| |
| 31 | + | |
| |
| 32 | + | function getID() { |
| |
| 33 | + | if (isset($this->_data['id']) && is_numeric($this->_data['id'])) { |
| |
| 34 | + | return $this->_data['id']; |
| |
| 35 | + | } |
| |
| 36 | + | |
| |
| 37 | + | return false; |
|
28 | 38 | | } |
| |
29 | 39 | | |
  |
30 | | - | // class methods |
| |
| 40 | + | function getFirstName() { |
| |
| 41 | + | static $first_name = null; |
| |
| 42 | + | |
| |
| 43 | + | if (is_null($first_name)) { |
| |
| 44 | + | if (isset($this->_data['first_name'])) { |
| |
| 45 | + | $first_name = $this->_data['first_name']; |
| |
| 46 | + | } |
| |
| 47 | + | } |
| |
| 48 | + | |
| |
| 49 | + | return $first_name; |
| |
| 50 | + | } |
| |
| 51 | + | |
| |
| 52 | + | function getLastName() { |
| |
| 53 | + | static $last_name = null; |
| |
| 54 | + | |
| |
| 55 | + | if (is_null($last_name)) { |
| |
| 56 | + | if (isset($this->_data['last_name'])) { |
| |
| 57 | + | $last_name = $this->_data['last_name']; |
| |
| 58 | + | } |
| |
| 59 | + | } |
| |
| 60 | + | |
| |
| 61 | + | return $last_name; |
| |
| 62 | + | } |
| |
| 63 | + | |
| |
| 64 | + | function getName() { |
| |
| 65 | + | static $name = ''; |
| |
| 66 | + | |
| |
| 67 | + | if (empty($name)) { |
| |
| 68 | + | if (isset($this->_data['first_name'])) { |
| |
| 69 | + | $name .= $this->_data['first_name']; |
| |
| 70 | + | } |
| |
| 71 | + | |
| |
| 72 | + | if (isset($this->_data['last_name'])) { |
| |
| 73 | + | if (empty($name) === false) { |
| |
| 74 | + | $name .= ' '; |
| |
| 75 | + | } |
| |
| 76 | + | |
| |
| 77 | + | $name .= $this->_data['last_name']; |
| |
| 78 | + | } |
| |
| 79 | + | } |
| |
| 80 | + | |
| |
| 81 | + | return $name; |
| |
| 82 | + | } |
| |
| 83 | + | |
| |
| 84 | + | function getGender() { |
| |
| 85 | + | static $gender = null; |
| |
| 86 | + | |
| |
| 87 | + | if (is_null($gender)) { |
| |
| 88 | + | if (isset($this->_data['gender'])) { |
| |
| 89 | + | $gender = $this->_data['gender']; |
| |
| 90 | + | } |
| |
| 91 | + | } |
| |
| 92 | + | |
| |
| 93 | + | return $gender; |
| |
| 94 | + | } |
| |
| 95 | + | |
| |
| 96 | + | function getEmailAddress() { |
| |
| 97 | + | static $email_address = null; |
| |
| 98 | + | |
| |
| 99 | + | if (is_null($email_address)) { |
| |
| 100 | + | if (isset($this->_data['email_address'])) { |
| |
| 101 | + | $email_address = $this->_data['email_address']; |
| |
| 102 | + | } |
| |
| 103 | + | } |
| |
| 104 | + | |
| |
| 105 | + | return $email_address; |
| |
| 106 | + | } |
| |
| 107 | + | |
| |
| 108 | + | function getCountryID() { |
| |
| 109 | + | static $country_id = null; |
| |
| 110 | + | |
| |
| 111 | + | if (is_null($country_id)) { |
| |
| 112 | + | if (isset($this->_data['country_id'])) { |
| |
| 113 | + | $country_id = $this->_data['country_id']; |
| |
| 114 | + | } |
| |
| 115 | + | } |
| |
| 116 | + | |
| |
| 117 | + | return $country_id; |
| |
| 118 | + | } |
| |
| 119 | + | |
| |
| 120 | + | function getZoneID() { |
| |
| 121 | + | static $zone_id = null; |
| |
| 122 | + | |
| |
| 123 | + | if (is_null($zone_id)) { |
| |
| 124 | + | if (isset($this->_data['zone_id'])) { |
| |
| 125 | + | $zone_id = $this->_data['zone_id']; |
| |
| 126 | + | } |
| |
| 127 | + | } |
| |
| 128 | + | |
| |
| 129 | + | return $zone_id; |
| |
| 130 | + | } |
| |
| 131 | + | |
| |
| 132 | + | function getDefaultAddressID() { |
| |
| 133 | + | static $id = null; |
| |
| 134 | + | |
| |
| 135 | + | if (is_null($id)) { |
| |
| 136 | + | if (isset($this->_data['default_address_id'])) { |
| |
| 137 | + | $id = $this->_data['default_address_id']; |
| |
| 138 | + | } |
| |
| 139 | + | } |
| |
| 140 | + | |
| |
| 141 | + | return $id; |
| |
| 142 | + | } |
| |
| 143 | + | |
|
31 | 144 | | function setCustomerData($customer_id = -1) { |
| |
32 | 145 | | if (is_numeric($customer_id) && ($customer_id > 0)) { |
| |
33 | 146 | | global $osC_Database; |
| |
|
|
 |
… |
|
48 | 161 | | |
| |
49 | 162 | | if (is_numeric($Qcustomer->value('customers_default_address_id')) && ($Qcustomer->value('customers_default_address_id') > 0)) { |
| |
50 | 163 | | $Qab = $osC_Database->query('select entry_country_id, entry_zone_id from :table_address_book where address_book_id = :address_book_id and customers_id = :customers_id'); |
  |
51 | | - | $Qab->bindRaw(':table_address_book', TABLE_ADDRESS_BOOK); |
| |
| 164 | + | $Qab->bindTable(':table_address_book', TABLE_ADDRESS_BOOK); |
|
52 | 165 | | $Qab->bindInt(':address_book_id', $Qcustomer->value('customers_default_address_id')); |
| |
53 | 166 | | $Qab->bindInt(':customers_id', $customer_id); |
| |
54 | 167 | | $Qab->execute(); |
| |
|
|
 |
… |
|
69 | 182 | | |
| |
70 | 183 | | function setIsLoggedOn($state) { |
| |
71 | 184 | | if ($state === true) { |
  |
72 | | - | $this->is_logged_on = true; |
| |
| 185 | + | $this->_is_logged_on = true; |
|
73 | 186 | | } else { |
  |
74 | | - | $this->is_logged_on = false; |
| |
| 187 | + | $this->_is_logged_on = false; |
|
75 | 188 | | } |
| |
76 | 189 | | } |
| |
77 | 190 | | |
| |
78 | 191 | | function isLoggedOn() { |
  |
79 | | - | if ($this->is_logged_on === true) { |
| |
| 192 | + | if ($this->_is_logged_on === true) { |
|
80 | 193 | | return true; |
| |
81 | 194 | | } |
| |
82 | 195 | | |
| |
|
|
 |
… |
|
89 | 202 | | |
| |
90 | 203 | | function setID($id) { |
| |
91 | 204 | | $this->id = $id; |
  |
| 205 | + | |
| |
| 206 | + | if (is_numeric($id) && ($id > 0)) { |
| |
| 207 | + | $this->_data['id'] = $id; |
| |
| 208 | + | } else { |
| |
| 209 | + | $this->_data['id'] = false; |
| |
| 210 | + | } |
|
92 | 211 | | } |
| |
93 | 212 | | |
| |
94 | 213 | | function setDefaultAddressID($id) { |
| |
95 | 214 | | $this->default_address_id = $id; |
  |
| 215 | + | |
| |
| 216 | + | if (is_numeric($id) && ($id > 0)) { |
| |
| 217 | + | $this->_data['default_address_id'] = $id; |
| |
| 218 | + | } else { |
| |
| 219 | + | $this->_data['default_address_id'] = false; |
| |
| 220 | + | } |
|
96 | 221 | | } |
| |
97 | 222 | | |
| |
98 | 223 | | function hasDefaultAddress() { |
  |
99 | | - | if (is_numeric($this->default_address_id) && ($this->default_address_id > 0)) { |
| |
| 224 | + | if (isset($this->_data['default_address_id']) && is_numeric($this->_data['default_address_id'])) { |
|
100 | 225 | | return true; |
  |
101 | | - | } else { |
| |
102 | | - | return false; |
|
103 | 226 | | } |
  |
| 227 | + | |
| |
| 228 | + | return false; |
|
104 | 229 | | } |
| |
105 | 230 | | |
| |
106 | 231 | | function setGender($gender) { |
| |
107 | 232 | | $this->gender = $gender; |
  |
| 233 | + | |
| |
| 234 | + | if ( (strtolower($gender) == 'm') || (strtolower($gender) == 'f') ) { |
| |
| 235 | + | $this->_data['gender'] = strtolower($gender); |
| |
| 236 | + | } else { |
| |
| 237 | + | $this->_data['gender'] = false; |
| |
| 238 | + | } |
|
108 | 239 | | } |
| |
109 | 240 | | |
  |
110 | | - | function setFirstName($firstname) { |
| |
111 | | - | $this->first_name = $firstname; |
| |
| 241 | + | function setFirstName($first_name) { |
| |
| 242 | + | $this->first_name = $first_name; |
| |
| 243 | + | |
| |
| 244 | + | $this->_data['first_name'] = $first_name; |
|
112 | 245 | | } |
| |
113 | 246 | | |
  |
114 | | - | function setLastName($lastname) { |
| |
115 | | - | $this->last_name = $lastname; |
| |
| 247 | + | function setLastName($last_name) { |
| |
| 248 | + | $this->last_name = $last_name; |
| |
| 249 | + | |
| |
| 250 | + | $this->_data['last_name'] = $last_name; |
|
116 | 251 | | } |
| |
117 | 252 | | |
| |
118 | 253 | | function setFullName($fullname = '') { |
| |
|
|
 |
… |
|
125 | 260 | | |
| |
126 | 261 | | function setEmailAddress($email_address) { |
| |
127 | 262 | | $this->email_address = $email_address; |
  |
| 263 | + | |
| |
| 264 | + | $this->_data['email_address'] = $email_address; |
|
128 | 265 | | } |
| |
129 | 266 | | |
| |
130 | 267 | | function setCountryID($id) { |
| |
131 | 268 | | $this->country_id = $id; |
  |
| 269 | + | |
| |
| 270 | + | $this->_data['country_id'] = $id; |
|
132 | 271 | | } |
| |
133 | 272 | | |
| |
134 | 273 | | function setZoneID($id) { |
| |
135 | 274 | | $this->zone_id = $id; |
  |
| 275 | + | |
| |
| 276 | + | $this->_data['zone_id'] = $id; |
  |
136 | 277 | | } |
| |
137 | 278 | | } |
| |
138 | 279 | | ?> |