customer Class Reference

List of all members.

Public Member Functions

Static Public Member Functions

Public Attributes

Protected Member Functions

Static Protected Attributes

Private Member Functions

Static Private Member Functions

  • static CleanKey ($array, $new_array=array())
    clean key in array result for customers; function recursive
  • static PassmessageStack ($class, $mess, $type='error')

Detailed Description

Definition at line 16 of file page.customer.php.


Constructor & Destructor Documentation

customer::__construct ( customer_id = ''  )  [protected]

Constructeur.

Parameters:
@a int id customer

Definition at line 39 of file page.customer.php.

00039                                                   {
00040 
00041     if(!empty($customer_id)) $this->the_customer($customer_id);
00042     if(!function_exists('tep_validate_password')) require_once(DIR_WS_FUNCTIONS.'password_funcs.php');
00043 
00044     return $this->customer;
00045   }


Member Function Documentation

customer::add_var_customer ( key,
value 
)

add data in array current user

Parameters:
$key string
$value string
Returns:
non

Definition at line 106 of file page.customer.php.

00106                                                   {
00107       $this->customer[$key]=$value;
00108     }

customer::address_label ( customers_id,
address_id = 1,
html = false,
boln = '',
eoln = "\n" 
) [static]

Return a formatted address TABLES: customers, address_book.

Parameters:
$customers_id insteger
$address_id integer
$html boolean
$boln string/null
$eoln string

Definition at line 538 of file page.customer.php.

Referenced by tep_address_label().

00538                                                                                                                 {
00539     $DB=Database::getInstance();
00540 
00541     $address_query = $DB->query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'");
00542     $address = $address_query->fetchAssoc();
00543 
00544     $format_id = tep_get_address_format_id($address['country_id']);
00545 
00546     return tep_address_format($format_id, $address, $html, $boln, $eoln);
00547   }

customer::CheckData ( _post,
ErrorClass = '',
insert = true 
) [private]

Definition at line 859 of file page.customer.php.

Referenced by userInsert(), and userUpdate().

00859                                                                 {
00860     global $page;
00861     $DB=Database::getInstance();
00862     $sortie = array();
00863     $error = false;
00864 
00865     if ( ($resul=$this->CheckDataName($_post, 'addressbook')) && $resul !=false && is_array($resul)) $sortie=$resul;
00866     else $error = true;
00867 
00868     if (_cst_bool('ACCOUNT_DOB')) $sortie['dob'] = tep_db_prepare_input($_post['dob']);
00869     $sortie['email_address'] = tep_db_prepare_input($_post['email_address']);
00870 
00871     $sortie['telephone'] = (isset($_post['telephone']) ? tep_db_prepare_input($_post['telephone']) :'');
00872 
00873     $sortie['fax'] = (_cst_bool('ACCOUNT_FAXNUM')) ? tep_db_prepare_input($_post['fax']) : '';
00874     $sortie['newsletter'] = (isset($_post['newsletter'])) ? tep_db_prepare_input($_post['newsletter']) : false ;
00875 
00876     if (_cst_bool('ACCOUNT_DOB'))
00877       if (checkdate(substr(tep_date_raw($sortie['dob']), 4, 2), substr(tep_date_raw($sortie['dob']), 6, 2), substr(tep_date_raw($sortie['dob']), 0, 4)) == false) {
00878         $error = true;
00879         self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'dob'), ENTRY_DATE_OF_BIRTH_ERROR);
00880       }
00881 
00882 
00883     if (strlen($sortie['email_address']) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
00884       $error = true;
00885       self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'email_address'), ENTRY_EMAIL_ADDRESS_ERROR);
00886 
00887     } elseif (tep_validate_email($sortie['email_address']) == false) {
00888       $error = true;
00889       self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'email_address'), ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
00890 
00891     }
00892     elseif($insert)  {
00893       $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($sortie['email_address']) . "'");
00894       $check_email = tep_db_fetch_array($check_email_query);
00895       if ($check_email['total'] > 0) {
00896         $error = true;
00897         self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'email_address'), ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
00898       }
00899     }
00900 
00901 
00902     if (isset($_post['telephone']) && strlen($sortie['telephone']) < ENTRY_TELEPHONE_MIN_LENGTH) {
00903       $error = true;
00904       self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'telephone'), ENTRY_TELEPHONE_NUMBER_ERROR);
00905     }
00906 
00907 //     if ( ($resul=$this->CheckDataPassword($_post)) && $resul !=false && is_array($resul)) $sortie=array_merge($sortie,$resul);
00908 //     else $error = true;
00909 
00910     //BOF Customers extra fields
00911     $extra_fields_query = tep_db_query("select ce.fields_id, ce.fields_input_type, ce.fields_required_status, cei.fields_name, ce.fields_status, ce.fields_input_type, ce.fields_size from " . TABLE_EXTRA_FIELDS . " ce, " . TABLE_EXTRA_FIELDS_INFO . " cei where ce.fields_status=1 and ce.fields_admin=0 and cei.fields_id=ce.fields_id  and cei.languages_id =" . $this->languages_id);
00912     while($extra_fields = tep_db_fetch_array($extra_fields_query)){
00913       if(strlen($_post['fields_' . $extra_fields['fields_id']])<$extra_fields['fields_size']){
00914         $error = true;
00915         self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'extra_fields'), sprintf(ENTRY_EXTRA_FIELDS_LENG_ERROR,$extra_fields['fields_name'],$extra_fields['fields_size']));
00916       }
00917       elseif($extra_fields['fields_required_status'] && empty($_post['fields_' . $extra_fields['fields_id']]) ){
00918         $error = true;
00919         self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'extra_fields'), sprintf(ENTRY_EXTRA_FIELDS_REQUIRED_ERROR,$extra_fields['fields_name']));
00920       }
00921       else $sortie['fields_' . $extra_fields['fields_id']]=tep_db_prepare_input($_post['fields_' . $extra_fields['fields_id']]);
00922     }
00923 
00924     return (!$error) ? $sortie : false;
00925   }

