  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: customer.php 185 2005-09-13 20:30:24Z hpdl $ |
| |
| 3 | + | $Id: customer.php 201 2005-09-23 08:40:18Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
17 | 17 | | var $_is_logged_on = false, |
| |
18 | 18 | | $_data = array(); |
| |
19 | 19 | | |
  |
| 20 | + | /* Class constructor */ |
| |
| 21 | + | |
| |
| 22 | + | function osC_Customer() { |
| |
| 23 | + | if (isset($_SESSION['osC_Customer_data']) && is_array($_SESSION['osC_Customer_data']) && (sizeof($_SESSION['osC_Customer_data']) > 0) && isset($_SESSION['osC_Customer_data']['id']) && is_numeric($_SESSION['osC_Customer_data']['id'])) { |
| |
| 24 | + | $this->setIsLoggedOn(true); |
| |
| 25 | + | $this->_data =& $_SESSION['osC_Customer_data']; |
| |
| 26 | + | } |
| |
| 27 | + | } |
| |
| 28 | + | |
|
20 | 29 | | /* Public methods */ |
| |
21 | 30 | | |
| |
22 | 31 | | function getID() { |
| |
|
|
 |
… |
|
132 | 141 | | } |
| |
133 | 142 | | |
| |
134 | 143 | | function setCustomerData($customer_id = -1) { |
  |
135 | | - | if (is_numeric($customer_id) && ($customer_id > 0)) { |
| |
136 | | - | global $osC_Database; |
| |
| 144 | + | global $osC_Database; |
|
137 | 145 | | |
  |
| 146 | + | $this->_data = array(); |
| |
| 147 | + | |
| |
| 148 | + | if (is_numeric($customer_id) && ($customer_id > 0)) { |
|
138 | 149 | | $Qcustomer = $osC_Database->query('select customers_gender, customers_firstname, customers_lastname, customers_email_address, customers_default_address_id from :table_customers where customers_id = :customers_id'); |
  |
139 | | - | $Qcustomer->bindRaw(':table_customers', TABLE_CUSTOMERS); |
| |
| 150 | + | $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS); |
|
140 | 151 | | $Qcustomer->bindInt(':customers_id', $customer_id); |
| |
141 | 152 | | $Qcustomer->execute(); |
| |
142 | 153 | | |
| |
|
|
 |
… |
|
167 | 178 | | |
| |
168 | 179 | | $Qcustomer->freeResult(); |
| |
169 | 180 | | } |
  |
| 181 | + | |
| |
| 182 | + | if (sizeof($this->_data) > 0) { |
| |
| 183 | + | $_SESSION['osC_Customer_data'] = $this->_data; |
| |
| 184 | + | } elseif (isset($_SESSION['osC_Customer_data'])) { |
| |
| 185 | + | $this->reset(); |
| |
| 186 | + | } |
|
170 | 187 | | } |
| |
171 | 188 | | |
| |
172 | 189 | | function setIsLoggedOn($state) { |
| |
|
|
 |
… |
|
236 | 253 | | function setZoneID($id) { |
| |
237 | 254 | | $this->_data['zone_id'] = $id; |
| |
238 | 255 | | } |
  |
| 256 | + | |
| |
| 257 | + | function reset() { |
| |
| 258 | + | $this->_is_logged_on = false; |
| |
| 259 | + | $this->_data = array(); |
| |
| 260 | + | |
| |
| 261 | + | unset($_SESSION['osC_Customer_data']); |
| |
| 262 | + | } |
  |
239 | 263 | | } |
| |
240 | 264 | | ?> |