Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1598
 
1766
 
1766
 
address_book_process.php
_> 11 <?php
  22 /*
<> 3 -  $Id: address_book_process.php,v 1.79 2003/06/09 23:03:52 hpdl Exp $
   3+  $Id: address_book_process.php 1766 2008-01-03 17:35:06Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2003 osCommerce
   8+  Copyright (c) 2007 osCommerce
99 
  1010   Released under the GNU General Public License
  1111 */
     
 !
142142       }
  143143 
  144144       if ($HTTP_POST_VARS['action'] == 'update') {
<> 145 -        tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "address_book_id = '" . (int)$HTTP_GET_VARS['edit'] . "' and customers_id ='" . (int)$customer_id . "'");
   145+        $check_query = tep_db_query("select address_book_id from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . (int)$HTTP_GET_VARS['edit'] . "' and customers_id = '" . (int)$customer_id . "' limit 1");
   146+        if (tep_db_num_rows($check_query) == 1) {
   147+          tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "address_book_id = '" . (int)$HTTP_GET_VARS['edit'] . "' and customers_id ='" . (int)$customer_id . "'");
146148 
  147149 // reregister session variables
<> 148 -        if ( (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) || ($HTTP_GET_VARS['edit'] == $customer_default_address_id) ) {
  149 -          $customer_first_name = $firstname;
  150 -          $customer_country_id = $country;
  151 -          $customer_zone_id = (($zone_id > 0) ? (int)$zone_id : '0');
  152 -          $customer_default_address_id = (int)$HTTP_GET_VARS['edit'];
   150+          if ( (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) || ($HTTP_GET_VARS['edit'] == $customer_default_address_id) ) {
   151+            $customer_first_name = $firstname;
   152+            $customer_country_id = $country;
   153+            $customer_zone_id = (($zone_id > 0) ? (int)$zone_id : '0');
   154+            $customer_default_address_id = (int)$HTTP_GET_VARS['edit'];
153155 
<> 154 -          $sql_data_array = array('customers_firstname' => $firstname,
  155 -                                  'customers_lastname' => $lastname,
  156 -                                  'customers_default_address_id' => (int)$HTTP_GET_VARS['edit']);
   156+            $sql_data_array = array('customers_firstname' => $firstname,
   157+                                    'customers_lastname' => $lastname,
   158+                                    'customers_default_address_id' => (int)$HTTP_GET_VARS['edit']);
157159 
<> 158 -          if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
   160+            if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
159161 
<> 160 -          tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");
   162+            tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");
   163+          }
   164+
   165+          $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
161166         }
  162167       } else {
<> 163 -        $sql_data_array['customers_id'] = (int)$customer_id;
  164 -        tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
   168+        if (tep_count_customer_address_book_entries() < MAX_ADDRESS_BOOK_ENTRIES) {
   169+          $sql_data_array['customers_id'] = (int)$customer_id;
   170+          tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
165171 
<> 166 -        $new_address_book_id = tep_db_insert_id();
   172+          $new_address_book_id = tep_db_insert_id();
167173 
  168174 // reregister session variables
<> 169 -        if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) {
  170 -          $customer_first_name = $firstname;
  171 -          $customer_country_id = $country;
  172 -          $customer_zone_id = (($zone_id > 0) ? (int)$zone_id : '0');
  173 -          if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) $customer_default_address_id = $new_address_book_id;
   175+          if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) {
   176+            $customer_first_name = $firstname;
   177+            $customer_country_id = $country;
   178+            $customer_zone_id = (($zone_id > 0) ? (int)$zone_id : '0');
   179+            if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) $customer_default_address_id = $new_address_book_id;
174180 
<> 175 -          $sql_data_array = array('customers_firstname' => $firstname,
  176 -                                  'customers_lastname' => $lastname);
   181+            $sql_data_array = array('customers_firstname' => $firstname,
   182+                                    'customers_lastname' => $lastname);
177183 
<> 178 -          if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
  179 -          if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) $sql_data_array['customers_default_address_id'] = $new_address_book_id;
   184+            if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
   185+            if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) $sql_data_array['customers_default_address_id'] = $new_address_book_id;
180186 
<> 181 -          tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");
   187+            tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");
   188+
   189+            $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
   190+          }
182191         }
  183192       }
  184193 
<> 185 -      $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
  186 -
<_ 187194       tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
  188195     }
  189196   }