customer::CheckDataAddressBook ( _post,
ErrorClass = '' 
)

Definition at line 740 of file page.customer.php.

Referenced by userAddAddressBook(), and userInsert().

00740                                                              {
00741     global $page;
00742     $sortie = array();
00743     $DB=Database::getInstance();
00744     $error = false;
00745 
00746     if ( ($resul=$this->CheckDataName($_POST, 'addressbook')) && $resul !=false && is_array($resul)) $sortie=$resul;
00747     else $error = true;
00748 
00749     if(_cst_bool('ACCOUNT_COMPANY')) {
00750       $sortie['company'] = (isset($_post['company']) ? tep_db_prepare_input($_post['company']) : '');
00751       $sortie['company_tax_id'] =(isset($_post['company_tax_id']) ?  tep_db_prepare_input($_post['company_tax_id']): '');
00752     }
00753 
00754     $sortie['street_address'] = (isset($_post['street_address']) ? tep_db_prepare_input($_post['street_address']): '');
00755     if (_cst_bool('ACCOUNT_SUBURB')) $sortie['suburb'] = (isset($_post['suburb']) ? tep_db_prepare_input($_post['suburb']): '');
00756     $sortie['postcode'] = (isset($_post['postcode']) ? tep_db_prepare_input($_post['postcode']): '');
00757     $sortie['city'] = (isset($_post['city']) ? tep_db_prepare_input($_post['city']): '');
00758 
00759     $sortie['country'] =(isset($_post['country']) ?   (_cst_bool('ACCOUNT_COUNTRY')? tep_db_prepare_input($_post['country']) : STORE_COUNTRY ) : '');
00760 
00761     if (_cst_bool('ACCOUNT_STATE')) {
00762       $sortie['state'] = tep_db_prepare_input($_post['state']);
00763       if (isset($_post['zone_id']))  $sortie['zone_id'] = tep_db_prepare_input($_post['zone_id']);
00764       else   $sortie['zone_id'] = false;
00765     }
00766 
00767 
00768     if (strlen($sortie['street_address']) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
00769       $error = true;
00770       self::PassmessageStack( (!empty($ErrorClass)?$ErrorClass:'street_address'), ENTRY_STREET_ADDRESS_ERROR);
00771     }
00772 
00773     if (strlen($sortie['postcode']) < ENTRY_POSTCODE_MIN_LENGTH) {
00774       $error = true;
00775       self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'postcode'), ENTRY_POST_CODE_ERROR);
00776     }
00777 
00778     if (strlen($sortie['city']) < ENTRY_CITY_MIN_LENGTH) {
00779       $error = true;
00780       self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'city'), ENTRY_CITY_ERROR);
00781     }
00782 
00783     if (!isset($sortie['country']) || is_numeric($sortie['country']) == false) {
00784       $error = true;
00785       self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'country'), ENTRY_COUNTRY_ERROR);
00786     }
00787 
00788     if (_cst_bool('ACCOUNT_STATE') && isset($sortie['country'])) {
00789       $zone_id = 0;
00790       $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$sortie['country'] . "'");
00791       $check = tep_db_fetch_array($check_query);
00792       $entry_state_has_zones = ($check['total'] > 0);
00793       if ($entry_state_has_zones == true) {
00794         $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$sortie['country'] . "' and (zone_name like '" . tep_db_input($sortie['state']) . "%' or zone_code like '%" . tep_db_input($sortie['state']) . "%')");
00795         if (tep_db_num_rows($zone_query) == 1) {
00796           $zone = tep_db_fetch_array($zone_query);
00797           $zone_id = $zone['zone_id'];
00798         } else {
00799           $error = true;
00800           self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'state'), ENTRY_STATE_ERROR_SELECT);
00801         }
00802       } else {
00803         if (strlen($sortie['state']) < ENTRY_STATE_MIN_LENGTH) {
00804           $error = true;
00805           self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'state'), ENTRY_STATE_ERROR);
00806         }
00807       }
00808     }
00809 
00810     return (!$error) ? $sortie : false;
00811   }

customer::CheckDataName ( _post,
ErrorClass = '' 
) [private]

Definition at line 819 of file page.customer.php.

Referenced by CheckData(), and CheckDataAddressBook().

00819                                                        {
00820     $sortie = array();
00821     $error = false;
00822 
00823     if (_cst_bool('ACCOUNT_GENDER')) {
00824       if (isset($_post['gender'])) {
00825         $sortie['gender'] = tep_db_prepare_input($_post['gender']);
00826       } else {
00827         $sortie['gender'] = false;
00828       }
00829     }
00830 
00831     $sortie['firstname'] = (isset($_post['firstname']))?tep_db_prepare_input($_post['firstname']) : '';
00832     $sortie['lastname'] = (isset($_post['lastname']))?tep_db_prepare_input($_post['lastname']): '';
00833 
00834     if (_cst_bool('ACCOUNT_GENDER') && !in_array($sortie['gender'],array('m','f','l')) ) {
00835       $error = true;
00836       self::PassmessageStack('gender', ENTRY_GENDER_ERROR);
00837     }
00838 
00839     if (strlen($sortie['firstname']) < ENTRY_FIRST_NAME_MIN_LENGTH) {
00840       $error = true;
00841       self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'firstname'), ENTRY_FIRST_NAME_ERROR);
00842     }
00843 
00844     if (strlen($sortie['lastname']) < ENTRY_LAST_NAME_MIN_LENGTH) {
00845       $error = true;
00846       self::PassmessageStack((!empty($ErrorClass)?$ErrorClass:'lastname'), ENTRY_LAST_NAME_ERROR);
00847     }
00848 
00849     return (!$error) ? $sortie : false;
00850   }

