[TEP-COMMIT] [CVS catalog] the new address book pages based on a CSS layout, and a new address_book

hpdl-OfajU3CKLf1/[email protected] 29 Mar 2005 23:33:02 -0000
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>catalog/catalog/includes</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>content/pages/<a href="#file1"><span id="added">address_book.php</span></a></tt></td><td align="right" id="added">+101</td><td></td><td nowrap="nowrap" align="right">added <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/address_book.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file2"><span id="added">address_book_delete.php</span></a></tt></td><td align="right" id="added">+76</td><td></td><td nowrap="nowrap" align="right">added <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/address_book_delete.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file3"><span id="added">address_book_process.php</span></a></tt></td><td align="right" id="added">+97</td><td></td><td nowrap="nowrap" align="right">added <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/address_book_process.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr class="alt"><td><tt>modules/account/<a href="#file4"><span id="added">address_book.php</span></a></tt></td><td align="right" id="added">+242</td><td></td><td nowrap="nowrap" align="right">added <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/account/address_book.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td></td><td align="right" id="added">+516</td><td></td><td></td></tr>
</table>
<small id="info">4 added files</small><br />
<pre class="comment">
the new address book pages based on a CSS layout, and a new address_book
account module to handle the related processing logic
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="added"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content">content</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages">pages</a><br /></span>
<div class="fileheader" id="added"><big><b>address_book.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/address_book.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N address_book.php
--- /dev/null	Wed Mar 30 01:32:48 2005
+++ /tmp/cvsAAAFWaijy	Wed Mar 30 01:32:56 2005
@@ -0,0 +1,101 @@
</small></pre><pre class="diff" id="added">+&lt;?php
+/*
+  $Id$
+
+  osCommerce, Open Source E-Commerce Solutions
+  http://www.oscommerce.com
+
+  Copyright (c) 2005 osCommerce
+
+  Released under the GNU General Public License
+*/
+?&gt;
+
+&lt;div class="pageHeading"&gt;
+  &lt;span class="pageHeadingImage"&gt;&lt;?php echo tep_image(DIR_WS_IMAGES . 'table_background_address_book.gif', HEADING_TITLE_ADDRESS_BOOK, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?&gt;&lt;/span&gt;
+
+  &lt;h1&gt;&lt;?php echo HEADING_TITLE_ADDRESS_BOOK; ?&gt;&lt;/h1&gt;
+&lt;/div&gt;
+
+&lt;?php
+  if ($messageStack-&gt;size('address_book') &gt; 0) {
+    echo $messageStack-&gt;output('address_book');
+  }
+?&gt;
+
+&lt;div class="moduleBox"&gt;
+  &lt;div class="outsideHeading"&gt;&lt;?php echo PRIMARY_ADDRESS_TITLE; ?&gt;&lt;/div&gt;
+
+  &lt;div class="content"&gt;
+    &lt;div style="float: right; padding: 0px 0px 10px 20px;"&gt;
+      &lt;?php echo tep_address_label($osC_Customer-&gt;id, $osC_Customer-&gt;default_address_id, true, ' ', '&lt;br&gt;'); ?&gt;
+    &lt;/div&gt;
+
+    &lt;div style="float: right; padding: 0px 0px 10px 20px; text-align: center;"&gt;
+      &lt;?php echo '&lt;b&gt;' . PRIMARY_ADDRESS_TITLE . '&lt;/b&gt;&lt;br&gt;' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?&gt;
+    &lt;/div&gt;
+
+    &lt;?php echo PRIMARY_ADDRESS_DESCRIPTION; ?&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;?php
+  $Qaddresses = $osC_Database-&gt;query('select address_book_id, 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 = :customers_id order by firstname, lastname');
+  $Qaddresses-&gt;bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+  $Qaddresses-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+  $Qaddresses-&gt;execute();
+?&gt;
+
+&lt;div class="moduleBox"&gt;
+  &lt;div class="outsideHeading"&gt;&lt;?php echo ADDRESS_BOOK_TITLE; ?&gt;&lt;/div&gt;
+
+  &lt;div class="content"&gt;
+    &lt;table border="0" width="100%" cellspacing="0" cellpadding="2"&gt;
+
+&lt;?php
+  $counter = 0;
+
+  while ($Qaddresses-&gt;next()) {
+    $counter++;
+
+    $format_id = tep_get_address_format_id($Qaddresses-&gt;valueInt('country_id'));
+?&gt;
+
+      &lt;tr class="moduleRow" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);"&gt;
+        &lt;td&gt;
+          &lt;b&gt;&lt;?php echo $Qaddresses-&gt;valueProtected('firstname') . ' ' . $Qaddresses-&gt;valueProtected('lastname'); ?&gt;&lt;/b&gt;
+
+&lt;?php
+    if ($Qaddresses-&gt;valueInt('address_book_id') == $osC_Customer-&gt;default_address_id) {
+      echo '&amp;nbsp;&lt;small&gt;&lt;i&gt;' . PRIMARY_ADDRESS . '&lt;/i&gt;&lt;/small&gt;';
+    }
+?&gt;
+
+        &lt;/td&gt;
+        &lt;td align="right"&gt;&lt;?php echo '&lt;a href="' . tep_href_link(FILENAME_ACCOUNT, 'address_book=' . $Qaddresses-&gt;valueInt('address_book_id') . '&amp;edit', 'SSL') . '"&gt;' . tep_image_button('small_edit.gif', SMALL_IMAGE_BUTTON_EDIT) . '&lt;/a&gt;&amp;nbsp;&lt;a href="' . tep_href_link(FILENAME_ACCOUNT, 'address_book=' . $Qaddresses-&gt;valueInt('address_book_id') . '&amp;delete', 'SSL') . '"&gt;' . tep_image_button('small_delete.gif', SMALL_IMAGE_BUTTON_DELETE) . '&lt;/a&gt;'; ?&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+      &lt;tr&gt;
+        &lt;td colspan="2" style="padding: 0px 0px 10px 10px;"&gt;&lt;?php echo tep_address_format($format_id, $Qaddresses-&gt;toArray(), true, ' ', '&lt;br&gt;'); ?&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+
+&lt;?php
+  }
+?&gt;
+
+    &lt;/table&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class="submitFormButtons"&gt;
+  &lt;span style="float: right;"&gt;
+&lt;?php
+  if ($counter &lt; MAX_ADDRESS_BOOK_ENTRIES) {
+    echo '&lt;a href="' . tep_href_link(FILENAME_ACCOUNT, 'address_book&amp;new', 'SSL') . '"&gt;' . tep_image_button('button_add_address.gif', IMAGE_BUTTON_ADD_ADDRESS) . '&lt;/a&gt;';
+  } else {
+    echo sprintf(TEXT_MAXIMUM_ENTRIES, MAX_ADDRESS_BOOK_ENTRIES);
+  }
+?&gt;
+  &lt;/span&gt;
+
+  &lt;?php echo '&lt;a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '"&gt;' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '&lt;/a&gt;'; ?&gt;
+&lt;/div&gt;
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname" id="added"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content">content</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages">pages</a><br /></span>
<div class="fileheader" id="added"><big><b>address_book_delete.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/address_book_delete.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N address_book_delete.php
--- /dev/null	Wed Mar 30 01:32:48 2005
+++ /tmp/cvsAAAr2a4jy	Wed Mar 30 01:32:57 2005
@@ -0,0 +1,76 @@
</small></pre><pre class="diff" id="added">+&lt;?php
+/*
+  $Id$
+
+  osCommerce, Open Source E-Commerce Solutions
+  http://www.oscommerce.com
+
+  Copyright (c) 2005 osCommerce
+
+  Released under the GNU General Public License
+*/
+
+  if ($_GET['address_book'] == $osC_Customer-&gt;default_address_id) {
+    $messageStack-&gt;add('address_book', WARNING_PRIMARY_ADDRESS_DELETION, 'warning');
+  } else {
+    $Qcheck = $osC_Database-&gt;query('select count(*) as total from :table_address_book where address_book_id = :address_book_id and customers_id = :customers_id');
+    $Qcheck-&gt;bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+    $Qcheck-&gt;bindInt(':address_book_id', $_GET['address_book']);
+    $Qcheck-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+    $Qcheck-&gt;execute();
+
+    if ($Qcheck-&gt;valueInt('total') &lt; 1) {
+      $messageStack-&gt;add('address_book', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY, 'error');
+    }
+  }
+?&gt;
+
+&lt;div class="pageHeading"&gt;
+  &lt;span class="pageHeadingImage"&gt;&lt;?php echo tep_image(DIR_WS_IMAGES . 'table_background_address_book.gif', HEADING_TITLE_ADDRESS_BOOK_DELETE_ENTRY, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?&gt;&lt;/span&gt;
+
+  &lt;h1&gt;&lt;?php echo HEADING_TITLE_ADDRESS_BOOK_DELETE_ENTRY; ?&gt;&lt;/h1&gt;
+&lt;/div&gt;
+
+&lt;?php
+  if ($messageStack-&gt;size('address_book') &gt; 0) {
+    echo $messageStack-&gt;output('address_book');
+  }
+
+  if ( ($_GET['address_book'] != $osC_Customer-&gt;default_address_id) &amp;&amp; ($Qcheck-&gt;valueInt('total') === 1) ) {
+?&gt;
+
+&lt;div class="moduleBox"&gt;
+  &lt;div class="outsideHeading"&gt;&lt;?php echo DELETE_ADDRESS_TITLE; ?&gt;&lt;/div&gt;
+
+  &lt;div class="content"&gt;
+    &lt;div style="float: right; padding: 0px 0px 10px 20px;"&gt;
+      &lt;?php echo tep_address_label($osC_Customer-&gt;id, $_GET['address_book'], true, ' ', '&lt;br&gt;'); ?&gt;
+    &lt;/div&gt;
+
+    &lt;div style="float: right; padding: 0px 0px 10px 20px; text-align: center;"&gt;
+      &lt;?php echo '&lt;b&gt;' . SELECTED_ADDRESS . '&lt;/b&gt;&lt;br&gt;' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?&gt;
+    &lt;/div&gt;
+
+    &lt;?php echo DELETE_ADDRESS_DESCRIPTION; ?&gt;
+
+    &lt;div style="clear: both;"&gt;&lt;/div&gt;
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class="submitFormButtons"&gt;
+  &lt;span style="float: right;"&gt;&lt;?php echo '&lt;a href="' . tep_href_link(FILENAME_ACCOUNT, 'address_book=' . $_GET['address_book'] . '&amp;delete=confirm', 'SSL') . '"&gt;' . tep_image_button('button_delete.gif', IMAGE_BUTTON_DELETE) . '&lt;/a&gt;'; ?&gt;&lt;/span&gt;
+
+  &lt;?php echo '&lt;a href="' . tep_href_link(FILENAME_ACCOUNT, 'address_book', 'SSL') . '"&gt;' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '&lt;/a&gt;'; ?&gt;
+&lt;/div&gt;
+
+&lt;?php
+  } else {
+?&gt;
+
+&lt;div class="submitFormButtons"&gt;
+  &lt;?php echo '&lt;a href="' . tep_href_link(FILENAME_ACCOUNT, 'address_book', 'SSL') . '"&gt;' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '&lt;/a&gt;'; ?&gt;
+&lt;/div&gt;
+
+&lt;?php
+  }
+?&gt;
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname" id="added"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content">content</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages">pages</a><br /></span>
<div class="fileheader" id="added"><big><b>address_book_process.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/address_book_process.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N address_book_process.php
--- /dev/null	Wed Mar 30 01:32:48 2005
+++ /tmp/cvsAAAu_aqky	Wed Mar 30 01:32:57 2005
@@ -0,0 +1,97 @@
</small></pre><pre class="diff" id="added">+&lt;?php
+/*
+  $Id$
+
+  osCommerce, Open Source E-Commerce Solutions
+  http://www.oscommerce.com
+
+  Copyright (c) 2005 osCommerce
+
+  Released under the GNU General Public License
+*/
+
+  if (isset($_GET['edit'])) {
+    $Qentry = $osC_Database-&gt;query('select entry_gender, entry_company, entry_firstname, entry_lastname, entry_street_address, entry_suburb, entry_postcode, entry_city, entry_state, entry_zone_id, entry_country_id, entry_telephone, entry_fax from :table_address_book where customers_id = :customers_id and address_book_id = :address_book_id');
+    $Qentry-&gt;bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+    $Qentry-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+    $Qentry-&gt;bindInt(':address_book_id', $_GET['address_book']);
+    $Qentry-&gt;execute();
+
+    if ($Qentry-&gt;numberOfRows() &lt; 1) {
+      $messageStack-&gt;add('address_book', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY, 'error');
+    }
+
+    $page_heading_title = HEADING_TITLE_ADDRESS_BOOK_EDIT_ENTRY;
+  } else {
+    if (($counter = tep_count_customer_address_book_entries()) &gt;= MAX_ADDRESS_BOOK_ENTRIES) {
+      $messageStack-&gt;add('address_book', ERROR_ADDRESS_BOOK_FULL);
+    }
+
+    $page_heading_title = HEADING_TITLE_ADDRESS_BOOK_ADD_ENTRY;
+  }
+
+  require('includes/form_check.js.php');
+?&gt;
+
+&lt;div class="pageHeading"&gt;
+  &lt;span class="pageHeadingImage"&gt;&lt;?php echo tep_image(DIR_WS_IMAGES . 'table_background_address_book.gif', $page_heading_title, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?&gt;&lt;/span&gt;
+
+  &lt;h1&gt;&lt;?php echo $page_heading_title; ?&gt;&lt;/h1&gt;
+&lt;/div&gt;
+
+&lt;?php
+  if ($messageStack-&gt;size('address_book') &gt; 0) {
+    echo $messageStack-&gt;output('address_book');
+  }
+
+  if ( ($osC_Customer-&gt;hasDefaultAddress() === false) || (isset($_GET['new']) &amp;&amp; ($counter &lt; MAX_ADDRESS_BOOK_ENTRIES)) || (isset($Qentry) &amp;&amp; ($Qentry-&gt;numberOfRows() === 1)) ) {
+?&gt;
+
+&lt;form name="address_book" action="&lt;?php echo tep_href_link(FILENAME_ACCOUNT, 'address_book=' . $_GET['address_book'] . '&amp;' . (isset($_GET['edit']) ? 'edit' : 'new') . '=save', 'SSL'); ?&gt;" method="post" onSubmit="return check_form(address_book);"&gt;
+
+&lt;div class="moduleBox"&gt;
+  &lt;div class="outsideHeading"&gt;
+    &lt;span class="inputRequirement" style="float: right;"&gt;&lt;?php echo FORM_REQUIRED_INFORMATION; ?&gt;&lt;/span&gt;
+
+    &lt;?php echo NEW_ADDRESS_TITLE; ?&gt;
+  &lt;/div&gt;
+
+  &lt;div class="content"&gt;
+
+&lt;?php
+  require('includes/modules/address_book_details.php');
+?&gt;
+
+  &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class="submitFormButtons"&gt;
+  &lt;span style="float: right;"&gt;&lt;?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?&gt;&lt;/span&gt;
+
+&lt;?php
+    if (sizeof($navigation-&gt;snapshot) &gt; 0) {
+      $back_link = tep_href_link($navigation-&gt;snapshot['page'], tep_array_to_string($navigation-&gt;snapshot['get'], array($osC_Session-&gt;name)), $navigation-&gt;snapshot['mode']);
+    } elseif ($osC_Customer-&gt;hasDefaultAddress() === false) {
+      $back_link = tep_href_link(FILENAME_ACCOUNT, '', 'SSL');
+    } else {
+      $back_link = tep_href_link(FILENAME_ACCOUNT, 'address_book', 'SSL');
+    }
+
+    echo '&lt;a href="' . $back_link . '"&gt;' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '&lt;/a&gt;';
+?&gt;
+
+&lt;/div&gt;
+
+&lt;/form&gt;
+
+&lt;?php
+  } else {
+?&gt;
+
+&lt;div class="submitFormButtons"&gt;
+  &lt;?php echo '&lt;a href="' . tep_href_link(FILENAME_ACCOUNT, 'address_book', 'SSL') . '"&gt;' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '&lt;/a&gt;'; ?&gt;
+&lt;/div&gt;
+
+&lt;?php
+  }
+?&gt;
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules">modules</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/account">account</a><br /></span>
<div class="fileheader" id="added"><big><b>address_book.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/account/address_book.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N address_book.php
--- /dev/null	Wed Mar 30 01:32:48 2005
+++ /tmp/cvsAAAlkaqly	Wed Mar 30 01:32:58 2005
@@ -0,0 +1,242 @@
</small></pre><pre class="diff" id="added">+&lt;?php
+/*
+  $Id$
+
+  osCommerce, Open Source E-Commerce Solutions
+  http://www.oscommerce.com
+
+  Copyright (c) 2005 osCommerce
+
+  Released under the GNU General Public License
+*/
+
+  class osC_Account_Address_book {
+
+/* Public variables */
+
+    var $page_contents = 'address_book.php';
+
+/* Private variables */
+
+    var $_module = 'address_book';
+
+/* Class constructor */
+
+    function osC_Account_Address_book() {
+      global $osC_Services, $breadcrumb, $osC_Customer;
+
+      if ($osC_Services-&gt;isStarted('breadcrumb')) {
+        $breadcrumb-&gt;add(NAVBAR_TITLE_ADDRESS_BOOK, tep_href_link(FILENAME_ACCOUNT, $this-&gt;_module, 'SSL'));
+      }
+
+      if ($osC_Customer-&gt;hasDefaultAddress() === false) {
+        $this-&gt;page_contents = 'address_book_process.php';
+      } elseif (isset($_GET['new'])) {
+        if ($osC_Services-&gt;isStarted('breadcrumb')) {
+          $breadcrumb-&gt;add(NAVBAR_TITLE_ADDRESS_BOOK_ADD_ENTRY, tep_href_link(FILENAME_ACCOUNT, $this-&gt;_module . '&amp;new', 'SSL'));
+        }
+
+        $this-&gt;page_contents = 'address_book_process.php';
+      } elseif (isset($_GET['edit']) &amp;&amp; is_numeric($_GET[$this-&gt;_module])) {
+        if ($osC_Services-&gt;isStarted('breadcrumb')) {
+          $breadcrumb-&gt;add(NAVBAR_TITLE_ADDRESS_BOOK_EDIT_ENTRY, tep_href_link(FILENAME_ACCOUNT, $this-&gt;_module . '=' . $_GET[$this-&gt;_module] . '&amp;edit', 'SSL'));
+        }
+
+        $this-&gt;page_contents = 'address_book_process.php';
+      } elseif (isset($_GET['delete']) &amp;&amp; is_numeric($_GET[$this-&gt;_module])) {
+        if ($osC_Services-&gt;isStarted('breadcrumb')) {
+          $breadcrumb-&gt;add(NAVBAR_TITLE_ADDRESS_BOOK_DELETE_ENTRY, tep_href_link(FILENAME_ACCOUNT, $this-&gt;_module . '=' . $_GET[$this-&gt;_module] . '&amp;delete', 'SSL'));
+        }
+
+        $this-&gt;page_contents = 'address_book_delete.php';
+      }
+
+      if (isset($_GET['new']) &amp;&amp; ($_GET['new'] == 'save')) {
+        if (tep_count_customer_address_book_entries() &gt;= MAX_ADDRESS_BOOK_ENTRIES) {
+          $messageStack-&gt;add('address_book', ERROR_ADDRESS_BOOK_FULL);
+
+          $this-&gt;page_contents = 'address_book.php';
+        } else {
+          $this-&gt;_process();
+        }
+      } elseif (isset($_GET['edit']) &amp;&amp; ($_GET['edit'] == 'save')) {
+        $this-&gt;_process($_GET[$this-&gt;_module]);
+      } elseif (isset($_GET['delete']) &amp;&amp; ($_GET['delete'] == 'confirm') &amp;&amp; is_numeric($_GET[$this-&gt;_module])) {
+        $this-&gt;_delete($_GET[$this-&gt;_module]);
+      }
+    }
+
+/* Public methods */
+
+    function getPageContentsFile() {
+      return $this-&gt;page_contents;
+    }
+
+/* Private methods */
+
+    function _process($id = '') {
+      global $messageStack, $osC_Database, $osC_Customer, $entry_state_has_zones;
+
+      if (ACCOUNT_GENDER &gt; 0) {
+        if (!isset($_POST['gender']) || (($_POST['gender'] != 'm') &amp;&amp; ($_POST['gender'] != 'f'))) {
+          $messageStack-&gt;add('address_book', ENTRY_GENDER_ERROR);
+        }
+      }
+
+      if (!isset($_POST['firstname']) || (strlen(trim($_POST['firstname'])) &lt; ACCOUNT_FIRST_NAME)) {
+        $messageStack-&gt;add('address_book', ENTRY_FIRST_NAME_ERROR);
+      }
+
+      if (!isset($_POST['lastname']) || (strlen(trim($_POST['lastname'])) &lt; ACCOUNT_LAST_NAME)) {
+        $messageStack-&gt;add('address_book', ENTRY_LAST_NAME_ERROR);
+      }
+
+      if (ACCOUNT_COMPANY &gt; 0) {
+        if (!isset($_POST['company']) || (strlen(trim($_POST['company'])) &lt; ACCOUNT_COMPANY)) {
+          $messageStack-&gt;add('address_book', ENTRY_COMPANY_ERROR);
+        }
+      }
+
+      if (!isset($_POST['street_address']) || (strlen(trim($_POST['street_address'])) &lt; ACCOUNT_STREET_ADDRESS)) {
+        $messageStack-&gt;add('address_book', ENTRY_STREET_ADDRESS_ERROR);
+      }
+
+      if (ACCOUNT_SUBURB &gt; 0) {
+        if (!isset($_POST['suburb']) || (strlen(trim($_POST['suburb'])) &lt; ACCOUNT_SUBURB)) {
+          $messageStack-&gt;add('address_book', ENTRY_SUBURB_ERROR);
+        }
+      }
+
+      if (!isset($_POST['postcode']) || (strlen(trim($_POST['postcode'])) &lt; ACCOUNT_POST_CODE)) {
+        $messageStack-&gt;add('address_book', ENTRY_POST_CODE_ERROR);
+      }
+
+      if (!isset($_POST['city']) || (strlen(trim($_POST['city'])) &lt; ACCOUNT_CITY)) {
+        $messageStack-&gt;add('address_book', ENTRY_CITY_ERROR);
+      }
+
+      if (ACCOUNT_STATE &gt; 0) {
+        $zone_id = 0;
+
+        $Qcheck = $osC_Database-&gt;query('select zone_id from :table_zones where zone_country_id = :zone_country_id limit 1');
+        $Qcheck-&gt;bindTable(':table_zones', TABLE_ZONES);
+        $Qcheck-&gt;bindInt(':zone_country_id', $_POST['country']);
+        $Qcheck-&gt;execute();
+
+        $entry_state_has_zones = ($Qcheck-&gt;numberOfRows() &gt; 0);
+
+        if ($entry_state_has_zones === true) {
+          $Qzone = $osC_Database-&gt;query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_code like :zone_code');
+          $Qzone-&gt;bindTable(':table_zones', TABLE_ZONES);
+          $Qzone-&gt;bindInt(':zone_country_id', $_POST['country']);
+          $Qzone-&gt;bindValue(':zone_code', trim($_POST['state']));
+          $Qzone-&gt;execute();
+
+          if ($Qzone-&gt;numberOfRows() === 1) {
+            $zone_id = $Qzone-&gt;valueInt('zone_id');
+          } else {
+            $Qzone = $osC_Database-&gt;query('select zone_id from :table_zones where zone_country_id = :zone_country_id and zone_name like :zone_name');
+            $Qzone-&gt;bindTable(':table_zones', TABLE_ZONES);
+            $Qzone-&gt;bindInt(':zone_country_id', $_POST['country']);
+            $Qzone-&gt;bindValue(':zone_name', trim($_POST['state']) . '%');
+            $Qzone-&gt;execute();
+
+            if ($Qzone-&gt;numberOfRows() === 1) {
+              $zone_id = $Qzone-&gt;valueInt('zone_id');
+            } else {
+              $messageStack-&gt;add('address_book', ENTRY_STATE_ERROR_SELECT);
+            }
+          }
+        } else {
+          if (strlen(trim($_POST['state'])) &lt; ACCOUNT_STATE) {
+            $messageStack-&gt;add('address_book', ENTRY_STATE_ERROR);
+          }
+        }
+      }
+
+      if ( (is_numeric($_POST['country']) === false) || ($_POST['country'] &lt; 1) ) {
+        $messageStack-&gt;add('address_book', ENTRY_COUNTRY_ERROR);
+      }
+
+      if (ACCOUNT_TELEPHONE &gt; 0) {
+        if (!isset($_POST['telephone']) || (strlen(trim($_POST['telephone'])) &lt; ACCOUNT_TELEPHONE)) {
+          $messageStack-&gt;add('address_book', ENTRY_TELEPHONE_NUMBER_ERROR);
+        }
+      }
+
+      if (ACCOUNT_FAX &gt; 0) {
+        if (!isset($_POST['fax']) || (strlen(trim($_POST['fax'])) &lt; ACCOUNT_FAX)) {
+          $messageStack-&gt;add('address_book', ENTRY_FAX_NUMBER_ERROR);
+        }
+      }
+
+      if ($messageStack-&gt;size('address_book') === 0) {
+        if (is_numeric($id)) {
+          $Qab = $osC_Database-&gt;query('update :table_address_book set customers_id = :customers_id, entry_gender = :entry_gender, entry_company = :entry_company, entry_firstname = :entry_firstname, entry_lastname = :entry_lastname, entry_street_address = :entry_street_address, entry_suburb = :entry_suburb, entry_postcode = :entry_postcode, entry_city = :entry_city, entry_state = :entry_state, entry_country_id = :entry_country_id, entry_zone_id = :entry_zone_id, entry_telephone = :entry_telephone, entry_fax = :entry_fax where address_book_id = :address_book_id and customers_id = :customers_id');
+          $Qab-&gt;bindInt(':address_book_id', $id);
+          $Qab-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+        } else {
+          $Qab = $osC_Database-&gt;query('insert into :table_address_book (customers_id, entry_gender, entry_company, entry_firstname, entry_lastname, entry_street_address, entry_suburb, entry_postcode, entry_city, entry_state, entry_country_id, entry_zone_id, entry_telephone, entry_fax) values (:customers_id, :entry_gender, :entry_company, :entry_firstname, :entry_lastname, :entry_street_address, :entry_suburb, :entry_postcode, :entry_city, :entry_state, :entry_country_id, :entry_zone_id, :entry_telephone, :entry_fax)');
+        }
+        $Qab-&gt;bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+        $Qab-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+        $Qab-&gt;bindValue(':entry_gender', (((ACCOUNT_GENDER &gt; -1) &amp;&amp; isset($_POST['gender']) &amp;&amp; (($_POST['gender'] == 'm') || ($_POST['gender'] == 'f'))) ? $_POST['gender'] : ''));
+        $Qab-&gt;bindValue(':entry_company', ((ACCOUNT_COMPANY &gt; -1) ? trim($_POST['company']) : ''));
+        $Qab-&gt;bindValue(':entry_firstname', trim($_POST['firstname']));
+        $Qab-&gt;bindValue(':entry_lastname', trim($_POST['lastname']));
+        $Qab-&gt;bindValue(':entry_street_address', trim($_POST['street_address']));
+        $Qab-&gt;bindValue(':entry_suburb', ((ACCOUNT_SUBURB &gt; -1) ? trim($_POST['suburb']) : ''));
+        $Qab-&gt;bindValue(':entry_postcode', trim($_POST['postcode']));
+        $Qab-&gt;bindValue(':entry_city', trim($_POST['city']));
+        $Qab-&gt;bindValue(':entry_state', ((ACCOUNT_STATE &gt; -1) ? (($zone_id &gt; 0) ? '' : trim($_POST['state'])) : ''));
+        $Qab-&gt;bindInt(':entry_country_id', $_POST['country']);
+        $Qab-&gt;bindInt(':entry_zone_id', ((ACCOUNT_STATE &gt; -1) ? (($zone_id &gt; 0) ? $zone_id : 0) : ''));
+        $Qab-&gt;bindValue(':entry_telephone', ((ACCOUNT_TELEPHONE &gt; -1) ? trim($_POST['telephone']) : ''));
+        $Qab-&gt;bindValue(':entry_fax', ((ACCOUNT_FAX &gt; -1) ? trim($_POST['fax']) : ''));
+        $Qab-&gt;execute();
+
+        if ( ($osC_Customer-&gt;hasDefaultAddress() === false) || (isset($_POST['primary']) &amp;&amp; ($_POST['primary'] == 'on')) ) {
+          if (is_numeric($id) === false) {
+            $id = $osC_Database-&gt;nextID();
+          }
+
+          $Qupdate = $osC_Database-&gt;query('update :table_customers set customers_default_address_id = :customers_default_address_id where customers_id = :customers_id');
+          $Qupdate-&gt;bindTable(':table_customers', TABLE_CUSTOMERS);
+          $Qupdate-&gt;bindInt(':customers_default_address_id', $id);
+          $Qupdate-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+          $Qupdate-&gt;execute();
+
+          if ($Qupdate-&gt;affectedRows() === 1) {
+            $osC_Customer-&gt;setCountryID($_POST['country']);
+            $osC_Customer-&gt;setZoneID(($zone_id &gt; 0) ? (int)$zone_id : '0');
+            $osC_Customer-&gt;setDefaultAddressID($id);
+          }
+        }
+
+        $messageStack-&gt;add_session('address_book', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
+
+        tep_redirect(tep_href_link(FILENAME_ACCOUNT, 'address_book', 'SSL'));
+      }
+    }
+
+    function _delete($id) {
+      global $messageStack, $osC_Database, $osC_Customer;
+
+      if ($id != $osC_Customer-&gt;default_address_id) {
+        $Qdelete = $osC_Database-&gt;query('delete from :table_address_book where address_book_id = :address_book_id and customers_id = :customers_id');
+        $Qdelete-&gt;bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+        $Qdelete-&gt;bindInt(':address_book_id', $id);
+        $Qdelete-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+        $Qdelete-&gt;execute();
+
+        if ($Qdelete-&gt;affectedRows() === 1) {
+          $messageStack-&gt;add_session('address_book', SUCCESS_ADDRESS_BOOK_ENTRY_DELETED, 'success');
+        }
+      } else {
+        $messageStack-&gt;add_session('address_book', WARNING_PRIMARY_ADDRESS_DELETION, 'warning');
+      }
+
+      tep_redirect(tep_href_link(FILENAME_ACCOUNT, 'address_book', 'SSL'));
+    }
+  }
+?&gt;
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.9</small></center>
</body></html>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click