[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/ -> account_edit.php (source)

   1  <?php
   2  /*

   3  $Id: account_edit.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13  // Most of this file is changed or moved to BTS - Basic Template System - format.

  14  // For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

  15  //       catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).

  16  // (Sub 'fallback' with your current template to see if there is a template specific file.)

  17  
  18    require ('includes/application_top.php');
  19  
  20    if (!tep_session_is_registered('customer_id')) {
  21      $navigation->set_snapshot();
  22      tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  23    }
  24  
  25  // needs to be included earlier to set the success message in the messageStack

  26    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_EDIT);
  27  
  28    if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) {
  29      if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
  30      $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
  31      $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
  32      if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']);
  33      $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
  34      $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']);
  35      $fax = tep_db_prepare_input($HTTP_POST_VARS['fax']);
  36  
  37      $error = false;
  38  
  39      if (ACCOUNT_GENDER == 'true') {
  40        if ( ($gender != 'm') && ($gender != 'f') ) {
  41          $error = true;
  42  
  43          $messageStack->add('account_edit', ENTRY_GENDER_ERROR);
  44        }
  45      }
  46  
  47      if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
  48        $error = true;
  49  
  50        $messageStack->add('account_edit', ENTRY_FIRST_NAME_ERROR);
  51      }
  52  
  53      if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
  54        $error = true;
  55  
  56        $messageStack->add('account_edit', ENTRY_LAST_NAME_ERROR);
  57      }
  58  
  59      if (ACCOUNT_DOB == 'true') {
  60        if (!checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4))) {
  61          $error = true;
  62  
  63          $messageStack->add('account_edit', ENTRY_DATE_OF_BIRTH_ERROR);
  64        }
  65      }
  66  
  67      if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
  68        $error = true;
  69  
  70        $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR);
  71      }
  72  
  73      if (!tep_validate_email($email_address)) {
  74        $error = true;
  75  
  76        $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
  77      }
  78  
  79      $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' and customers_id != '" . (int)$customer_id . "'");
  80      $check_email = tep_db_fetch_array($check_email_query);
  81      if ($check_email['total'] > 0) {
  82        $error = true;
  83  
  84        $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
  85      }
  86  
  87      if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
  88        $error = true;
  89  
  90        $messageStack->add('account_edit', ENTRY_TELEPHONE_NUMBER_ERROR);
  91      }
  92  
  93      if ($error == false) {
  94        $sql_data_array = array('customers_firstname' => $firstname,
  95                                'customers_lastname' => $lastname,
  96                                'customers_email_address' => $email_address,
  97                                'customers_telephone' => $telephone,
  98                                'customers_fax' => $fax);
  99  
 100        if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
 101        if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob);
 102  
 103        tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");
 104  
 105        tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customer_id . "'");
 106  
 107        $sql_data_array = array('entry_firstname' => $firstname,
 108                                'entry_lastname' => $lastname);
 109  
 110        tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$customer_default_address_id . "'");
 111  
 112  // reset the session variables

 113        $customer_first_name = $firstname;
 114  
 115        $messageStack->add_session('account', SUCCESS_ACCOUNT_UPDATED, 'success');
 116  
 117        tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
 118      }
 119    }
 120  
 121    $account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_telephone, customers_fax from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
 122    $account = tep_db_fetch_array($account_query);
 123  
 124    $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
 125    $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL'));
 126  
 127    $content = CONTENT_ACCOUNT_EDIT;
 128    $javascript = 'form_check.js.php';
 129  
 130    include (bts_select('main', $content_template)); // BTSv1.5

 131  
 132    require (DIR_WS_INCLUDES . 'application_bottom.php');
 133  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7