customer::CheckDataPassword ( _post  )  [private]

Definition at line 709 of file page.customer.php.

Referenced by checkPasswordProcess(), and userInsert().

00709                                             {
00710     global $page;
00711     $sortie = array();
00712     $error=false;
00713 
00714     $sortie['password'] = tep_db_prepare_input($_post['password']);
00715     $sortie['confirmation'] = tep_db_prepare_input($_post['confirmation']);
00716 
00717 
00718     if (strlen($sortie['password']) < ENTRY_PASSWORD_MIN_LENGTH) {
00719       $error = true;
00720       self::PassmessageStack('account_password', ENTRY_PASSWORD_ERROR);
00721     }
00722     elseif (strlen($sortie['confirmation']) < ENTRY_PASSWORD_MIN_LENGTH) {
00723       $error = true;
00724       self::PassmessageStack('account_password', ENTRY_PASSWORD_ERROR);
00725     }
00726     elseif ($sortie['password'] != $sortie['confirmation']) {
00727       $error = true;
00728       self::PassmessageStack('confirmation', ENTRY_PASSWORD_ERROR_NOT_MATCHING);
00729     }
00730 
00731     return (!$error) ? $sortie : false;
00732   }

customer::checkHash ( hash  ) 

check hash for valid account for current customers and up customers status

Parameters:
hash string
Returns:
boolean true/false

Definition at line 1041 of file page.customer.php.

01041                                   {
01042     $this->detail_long_cust();
01043 
01044     if( md5($this->customer['customers_info_date_account_last_modified'].strtoupper($this->customer['customers_firstname'].$this->customer['customers_lastname'])) == $hash) {
01045       $DB=Database::getInstance();
01046       $DB->query("UPDATE " . TABLE_CUSTOMERS . " SET customers_status='1' WHERE customers_id='".(int)$this->customer['customers_id']."' ");
01047 
01048       return true;
01049     }
01050 
01051     return false;
01052   }

customer::CheckMailAndPass ( password,
email_address 
)

test mail and password for login

Parameters:
$password string
$email_address string
Returns:
boolean false Or integer customers_id

include the password crypto functions

Definition at line 165 of file page.customer.php.

00165                                                                {
00166       $DB=Database::getInstance();
00167       $check_customer_query = $DB->query("select customers_id,customers_password from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'  ");
00168       $check_customer = $check_customer_query->fetchAssoc();
00169 
00171       if(!function_exists('tep_validate_password')) require(DIR_WS_FUNCTIONS . 'password_funcs.php');
00172 
00173       return (!tep_validate_password($password, $check_customer['customers_password'])? false : (int)$check_customer['customers_id'] ) ;
00174     }

customer::checkPasswordProcess ( current,
new,
confirmation,
mode = 1 
) [private]

test and control pre-update password the check process is:

  • min lengt entry password_current
  • min lengt entry password_new
  • matching password_new vs password_confirmation
    Parameters:
    $current string
    $new string
    $confirmation string
    $mode integer (default:1)
    Returns:
    boolean

Definition at line 651 of file page.customer.php.

Referenced by userUpdatepassword().

00651                                                                                {
00652     global $page;
00653     $DB=Database::getInstance();
00654     $error = false;
00655 
00656     switch ($mode) {
00657       case 2:
00658         if (strlen($new) < ENTRY_PASSWORD_MIN_LENGTH) {
00659           $error = true;
00660 
00661           self::PassmessageStack('account_password', ENTRY_PASSWORD_NEW_ERROR);
00662         }
00663 
00664         if ($error == false)return true;
00665         else return false;
00666       break;
00667 
00668       case 1:
00669       default:
00670 /*
00671         if (strlen($current) < ENTRY_PASSWORD_MIN_LENGTH) {
00672           $error = true;
00673 
00674           self::PassmessageStack('account_password', ENTRY_PASSWORD_CURRENT_ERROR);
00675         }*/
00676         if ( ($resul=$this->CheckDataPassword(array('password'=>$new, 'confirmation'=>$confirmation))) && $resul !=false && is_array($resul)){
00677           $check_customer_query = tep_db_query("select customers_password from " . TABLE_CUSTOMERS . " where customers_id = '" . $this->customer_id . "'");
00678           $check_customer = tep_db_fetch_array($check_customer_query);
00679 
00680           if (tep_validate_password($current, $check_customer['customers_password'])) {
00681             self::PassmessageStack('account', SUCCESS_PASSWORD_UPDATED, 'success');
00682             return true;
00683           }
00684           else {
00685             self::PassmessageStack('account_password', ERROR_CURRENT_PASSWORD_NOT_MATCHING);
00686             return false;
00687           }
00688       }
00689     }
00690   }

customer::CleanKey ( array,
new_array = array() 
) [static, private]

clean key in array result for customers; function recursive

Parameters:
$array array data
$new_array array data result, for recursive
Returns:
array

Definition at line 624 of file page.customer.php.

00624                                                                {
00625 
00626       $e=strlen('entry_');
00627       $c=strlen('customers_');
00628       foreach($array as $k=>$v){
00629         if(is_array($v)) $new_array = self::CleanKey($v, $new_array);
00630         elseif( substr($k,0,$e) =='entry_' ) $new_array[substr($k,$e)] =$v;
00631         elseif( substr($k,0,$c) =='customers_' ) $new_array[substr($k,$c)] =$v;
00632         else $new_array[$k] =$v;
00633       }
00634 
00635       return $new_array;
00636   }

customer::closeSession (  )  [static]

close and destruct session

Definition at line 997 of file page.customer.php.

