Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

151
 
368
 
368
 
customer.php
_> 11 <?php
  22 /*
<> 3 -  $Id: customer.php 151 2005-08-02 14:33:25Z mattice $
   3+  $Id: customer.php 368 2005-12-22 16:27:23Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2004 osCommerce
   8+  Copyright (c) 2005 osCommerce
99 
  1010   Released under the GNU General Public License
  1111 */
  1212 
  1313   class osC_Customer {
<> 14 -    var $is_logged_on,
  15 -        $id,
  16 -        $gender,
  17 -        $first_name,
  18 -        $last_name,
  19 -        $full_name,
  20 -        $email_address,
  21 -        $default_address_id,
  22 -        $country_id,
  23 -        $zone_id;
2414 
<> 25 -// class constructor
   15+/* Private variables */
   16+
   17+    var $_is_logged_on = false,
   18+        $_data = array();
   19+
   20+/* Class constructor */
   21+
2622     function osC_Customer() {
<> 27 -      $this->setIsLoggedOn(false);
   23+      if (isset($_SESSION['osC_Customer_data']) && is_array($_SESSION['osC_Customer_data']) && 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+      }
2827     }
  2928 
<> 30 -// class methods
   29+/* Public methods */
   30+
   31+    function getID() {
   32+      if (isset($this->_data['id']) && is_numeric($this->_data['id'])) {
   33+        return $this->_data['id'];
   34+      }
   35+
   36+      return false;
   37+    }
   38+
   39+    function getFirstName() {
   40+      static $first_name = null;
   41+
   42+      if (is_null($first_name)) {
   43+        if (isset($this->_data['first_name'])) {
   44+          $first_name = $this->_data['first_name'];
   45+        }
   46+      }
   47+
   48+      return $first_name;
   49+    }
   50+
   51+    function getLastName() {
   52+      static $last_name = null;
   53+
   54+      if (is_null($last_name)) {
   55+        if (isset($this->_data['last_name'])) {
   56+          $last_name = $this->_data['last_name'];
   57+        }
   58+      }
   59+
   60+      return $last_name;
   61+    }
   62+
   63+    function getName() {
   64+      static $name = '';
   65+
   66+      if (empty($name)) {
   67+        if (isset($this->_data['first_name'])) {
   68+          $name .= $this->_data['first_name'];
   69+        }
   70+
   71+        if (isset($this->_data['last_name'])) {
   72+          if (empty($name) === false) {
   73+            $name .= ' ';
   74+          }
   75+
   76+          $name .= $this->_data['last_name'];
   77+        }
   78+      }
   79+
   80+      return $name;
   81+    }
   82+
   83+    function getGender() {
   84+      static $gender = null;
   85+
   86+      if (is_null($gender)) {
   87+        if (isset($this->_data['gender'])) {
   88+          $gender = $this->_data['gender'];
   89+        }
   90+      }
   91+
   92+      return $gender;
   93+    }
   94+
   95+    function getEmailAddress() {
   96+      static $email_address = null;
   97+
   98+      if (is_null($email_address)) {
   99+        if (isset($this->_data['email_address'])) {
   100+          $email_address = $this->_data['email_address'];
   101+        }
   102+      }
   103+
   104+      return $email_address;
   105+    }
   106+
   107+    function getCountryID() {
   108+      static $country_id = null;
   109+
   110+      if (is_null($country_id)) {
   111+        if (isset($this->_data['country_id'])) {
   112+          $country_id = $this->_data['country_id'];
   113+        }
   114+      }
   115+
   116+      return $country_id;
   117+    }
   118+
   119+    function getZoneID() {
   120+      static $zone_id = null;
   121+
   122+      if (is_null($zone_id)) {
   123+        if (isset($this->_data['zone_id'])) {
   124+          $zone_id = $this->_data['zone_id'];
   125+        }
   126+      }
   127+
   128+      return $zone_id;
   129+    }
   130+
   131+    function getDefaultAddressID() {
   132+      static $id = null;
   133+
   134+      if (is_null($id)) {
   135+        if (isset($this->_data['default_address_id'])) {
   136+          $id = $this->_data['default_address_id'];
   137+        }
   138+      }
   139+
   140+      return $id;
   141+    }
   142+
31143     function setCustomerData($customer_id = -1) {
<> 32 -      if (is_numeric($customer_id) && ($customer_id > 0)) {
  33 -        global $osC_Database;
   144+      global $osC_Database;
34145 
<>  146+      $this->_data = array();
   147+
   148+      if (is_numeric($customer_id) && ($customer_id > 0)) {
35149         $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');
<> 36 -        $Qcustomer->bindRaw(':table_customers', TABLE_CUSTOMERS);
   150+        $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS);
37151         $Qcustomer->bindInt(':customers_id', $customer_id);
  38152         $Qcustomer->execute();
  39153 
     
 !
43157           $this->setGender($Qcustomer->value('customers_gender'));
  44158           $this->setFirstName($Qcustomer->value('customers_firstname'));
  45159           $this->setLastName($Qcustomer->value('customers_lastname'));
<> 46 -          $this->setFullName();
47160           $this->setEmailAddress($Qcustomer->value('customers_email_address'));
  48161 
  49162           if (is_numeric($Qcustomer->value('customers_default_address_id')) && ($Qcustomer->value('customers_default_address_id') > 0)) {
  50163             $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);
52165             $Qab->bindInt(':address_book_id', $Qcustomer->value('customers_default_address_id'));
  53166             $Qab->bindInt(':customers_id', $customer_id);
  54167             $Qab->execute();
     
 !
65178 
  66179         $Qcustomer->freeResult();
  67180       }
<>  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+      }
68187     }
  69188 
  70189     function setIsLoggedOn($state) {
  71190       if ($state === true) {
<> 72 -        $this->is_logged_on = true;
   191+        $this->_is_logged_on = true;
73192       } else {
<> 74 -        $this->is_logged_on = false;
   193+        $this->_is_logged_on = false;
75194       }
  76195     }
  77196 
  78197     function isLoggedOn() {
<> 79 -      if ($this->is_logged_on === true) {
   198+      if ($this->_is_logged_on === true) {
80199         return true;
  81200       }
  82201 
  83202       return false;
  84203     }
  85204 
<> 86 -    function isGuest() {
  87 -      return !$this->isLoggedOn();
  88 -    }
  89 -
90205     function setID($id) {
<> 91 -      $this->id = $id;
   206+      if (is_numeric($id) && ($id > 0)) {
   207+        $this->_data['id'] = $id;
   208+      } else {
   209+        $this->_data['id'] = false;
   210+      }
92211     }
  93212 
  94213     function setDefaultAddressID($id) {
<> 95 -      $this->default_address_id = $id;
   214+      if (is_numeric($id) && ($id > 0)) {
   215+        $this->_data['default_address_id'] = $id;
   216+      } else {
   217+        $this->_data['default_address_id'] = false;
   218+      }
96219     }
  97220 
  98221     function hasDefaultAddress() {
<> 99 -      if (is_numeric($this->default_address_id) && ($this->default_address_id > 0)) {
   222+      if (isset($this->_data['default_address_id']) && is_numeric($this->_data['default_address_id'])) {
100223         return true;
<> 101 -      } else {
  102 -        return false;
103224       }
<>  225+
   226+      return false;
104227     }
  105228 
  106229     function setGender($gender) {
<> 107 -      $this->gender = $gender;
   230+      if ( (strtolower($gender) == 'm') || (strtolower($gender) == 'f') ) {
   231+        $this->_data['gender'] = strtolower($gender);
   232+      } else {
   233+        $this->_data['gender'] = false;
   234+      }
108235     }
  109236 
<> 110 -    function setFirstName($firstname) {
  111 -      $this->first_name = $firstname;
   237+    function setFirstName($first_name) {
   238+      $this->_data['first_name'] = $first_name;
112239     }
  113240 
<> 114 -    function setLastName($lastname) {
  115 -      $this->last_name = $lastname;
   241+    function setLastName($last_name) {
   242+      $this->_data['last_name'] = $last_name;
116243     }
  117244 
<> 118 -    function setFullName($fullname = '') {
  119 -      if (empty($fullname)) {
  120 -        $this->full_name = $this->first_name . ' ' . $this->last_name;
  121 -      } else {
  122 -        $this->full_name = $fullname;
  123 -      }
  124 -    }
  125 -
126245     function setEmailAddress($email_address) {
<> 127 -      $this->email_address = $email_address;
   246+      $this->_data['email_address'] = $email_address;
128247     }
  129248 
  130249     function setCountryID($id) {
<> 131 -      $this->country_id = $id;
   250+      $this->_data['country_id'] = $id;
132251     }
  133252 
  134253     function setZoneID($id) {
<> 135 -      $this->zone_id = $id;
   254+      $this->_data['zone_id'] = $id;
136255     }
<>  256+
   257+    function reset() {
   258+      $this->_is_logged_on = false;
   259+      $this->_data = array();
   260+
   261+      if (isset($_SESSION['osC_Customer_data'])) {
   262+        unset($_SESSION['osC_Customer_data']);
   263+      }
   264+    }
<_ 137265   }
  138266 ?>