Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1497
 
1669
 
1669
 
account.php
_> 11 <?php
  22 /*
<> 3 -  $Id: account.php 1497 2007-03-29 13:40:05Z hpdl $
   3+  $Id: account.php 1669 2007-07-20 20:38:29Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2005 osCommerce
   8+  Copyright (c) 2007 osCommerce
99 
  1010   This program is free software; you can redistribute it and/or modify
  1111   it under the terms of the GNU General Public License v2 (1991)
  1212   as published by the Free Software Foundation.
  1313 */
  1414 
<>  15+/**
   16+ * The osC_Account class manages customer accounts
   17+ */
   18+
1519   class osC_Account {
  1620 
<> 17 -    function &getEntry() {
   21+/**
   22+ * Returns the account information for the current customer
   23+ *
   24+ * @access public
   25+ * @return object
   26+ */
   27+
   28+    public static function &getEntry() {
1829       global $osC_Database, $osC_Customer;
  1930 
  2031       $Qaccount = $osC_Database->query('select customers_gender, customers_firstname, customers_lastname, date_format(customers_dob, "%Y") as customers_dob_year, date_format(customers_dob, "%m") as customers_dob_month, date_format(customers_dob, "%d") as customers_dob_date, customers_email_address from :table_customers where customers_id = :customers_id');
     
 !
2536       return $Qaccount;
  2637     }
  2738 
<> 28 -    function getID($email_address) {
   39+/**
   40+ * Returns the customer ID from a given email address
   41+ *
   42+ * @param string $email_address The customers email address
   43+ * @access public
   44+ */
   45+
   46+    public static function getID($email_address) {
2947       global $osC_Database;
  3048 
  3149       $Quser = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address limit 1');
  3250       $Quser->bindTable(':table_customers', TABLE_CUSTOMERS);
  3351       $Quser->bindValue(':customers_email_address', $email_address);
  3452       $Quser->execute();
  3553 
<> 36 -      if ($Quser->numberOfRows() === 1) {
   54+      if ( $Quser->numberOfRows() === 1 ) {
3755         return $Quser->valueInt('customers_id');
  3856       }
  3957 
  4058       return false;
  4159     }
  4260 
<> 43 -    function createEntry($data) {
   61+/**
   62+ * Stores a new customer account entry in the database
   63+ *
   64+ * @param array $data An array containing the customers information
   65+ * @access public
   66+ * @return boolean
   67+ */
   68+
   69+    public static function createEntry($data) {
4470       global $osC_Database, $osC_Session, $osC_Language, $osC_ShoppingCart, $osC_Customer, $osC_NavigationHistory;
  4571 
  4672       $Qcustomer = $osC_Database->query('insert into :table_customers (customers_firstname, customers_lastname, customers_email_address, customers_newsletter, customers_status, customers_ip_address, customers_password, customers_gender, customers_dob, number_of_logons, date_account_created) values (:customers_firstname, :customers_lastname, :customers_email_address, :customers_newsletter, :customers_status, :customers_ip_address, :customers_password, :customers_gender, :customers_dob, :number_of_logons, :date_account_created)');
     
 !
5884       $Qcustomer->bindRaw(':date_account_created', 'now()');
  5985       $Qcustomer->execute();
  6086 
<> 61 -      if ($Qcustomer->affectedRows() === 1) {
   87+      if ( $Qcustomer->affectedRows() === 1 ) {
6288         $customer_id = $osC_Database->nextID();
  6389 
<> 64 -        if (SERVICE_SESSION_REGENERATE_ID == '1') {
   90+        if ( SERVICE_SESSION_REGENERATE_ID == '1' ) {
6591           $osC_Session->recreate();
  6692         }
  6793 
     
 !
7298 
  7399         $osC_NavigationHistory->removeCurrentPage();
  74100 
<> 75 -// build the message content
  76 -        if ((ACCOUNT_GENDER > -1) && isset($data['gender'])) {
  77 -           if ($data['gender'] == 'm') {
   101+// build the welcome email content
   102+        if ( (ACCOUNT_GENDER > -1) && isset($data['gender']) ) {
   103+           if ( $data['gender'] == 'm' ) {
78104              $email_text = sprintf($osC_Language->get('email_addressing_gender_male'), $osC_Customer->getLastName()) . "\n\n";
  79105            } else {
  80106              $email_text = sprintf($osC_Language->get('email_addressing_gender_female'), $osC_Customer->getLastName()) . "\n\n";
     
 !
93119       return false;
  94120     }
  95121 
<> 96 -    function saveEntry($data) {
   122+/**
   123+ * Update the current customer account record in the database
   124+ *
   125+ * @param array $data An array containing the customer account information
   126+ * @access public
   127+ * @return boolean
   128+ */
   129+
   130+    public static function saveEntry($data) {
97131       global $osC_Database, $osC_Customer;
  98132 
  99133       $Qcustomer = $osC_Database->query('update :table_customers set customers_gender = :customers_gender, customers_firstname = :customers_firstname, customers_lastname = :customers_lastname, customers_email_address = :customers_email_address, customers_dob = :customers_dob, date_account_last_modified = :date_account_last_modified where customers_id = :customers_id');
     
 !
107141       $Qcustomer->bindInt(':customers_id', $osC_Customer->getID());
  108142       $Qcustomer->execute();
  109143 
<> 110 -      if ($Qcustomer->affectedRows() === 1) {
  111 -        return true;
  112 -      }
  113 -
  114 -      return false;
   144+      return ( $Qcustomer->affectedRows() === 1 );
115145     }
  116146 
<> 117 -    function savePassword($password, $customer_id = null) {
   147+/**
   148+ * Updates the password in a customers account
   149+ *
   150+ * @param string $password The new password
   151+ * @param integer $customer_id The ID of the customer account to update
   152+ * @access public
   153+ * @return boolean
   154+ */
   155+
   156+    public static function savePassword($password, $customer_id = null) {
118157       global $osC_Database, $osC_Customer;
  119158 
<> 120 -      if (is_numeric($customer_id) === false) {
   159+      if ( !is_numeric($customer_id) ) {
121160         $customer_id = $osC_Customer->getID();
  122161       }
  123162 
     
 !
128167       $Qcustomer->bindInt(':customers_id', $customer_id);
  129168       $Qcustomer->execute();
  130169 
<> 131 -      if ($Qcustomer->affectedRows() === 1) {
  132 -        return true;
  133 -      }
  134 -
  135 -      return false;
   170+      return ( $Qcustomer->affectedRows() === 1 );
136171     }
  137172 
<> 138 -    function checkEntry($email_address) {
   173+/**
   174+ * Checks if a customer account record exists with the provided e-mail address
   175+ *
   176+ * @param string $email_address The e-mail address to check for
   177+ * @access public
   178+ * @return boolean
   179+ */
   180+
   181+    public static function checkEntry($email_address) {
139182       global $osC_Database;
  140183 
  141184       $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address limit 1');
  142185       $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
  143186       $Qcheck->bindValue(':customers_email_address', $email_address);
  144187       $Qcheck->execute();
  145188 
<> 146 -      if ($Qcheck->numberOfRows() === 1) {
  147 -        return true;
  148 -      }
  149 -
  150 -      return false;
   189+      return ( $Qcheck->numberOfRows() === 1 );
151190     }
  152191 
<> 153 -    function checkPassword($password, $email_address = null) {
   192+/**
   193+ * Checks if a password matches the current or provided customer account
   194+ *
   195+ * @param string $password The unencrypted password to confirm
   196+ * @param string $email_address The email address of the customer account to check against
   197+ * @access public
   198+ * @return boolean
   199+ */
   200+
   201+    public static function checkPassword($password, $email_address = null) {
154202       global $osC_Database, $osC_Customer;
  155203 
<> 156 -      if ($email_address === null) {
   204+      if ( empty($email_address) ) {
157205         $Qcheck = $osC_Database->query('select customers_password from :table_customers where customers_id = :customers_id');
  158206         $Qcheck->bindTable(':table_customers', TABLE_CUSTOMERS);
  159207         $Qcheck->bindInt(':customers_id', $osC_Customer->getID());
     
 !
165213         $Qcheck->execute();
  166214       }
  167215 
<> 168 -      if ($Qcheck->numberOfRows() === 1) {
   216+      if ( $Qcheck->numberOfRows() === 1 ) {
169217         if ( (strlen($password) > 0) && (strlen($Qcheck->value('customers_password')) > 0) ) {
  170218           $stack = explode(':', $Qcheck->value('customers_password'));
  171219 
<> 172 -          if (sizeof($stack) === 2) {
  173 -            if (md5($stack[1] . $password) == $stack[0]) {
  174 -              return true;
  175 -            }
   220+          if ( sizeof($stack) === 2 ) {
   221+            return ( md5($stack[1] . $password) == $stack[0] );
176222           }
  177223         }
  178224       }
  179225 
  180226       return false;
  181227     }
  182228 
<> 183 -    function checkDuplicateEntry($email_address) {
   229+/**
   230+ * Checks if an e-mail address already exists in another customer account record
   231+ *
   232+ * @param string $email_address The e-mail address to check
   233+ * @access public
   234+ * @return boolean
   235+ */
   236+
   237+    public static function checkDuplicateEntry($email_address) {
184238       global $osC_Database, $osC_Customer;
  185239 
  186240       $Qcheck = $osC_Database->query('select customers_id from :table_customers where customers_email_address = :customers_email_address and customers_id != :customers_id limit 1');
     
 !
189243       $Qcheck->bindInt(':customers_id', $osC_Customer->getID());
  190244       $Qcheck->execute();
  191245 
<> 192 -      if ($Qcheck->numberOfRows() === 1) {
  193 -        return true;
  194 -      }
  195 -
  196 -      return false;
   246+      return ( $Qcheck->numberOfRows() === 1 );
<_ 197247     }
  198248   }
  199249 ?>