00997                                        {
00998     global $cart;
00999     tep_session_unregister('customer_id');
01000     tep_session_unregister('customer_default_address_id');
01001     tep_session_unregister('customer_first_name');
01002     tep_session_unregister('customer_country_id');
01003     tep_session_unregister('customer_zone_id');
01004     tep_session_unregister('comments');
01005     tep_session_unregister('billto');
01006     tep_session_unregister('sendto');
01007     tep_session_unregister('shipping');
01008     tep_session_unregister('payment');
01009     tep_session_unregister('coupon');
01010     tep_session_unregister('sppc_customer_group_id');
01011     tep_session_unregister('sppc_customer_group_show_tax');
01012     tep_session_unregister('sppc_customer_group_tax_exempt');
01013     tep_session_unregister('sppc_customer_specific_taxes_exempt');
01014     tep_session_unregister('country_id');
01015     tep_session_unregister('state_id');
01016     $cart->reset();
01017   }

customer::count_customer_address_book_entries ( id = '',
check_session = true 
) [static]
Parameters:
$id customer id
$check_session boolean
Returns:
integer

Definition at line 483 of file page.customer.php.

Referenced by tep_count_customer_address_book_entries().

00483                                                                                               {
00484     global $customer_id;
00485     $DB=Database::getInstance();
00486     if (is_numeric($id) == false) {
00487       if (tep_session_is_registered('customer_id'))  $id = $customer_id;
00488        else   return 0;
00489     }
00490 
00491     if ($check_session == true) {
00492       if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) {
00493         return 0;
00494       }
00495     }
00496 
00497     $addresses_query = $DB->query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$id . "'");
00498     $addresses = $addresses_query->fetchAssoc();
00499 
00500     return $addresses['total'];
00501   }

customer::count_customer_orders ( id = '',
check_session = true 
) [static]

count order for customers

Parameters:
$id integer id customer
$check_session boolean control session
Returns:
integer (number of order)

Definition at line 456 of file page.customer.php.

Referenced by tep_count_customer_orders().

00456                                                                                 {
00457     $DB=Database::getInstance();
00458     global $customer_id;
00459 
00460     if (is_numeric($id) == false) {
00461       if (tep_session_is_registered('customer_id'))  $id = $customer_id;
00462       else return 0;
00463     }
00464 
00465     if ($check_session == true) {
00466       if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) {
00467         return 0;
00468       }
00469     }
00470 
00471     $orders_check_query = $DB->query("select count(*) as total from " . TABLE_ORDERS . " where customers_id = '" . (int)$id . "'");
00472     $orders_check = $orders_check_query->fetchAssoc();
00473 
00474     return $orders_check['total'];
00475   }

customer::creatValidHash (  ) 

creat valid hash, for account actived by email confirm for current customers

Returns:
hash string

Definition at line 1025 of file page.customer.php.

01025                                   {
01026     $DB=Database::getInstance();
01027 
01028     $date = date('Y-m-d H:i:s');
01029 
01030     $DB->query("UPDATE " . TABLE_CUSTOMERS_INFO . " SET customers_info_date_account_last_modified='".$date."' WHERE customers_info_id   ='".(int)$this->customer['customers_id']."' ");
01031 
01032     return md5($date.strtoupper($this->customer['customers_firstname'].$this->customer['customers_lastname']));
01033   }

function customer::definePostMess ( mode = 0  )  [static]

define method efor messagestack

Parameters:
$mode 0: add 1: add_session

Definition at line 613 of file page.customer.php.

Referenced by address_book::check_action().

00613                                                 {
00614     self::$methodeMessage = ((!$mode)? 'add' : 'add_session');
00615   }

customer::detail_cust (  )  [private]

Reconstruit le detail d'un customer Prend en Charge la gestion des extra_fields.

Returns:
array

Definition at line 87 of file page.customer.php.

Referenced by the_customer().

00087                                   {
00088       $account_query = tep_db_query("select customers_id, customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_telephone, customers_fax, customers_newsletter,customers_default_address_id, c.customers_group_id,  c.customers_group_ra, c.customers_payment_allowed, c.customers_shipment_allowed, c.customers_order_total_allowed, c.customers_specific_taxes_exempt , customers_status, customers_shopping_points  from " . TABLE_CUSTOMERS . " c where customers_id = '" . $this->customer_id . "'");
00089       $account = tep_db_fetch_array($account_query);
00090 
00091       $value_query = tep_db_query("select fields_name,fields_key, value from " . TABLE_EXTRA_FIELDS . " ce, " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " cef, " . TABLE_EXTRA_FIELDS_INFO . " cei where cef.customers_id= '" . $this->customer_id . "'  and cei.fields_id=ce.fields_id and cef.fields_id= cei.fields_id  and languages_id='".$this->languages_id."' and ce.fields_admin !=1 " );
00092 
00093       while ($t=tep_db_fetch_array($value_query) )
00094         $account[(!empty($t['fields_key'])? $t['fields_key']: $t['fields_name'])]=$t['value'];
00095 
00096       $this->customer=$account;
00097     }

customer::detail_long_cust (  ) 

full data user

Returns:
array

Definition at line 115 of file page.customer.php.

Referenced by checkHash().

00115                                       {
00116       $account_query = tep_db_query("select * from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . $this->customer_id . "'");
00117       $account = tep_db_fetch_array($account_query);
00118       return $this->customer=array_merge((array)$this->customer,(array)$account);
00119     }

static customer::getInstance ( customer_id = ''  )  [static]
customer::initSession ( user  )  [static]

Session creat / restore for current user.

Parameters:
$user object | array

Grp confirmed

Definition at line 933 of file page.customer.php.

00933                                            {
00934     global $cart;
00935 
00936     $DB=Database::getInstance();
00937     if (_cst_bool('SESSION_RECREATE'))  tep_session_recreate();
00938 
00939     if(!is_object($user)) $user=new objectInfo($user);
00940 
00941     $_SESSION['customer_id']=$customer_id=(isset($user->customers_id)?$user->customers_id : $user->id );
00942     $_SESSION['customer_first_name']=$customer_first_name =(isset($user->customers_firstname)? $user->customers_firstname : $user->firstname);
00943     $_SESSION['customer_default_address_id']=$customer_default_address_id = (isset($user->customers_default_address_id)? $user->customers_default_address_id : $user->address_book_id);
00944     $customers_group_ra = (isset($user->customers_group_ra)? $user->customers_group_ra: $user->group_ra);
00945     $_SESSION['sppc_customer_group_id']=$sppc_customer_group_id = (isset($user->customers_group_id)? $user->customers_group_id: 0 );
00946     $customers_specific_taxes_exempt = (isset($user->customers_specific_taxes_exempt)? $user->customers_specific_taxes_exempt : '' );
00947 
00948     $check_country_query = $DB->query($sql="select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$customer_default_address_id. "'");
00949     $check_country = $check_country_query->fetchAssoc();
00950 
00951     $_SESSION['customer_country_id']=$customer_country_id = $check_country['entry_country_id'];
00952     if (_cst_bool('ACCOUNT_STATE'))
00953       $_SESSION['customer_zone_id']=$customer_zone_id = $check_country['entry_zone_id'];
00954 
00955     $check_customer_group_tax = tep_db_query($sql="select customers_group_show_tax, customers_group_tax_exempt, group_specific_taxes_exempt, group_discount from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$sppc_customer_group_id . "'");
00956     $customer_group_tax = tep_db_fetch_array($check_customer_group_tax);
00957 
00959     if($customers_group_ra ===1) {
00960       $_SESSION['sppc_customer_group_show_tax']=$sppc_customer_group_show_tax = (int)$customer_group_tax['customers_group_show_tax'];
00961       $_SESSION['sppc_customer_group_tax_exempt']=$sppc_customer_group_tax_exempt = (int)$customer_group_tax['customers_group_tax_exempt'];
00962       /*$_SESSION['group_specific_taxes_exempt']=*/$group_specific_taxes_exempt = $customer_group_tax['group_specific_taxes_exempt'];
00963       $_SESSION['sppc_group_discount']=$sppc_group_discount = $customer_group_tax['group_discount'];
00964       if (tep_not_null($customers_specific_taxes_exempt)) $sppc_customer_specific_taxes_exempt = $customers_specific_taxes_exempt;
00965       elseif (tep_not_null($group_specific_taxes_exempt))  $sppc_customer_specific_taxes_exempt = $group_specific_taxes_exempt;
00966       else  $sppc_customer_specific_taxes_exempt = '';
00967     }
00968     else {
00969       $_SESSION['sppc_customer_group_show_tax']=$sppc_customer_group_show_tax = 1;
00970       $_SESSION['sppc_customer_group_tax_exempt']=$sppc_customer_group_tax_exempt = '';
00971       $group_specific_taxes_exempt = '';
00972       if (tep_not_null($customers_specific_taxes_exempt)) $sppc_customer_specific_taxes_exempt = $customers_specific_taxes_exempt;
00973       elseif (tep_not_null($group_specific_taxes_exempt))  $sppc_customer_specific_taxes_exempt = $group_specific_taxes_exempt;
00974       else  $sppc_customer_specific_taxes_exempt = '';
00975     }
00976 
00977     if (tep_not_null($sppc_customer_specific_taxes_exempt)) $_SESSION['sppc_customer_specific_taxes_exempt']= $sppc_customer_specific_taxes_exempt;
00978 
00979 
00980     // add in session last logon
00981     $cu=self::$_instance;
00982     $cu->detail_long_cust();
00983     $_SESSION['last_logon'] = $cu->customer['customers_info_date_of_last_logon'];
00984 
00985     // restore cart contents
00986     $cart->restore_contents();
00987 
00988 
00989     // update logon user
00990     $DB->query("UPDATE " . TABLE_CUSTOMERS_INFO . " SET customers_info_date_of_last_logon=NOW() , customers_info_number_of_logons = customers_info_number_of_logons + 1 WHERE customers_info_id         ='".(int)$customer_id."' ");
00991   }

static customer::PassmessageStack ( class,
mess,
type = 'error' 
) [static, private]

Definition at line 697 of file page.customer.php.

Referenced by CheckData(), CheckDataAddressBook(), CheckDataName(), CheckDataPassword(), checkPasswordProcess(), userNotifiUpdate(), userUpdate(), and userUpdatepassword().

00697                                                                         {
00698     global $page;
00699     $methode=self::$methodeMessage;
00700     $page->messageStack->$methode($class, $mess, $type);
00701   }

customer::resetInstance (  )  [static]

Definition at line 59 of file page.customer.php.

00059                                         {
00060     self::$_instance = null;
00061     return self::getInstance();
00062   }

customer::search ( key,
value 
) [static]

search in db for key and value in tale master customers

Parameters:
key col in db
value for col
Returns:
customers_id integer

Definition at line 1061 of file page.customer.php.

01061                                              {
01062     $value=tep_db_prepare_input($value);
01063     $check_query = tep_db_query("select * from " . TABLE_CUSTOMERS . " where ".$key." = '" . tep_db_input($value) . "' LIMIT 1");
01064 
01065     if(!(bool)tep_db_num_rows($check_query)) return false;
01066 
01067     $_query=$check_query->fetchAssoc();
01068 
01069     return (!isset($_query[$key])?false: $_query['customers_id'] );
01070   }

customer::the_customer ( customer_id = ''  ) 

fetch user data

Parameters:
$customer_id integer
Returns:
array

Definition at line 70 of file page.customer.php.

Referenced by __construct().

00070                                                {
00071     global $page;
00072     if(!is_numeric($customer_id)) return $this->customer;
00073 
00074     $this->languages_id=$page->the_var('languages_id');
00075     $this->customer_id=(int)$customer_id;
00076     $this->detail_cust();
00077 
00078     return $this->customer;
00079   }

customer::userAddAddressBook ( _post,
update = false 
)

Definition at line 573 of file page.customer.php.

00573                                                            {
00574 
00575     if ( ($resul=$this->CheckDataAddressBook($_post)) && $resul !=false && is_array($resul)) {
00576 
00577       $db=$sql_data_array = array('customers_id' => $this->customer_id,
00578                               'entry_firstname' => $resul['firstname'],
00579                               'entry_lastname' => $resul['lastname'],
00580                               'entry_street_address' => $resul['street_address'],
00581                               'entry_postcode' => $resul['postcode'],
00582                               'entry_city' => $resul['city'],
00583                               'entry_country_id' => $resul['country']);
00584 
00585       if (_cst_bool('ACCOUNT_GENDER')) $sql_data_array['entry_gender'] = $resul['gender'];
00586       if (_cst_bool('ACCOUNT_COMPANY')){
00587         $sql_data_array['entry_company'] = $resul['company'];
00588         $sql_data_array['entry_company_tax_id'] = $resul['company_tax_id'];
00589       }
00590       if (_cst_bool('ACCOUNT_SUBURB')) $sql_data_array['entry_suburb'] = $resul['suburb'];
00591       if (_cst_bool('ACCOUNT_STATE')) {
00592         if (isset($resul['zone_id']) && $resul['zone_id'] > 0) {
00593           $sql_data_array['entry_zone_id'] = @$resul['zone_id'];
00594           $sql_data_array['entry_state'] = '';
00595         } else {
00596           $sql_data_array['entry_zone_id'] = '0';
00597           $sql_data_array['entry_state'] = @$resul['state'];
00598         }
00599       }
00600 
00601       if(!$update) $res=tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
00602       elseif($update !=false) $res=tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', " address_book_id='".(int)$update."' ");
00603     }
00604 
00605     return (isset($res)? $res : false);
00606   }

customer::userDelete (  ) 

delete customer current

call method module account

Definition at line 508 of file page.customer.php.

00508                               {
00509         $DB=Database::getInstance();
00510 
00511         $DB->query("DELETE FROM " . TABLE_CUSTOMERS . " WHERE customers_id = '" . $this->customer_id . "'");
00512 
00513         $DB->query("DELETE FROM " . TABLE_CUSTOMERS_INFO . " WHERE customers_info_id = '" . $this->customer_id . "'");
00514 
00515         $DB->query("DELETE FROM " . TABLE_ADDRESS_BOOK . " WHERE customers_id = '" . $this->customer_id . "'");
00516 
00520       $page=page::getInstance();
00521       $aca_account=$page->new_class('account',$this->customer_id);
00522 
00523       $aca_account->userDelete($this->customer_id);
00524 
00525         return true;
00526   }

customer::userInsert ( _post  ) 

creat account

Parameters:
$_post array
Returns:
object / false

include the password crypto functions

extra fields sauf specifique admin

value in list mutli

call method module account

Definition at line 183 of file page.customer.php.

00183                                       {
00184       global $page;
00185 
00186       $this->languages_id=$page->the_var('languages_id');
00187       $newcustomer=array();
00188 
00189       if ( ( ($resul=$this->CheckData($_post)) && $resul !=false && is_array($resul))
00190           && ( ($pass=$this->CheckDataPassword($_post)) && $pass !=false && is_array($pass) ) ){
00191 
00192         $resul=array_merge($pass,$resul);
00193 
00195         require_once(DIR_WS_FUNCTIONS . 'password_funcs.php');
00196 
00197         if (_cst_bool('CUSTOMER_FORCE_UCWORDS')) {
00198           $resul['lastname']=ucwords($resul['lastname']);
00199           $resul['firstname']=ucwords($resul['firstname']);
00200         }
00201         if (_cst_bool('CUSTOMER_FORCE_STRTOUPPER')) {
00202           $resul['lastname']=strtoupper($resul['lastname']);
00203         }
00204 
00205         $check_customer['customers_group_id']=( (_cst_bool('ACCOUNT_COMPANY') && isset($resul['company_tax_id']))? 0 : 1 );
00206 
00207         $sql_data_array = array('customers_firstname' => $resul['firstname'],
00208                                 'customers_lastname' => $resul['lastname'],
00209                                 'customers_email_address' => $resul['email_address'],
00210                                 'customers_telephone' => $resul['telephone'],
00211                                 'customers_fax' => $resul['fax'],
00212                                 'customers_newsletter' => $resul['newsletter'],
00213                                 'customers_password' => tep_encrypt_password($resul['password']),
00214                                 'customers_group_ra'=>  $check_customer['customers_group_id'],
00215                                 'customers_language'=>  $this->languages_id,
00216                                 'customers_status'=>  (_cst_bool('ACCOUNT_FORCE_ACTIV_MAIL')? 2 : 1)
00217                                 );
00218 
00219         if (_cst_bool('ACCOUNT_GENDER')) $sql_data_array['customers_gender'] = $resul['gender'];
00220         if (_cst_bool('ACCOUNT_DOB')) $sql_data_array['customers_dob'] = tep_date_raw($resul['dob']);
00221 
00222         $res=tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);
00223         $newcustomer = $sql_data_array;
00224 
00225         $newcustomer['customers_id']=$customer_id=tep_db_insert_id($res);
00226 
00227         tep_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created,customers_info_date_account_last_modified) values ('" . (int)$customer_id . "', '0', now(), now())");
00228 
00229 
00233         $extra_fields_query = tep_db_query("select ce.fields_id, fields_key, fields_required_email from " . TABLE_EXTRA_FIELDS . " ce where ce.fields_status=1 and fields_admin !=1 ");
00234         while($extra_fields = tep_db_fetch_array($extra_fields_query)) {
00235           if(isset($resul['fields_' . $extra_fields['fields_id']])){
00236             $sql_data_array = array('customers_id' => (int)$customer_id,
00237                                     'fields_id' => $extra_fields['fields_id'],
00238                                     'value' => $resul['fields_' . $extra_fields['fields_id']]);
00239           }
00240           else {
00241             $sql_data_array = array('customers_id' => (int)$customer_id,
00242                                     'fields_id' => $extra_fields['fields_id'],
00243                                     'value' => '');
00245             if(isset($resul['fields_' . $extra_fields['fields_id'] . '_total'])){
00246               $is_add = false;
00247               for($i = 1; $i <= $resul['fields_' . $extra_fields['fields_id'] . '_total']; $i++) {
00248                 if(isset($_POST['fields_' . $extra_fields['fields_id'] . '_' . $i])) {
00249                   if($is_add) { $sql_data_array['value'] .= "\n"; }
00250                   else { $is_add = true; }
00251                   $sql_data_array['value'] .= $resul['fields_' . $extra_fields['fields_id'] . '_' . $i];
00252                 }
00253               }
00254             }
00255           }
00256 
00257           tep_db_perform(TABLE_CUSTOMERS_TO_EXTRA_FIELDS, $sql_data_array);
00258 
00259           $newcustomer[(isset($extra_fields['fields_key'])?$extra_fields['fields_key'] : 'fields_'.$extra_fields['fields_id'])]=$sql_data_array['value'];
00260           $newcustomer['extra'][]=array_merge($sql_data_array, array('email'=>$extra_fields['fields_required_email']) );
00261         }
00262 
00263 
00264       }
00265       else return false;
00266 
00267       if ( ($resul=$this->CheckDataAddressBook($_post)) && $resul !=false && is_array($resul)) {
00268 
00269         if (_cst_bool('CUSTOMER_CITY_FORCE_STRTOUPPER')) {
00270           $resul['city']=strtoupper($resul['city']);
00271         }
00272 
00273         $sql_data_array = array('customers_id' => $customer_id,
00274                                 'entry_firstname' => $resul['firstname'],
00275                                 'entry_lastname' => $resul['lastname'],
00276                                 'entry_street_address' => $resul['street_address'],
00277                                 'entry_postcode' => $resul['postcode'],
00278                                 'entry_city' => $resul['city'],
00279                                 'entry_country_id' => $resul['country']);
00280 
00281         if (_cst_bool('ACCOUNT_GENDER')) $sql_data_array['entry_gender'] = $resul['gender'];
00282         if (_cst_bool('ACCOUNT_COMPANY')){
00283           $sql_data_array['entry_company'] = $resul['company'];
00284           $sql_data_array['entry_company_tax_id'] = $resul['company_tax_id'];
00285         }
00286         if (_cst_bool('ACCOUNT_SUBURB')) $sql_data_array['entry_suburb'] = $resul['suburb'];
00287         if (_cst_bool('ACCOUNT_STATE')) {
00288           if (isset($resul['zone_id']) && $resul['zone_id'] > 0) {
00289             $sql_data_array['entry_zone_id'] = @$resul['zone_id'];
00290             $sql_data_array['entry_state'] = '';
00291           } else {
00292             $sql_data_array['entry_zone_id'] = '0';
00293             $sql_data_array['entry_state'] = @$resul['state'];
00294           }
00295         }
00296 
00297         tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
00298 
00299         $newcustomer=array_merge($newcustomer,$sql_data_array);
00300 
00301         $cs_s=tep_db_query("select address_book_id from " . TABLE_ADDRESS_BOOK . "  where customers_id='".$customer_id."' ORDER BY address_book_id DESC");
00302         $cs=tep_db_fetch_array($cs_s);
00303         $address_id=$cs['address_book_id'];
00304 
00305         $newcustomer['address_book_id']= $address_id;
00306 
00307         tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'");
00308       }
00309       else {
00310         $resul=$this->CheckData($_post);
00311         $sql_data_array = array('customers_id' => $customer_id,
00312                                 'entry_firstname' => $resul['firstname'],
00313                                 'entry_lastname' => $resul['lastname']);
00314 
00315         tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
00316 
00317         $cs_s=tep_db_query("select address_book_id from " . TABLE_ADDRESS_BOOK . "  where customers_id='".$customer_id."' ORDER BY address_book_id DESC");
00318         $cs=tep_db_fetch_array($cs_s);
00319         $address_id=$cs['address_book_id'];
00320 
00321         $newcustomer['address_book_id']= $address_id;
00322 
00323         tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'");
00324       }
00325 
00329       $page=page::getInstance();
00330       $aca_account=$page->new_class('account',$customer_id);
00331       $aca_account->userInsert($newcustomer);
00332 
00333       return (is_array($newcustomer) ? new objectInfo(self::CleanKey($newcustomer)) : false);
00334     }

customer::userLoadAddress ( address_id  ) 

load address for customer Use current customer id

Parameters:
$address_id integer
Returns:
array result sql | false

Definition at line 556 of file page.customer.php.

00556                                               {
00557     $check_address_query = tep_db_query("select * from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $this->customer_id . "' and address_book_id = '" . (int)$address_id . "'");
00558 
00559     if(tep_db_num_rows($check_address_query)) {
00560       return tep_db_fetch_array($check_address_query);
00561     }
00562     else return false;
00563   }

customer::userNotifiUpdate ( _post  ) 

Assure enregsitrement action=newseltters.

Parameters:
$_post array

Definition at line 127 of file page.customer.php.

00127                                             {
00128       global $page;
00129 
00130       if (isset($_post['newsletter_product_notification']) && is_numeric($_post['newsletter_product_notification'])) $sql_data_array = array('global_product_notifications'=> '1' );
00131       else  $sql_data_array = array('global_product_notifications'=> '0' );
00132 
00133       tep_db_perform(TABLE_CUSTOMERS_INFO, $sql_data_array, 'update', " customers_info_id = '" . $this->customer_id . "'");
00134 
00135       if (isset($_post['newsletter_general']) && is_numeric($_post['newsletter_general'])) $sql_data_array = array('customers_newsletter'=> '1' );
00136       else $sql_data_array = array('customers_newsletter'=> '0' );
00137 
00138       $res=tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', " customers_id = '" . $this->customer_id . "'");
00139 
00140       if($res ==false) return false;
00141       else  self::PassmessageStack('account', SUCCESS_NEWSLETTER_UPDATED, 'success');
00142 
00143       return true;
00144     }

customer::userTestNotExist ( email  ) 

test user not exist, control by email

Parameters:
$email string
Returns:
boolean true if not exist false if exists

Definition at line 154 of file page.customer.php.

00154                                             {
00155         return (!(bool)self::search('customers_email_address', $email)?true : false );
00156     }

customer::userUpdate ( _post  ) 

Assure enregsitrement d'un customers info de action=edit.

Parameters:
$_post 
Returns:
boolean

TODO: Reporter usage function up adress book

call method module account

Definition at line 344 of file page.customer.php.

00344                                       {
00345 
00346       global $page;
00347 
00348       $this->languages_id=$page->the_var('languages_id');
00349 
00350       if ( ($resul=$this->CheckData($_post,'',false)) && $resul !=false && is_array($resul)) {
00351 
00352         $sql_data_array = array('customers_firstname' => $resul['firstname'],
00353                                 'customers_lastname' => $resul['lastname'],
00354                                 'customers_email_address' => $resul['email_address'],
00355                                 'customers_telephone' => $resul['telephone'],
00356                                 'customers_fax' => $resul['fax']);
00357 
00358         if (_cst_bool('ACCOUNT_GENDER')) $sql_data_array['customers_gender'] = $resul['gender'];
00359         if (_cst_bool('ACCOUNT_DOB')) $sql_data_array['customers_dob'] = tep_date_raw($resul['dob']);
00360 
00361         tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . $this->customer_id . "'");
00362 
00363         tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . $this->customer_id . "'");
00364 
00365 
00369         $res=array();
00370         $bas_user=tep_db_query("select fields_id from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id='" . $this->customer_id."'");
00371         while ($extra_fields = tep_db_fetch_array($bas_user)) {
00372           $res[]=$extra_fields['fields_id'];
00373         }
00374         $extra_fields_query = tep_db_query($sql="select ce.fields_id from " . TABLE_EXTRA_FIELDS . " ce  where  ce.fields_status=1 and fields_admin =0 " );
00375 
00376         while ($extra_fields = tep_db_fetch_array($extra_fields_query)) {
00377           if(isset($resul['fields_' . $extra_fields['fields_id']])){
00378             $sql_data_array = array('value' => $resul['fields_' . $extra_fields['fields_id']]);
00379           }else {
00380             $sql_data_array = array('value' => '');
00381             $is_add = false;
00382             for($i = 1; $i <= $_post['fields_' . $extra_fields['fields_id'] . '_total']; $i++) {
00383               if(isset($resul['fields_' . $extra_fields['fields_id'] . '_' . $i])) {
00384                 if($is_add) {
00385                   $sql_data_array['value'] .= "\n";
00386                 }
00387                 else {
00388                   $is_add = true;
00389                 }
00390                 $sql_data_array['value'] .= $resul['fields_' . $extra_fields['fields_id'] . '_' . $i];
00391               }
00392             }
00393           }
00394 
00395           if(in_array($extra_fields['fields_id'],$res)) tep_db_perform(TABLE_CUSTOMERS_TO_EXTRA_FIELDS, $sql_data_array, 'update', "fields_id='".(int)$extra_fields['fields_id']."' and customers_id='".(int)$this->customer_id."'");
00396           else{
00397             $sql_data_array['customers_id']=(int)$this->customer_id;
00398             $sql_data_array['fields_id']=(int)$extra_fields['fields_id'];
00399             tep_db_perform(TABLE_CUSTOMERS_TO_EXTRA_FIELDS, $sql_data_array);
00400           }
00401         }
00402 
00403         self::PassmessageStack('account', SUCCESS_ACCOUNT_UPDATED, 'success');
00404 
00405       }
00406 
00410       $page=page::getInstance();
00411       $aca_account=$page->new_class('account',$this->customer_id);
00412 
00413       $aca_account->userUpdate($_post);
00414 
00415       return (($resul==false)?true:false);
00416     }

customer::userUpdatepassword ( _post  ) 

Update password password_current depend method checkPasswordProcess().

Parameters:
$_post array( password_confirmation, password_current , password_new )
Returns:
boolean

Definition at line 429 of file page.customer.php.

00429                                               {
00430       global $page;
00431 
00432       $_current = tep_db_prepare_input($_post['password_current']);
00433       $_new = tep_db_prepare_input($_post['password_new']);
00434       $_confirmation = tep_db_prepare_input($_post['password_confirmation']);
00435 
00436       if ($this->checkPasswordProcess($_current, $_new, $_confirmation) ) {
00437           tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . tep_encrypt_password($_new) . "' where customers_id = '" . $this->customer_id . "'");
00438 
00439           tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . $this->customer_id . "'");
00440 
00441           self::PassmessageStack('account', SUCCESS_PASSWORD_UPDATED, 'success');
00442           return true;
00443       }
00444       return false;
00445     }


Member Data Documentation

customer::$_instance [static, protected]

Definition at line 32 of file page.customer.php.

customer::$customer

Definition at line 25 of file page.customer.php.

customer::$methodeMessage = 'add_session' [static, protected]

Definition at line 30 of file page.customer.php.


The documentation for this class was generated from the following file: