[TEP-COMMIT] [CVS catalog] the new account edit page based on a CSS layout

hpdl-OfajU3CKLf1/[email protected] 29 Mar 2005 23:29:35 -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">account_edit.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/account_edit.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="#file2"><span id="added">edit.php</span></a></tt></td><td align="right" id="added">+121</td><td></td><td nowrap="nowrap" align="right">added <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/account/edit.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></td></tr>
<tr><td></td><td align="right" id="added">+222</td><td></td><td></td></tr>
</table>
<small id="info">2 added files</small><br />
<pre class="comment">
the new account edit page based on a CSS layout

introduce a new account module to handle the account_edit 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>account_edit.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/content/pages/account_edit.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N account_edit.php
--- /dev/null	Wed Mar 30 01:29:19 2005
+++ /tmp/cvsAAAi8aGWs	Wed Mar 30 01:29:32 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
+*/
+
+  require('includes/form_check.js.php');
+
+  $Qaccount = $osC_Database-&gt;query('select customers_gender, customers_firstname, customers_lastname, unix_timestamp(customers_dob) as customers_dob, customers_email_address from :table_customers where customers_id = :customers_id');
+  $Qaccount-&gt;bindTable(':table_customers', TABLE_CUSTOMERS);
+  $Qaccount-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+  $Qaccount-&gt;execute();
+?&gt;
+
+&lt;div class="pageHeading"&gt;
+  &lt;span class="pageHeadingImage"&gt;&lt;?php echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE_ACCOUNT_EDIT, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?&gt;&lt;/span&gt;
+
+  &lt;h1&gt;&lt;?php echo HEADING_TITLE_ACCOUNT_EDIT; ?&gt;&lt;/h1&gt;
+&lt;/div&gt;
+
+&lt;?php
+  if ($messageStack-&gt;size('account_edit') &gt; 0) {
+    echo $messageStack-&gt;output('account_edit');
+  }
+?&gt;
+
+&lt;form name="account_edit" action="&lt;?php echo tep_href_link(FILENAME_ACCOUNT, 'edit=save', 'SSL'); ?&gt;" method="post" onSubmit="return check_form(account_edit);"&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 MY_ACCOUNT_TITLE; ?&gt;
+  &lt;/div&gt;
+
+  &lt;div class="content"&gt;
+    &lt;table border="0" cellspacing="2" cellpadding="2"&gt;
+
+&lt;?php
+  if (ACCOUNT_GENDER &gt; -1) {
+    $gender_array = array(array('id' =&gt; 'm', 'text' =&gt; MALE),
+                          array('id' =&gt; 'f', 'text' =&gt; FEMALE));
+?&gt;
+      &lt;tr&gt;
+        &lt;td&gt;&lt;?php echo ENTRY_GENDER; ?&gt;&lt;/td&gt;
+        &lt;td&gt;&lt;?php echo osc_draw_radio_field('gender', $gender_array, $Qaccount-&gt;value('customers_gender'), '', (ACCOUNT_GENDER &gt; 0)); ?&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+      &lt;tr&gt;
+       &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
+      &lt;/tr&gt;
+&lt;?php
+  }
+?&gt;
+
+      &lt;tr&gt;
+        &lt;td&gt;&lt;?php echo ENTRY_FIRST_NAME; ?&gt;&lt;/td&gt;
+        &lt;td&gt;&lt;?php echo osc_draw_input_field('firstname', $Qaccount-&gt;value('customers_firstname'), '', true); ?&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+      &lt;tr&gt;
+        &lt;td&gt;&lt;?php echo ENTRY_LAST_NAME; ?&gt;&lt;/td&gt;
+        &lt;td&gt;&lt;?php echo osc_draw_input_field('lastname', $Qaccount-&gt;value('customers_lastname'), '', true); ?&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+
+&lt;?php
+  if (ACCOUNT_DATE_OF_BIRTH &gt; -1) {
+?&gt;
+      &lt;tr&gt;
+       &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
+      &lt;/tr&gt;
+      &lt;tr&gt;
+        &lt;td&gt;&lt;?php echo ENTRY_DATE_OF_BIRTH; ?&gt;&lt;/td&gt;
+        &lt;td&gt;&lt;?php echo tep_draw_date_pull_down_menu('dob', $Qaccount-&gt;value('customers_dob'), false, true, true, date('Y')-1901, -5) . '&amp;nbsp;&lt;span class="inputRequirement"&gt;*&lt;/span&gt;'; ?&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+&lt;?php
+  }
+?&gt;
+
+      &lt;tr&gt;
+       &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
+      &lt;/tr&gt;
+      &lt;tr&gt;
+        &lt;td&gt;&lt;?php echo ENTRY_EMAIL_ADDRESS; ?&gt;&lt;/td&gt;
+        &lt;td&gt;&lt;?php echo osc_draw_input_field('email_address', $Qaccount-&gt;value('customers_email_address'), '', true); ?&gt;&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&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 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;
+
+&lt;/form&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/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>edit.php</b></big> <small id="info">added at <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/modules/account/edit.php?rev=1.1&amp;content-type=text/vnd.viewcvs-markup">1.1</a></small></div>
<pre class="diff"><small id="info">diff -N edit.php
--- /dev/null	Wed Mar 30 01:29:33 2005
+++ /tmp/cvsAAATma4Xs	Wed Mar 30 01:29:33 2005
@@ -0,0 +1,121 @@
</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_Edit {
+
+/* Public variables */
+
+    var $page_contents = 'account_edit.php';
+
+/* Private variables */
+
+    var $_module = 'edit';
+
+/* Class constructor */
+
+    function osC_Account_Edit() {
+      global $osC_Services, $breadcrumb;
+
+      if ($osC_Services-&gt;isStarted('breadcrumb')) {
+        $breadcrumb-&gt;add(NAVBAR_TITLE_EDIT_ACCOUNT, tep_href_link(FILENAME_ACCOUNT, $this-&gt;_module, 'SSL'));
+      }
+
+      if ($_GET[$this-&gt;_module] == 'save') {
+        $this-&gt;_process();
+      }
+    }
+
+/* Public methods */
+
+    function getPageContentsFile() {
+      return $this-&gt;page_contents;
+    }
+
+/* Private methods */
+
+    function _process() {
+      global $messageStack, $osC_Database, $osC_Customer;
+
+      if (ACCOUNT_GENDER &gt; 0) {
+        if (!isset($_POST['gender']) || (($_POST['gender'] != 'm') &amp;&amp; ($_POST['gender'] != 'f'))) {
+          $messageStack-&gt;add('account_edit', ENTRY_GENDER_ERROR);
+        }
+      }
+
+      if (!isset($_POST['firstname']) || (strlen(trim($_POST['firstname'])) &lt; ACCOUNT_FIRST_NAME)) {
+        $messageStack-&gt;add('account_edit', ENTRY_FIRST_NAME_ERROR);
+      }
+
+      if (!isset($_POST['lastname']) || (strlen(trim($_POST['lastname'])) &lt; ACCOUNT_LAST_NAME)) {
+        $messageStack-&gt;add('account_edit', ENTRY_LAST_NAME_ERROR);
+      }
+
+      if (ACCOUNT_DATE_OF_BIRTH &gt; -1) {
+        if (isset($_POST['dob_days']) &amp;&amp; isset($_POST['dob_months']) &amp;&amp; isset($_POST['dob_years']) &amp;&amp; checkdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) {
+          $dob = mktime(0, 0, 0, $_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years']);
+        } else {
+          $messageStack-&gt;add('account_edit', ENTRY_DATE_OF_BIRTH_ERROR);
+        }
+      }
+
+      if (!isset($_POST['email_address']) || (strlen(trim($_POST['email_address'])) &lt; ACCOUNT_EMAIL_ADDRESS)) {
+        $messageStack-&gt;add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR);
+      } else {
+        if (tep_validate_email($_POST['email_address']) == false) {
+          $messageStack-&gt;add('account_edit', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
+        } else {
+          $Qcheck = $osC_Database-&gt;query('select customers_id from :table_customers where customers_email_address = :customers_email_address and customers_id != :customers_id limit 1');
+          $Qcheck-&gt;bindTable(':table_customers', TABLE_CUSTOMERS);
+          $Qcheck-&gt;bindValue(':customers_email_address', $_POST['email_address']);
+          $Qcheck-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+          $Qcheck-&gt;execute();
+
+          if ($Qcheck-&gt;numberOfRows() &gt; 0) {
+            $messageStack-&gt;add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
+          }
+
+          $Qcheck-&gt;freeResult();
+        }
+      }
+
+      if ($messageStack-&gt;size('account_edit') === 0) {
+        $Qcustomer = $osC_Database-&gt;query('update :table_customers set customers_gender = :customers_gender, customers_firstname = :customers_firstname, customers_lastname = :customers_lastname, customers_email_address = :customers_email_address, customers_dob = :customers_dob where customers_id = :customers_id');
+        $Qcustomer-&gt;bindTable(':table_customers', TABLE_CUSTOMERS);
+        $Qcustomer-&gt;bindValue(':customers_gender', (((ACCOUNT_GENDER &gt; -1) &amp;&amp; isset($_POST['gender']) &amp;&amp; (($_POST['gender'] == 'm') || ($_POST['gender'] == 'f'))) ? $_POST['gender'] : ''));
+        $Qcustomer-&gt;bindValue(':customers_firstname', $_POST['firstname']);
+        $Qcustomer-&gt;bindValue(':customers_lastname', $_POST['lastname']);
+        $Qcustomer-&gt;bindValue(':customers_email_address', $_POST['email_address']);
+        $Qcustomer-&gt;bindValue(':customers_dob', ((ACCOUNT_DATE_OF_BIRTH &gt; -1) ? date('Ymd', $dob) : ''));
+        $Qcustomer-&gt;bindInt(':customers_id', $osC_Customer-&gt;id);
+        $Qcustomer-&gt;execute();
+
+        $Qupdate = $osC_Database-&gt;query('update :table_customers_info set customers_info_date_account_last_modified = now() where customers_info_id = :customers_info_id');
+        $Qupdate-&gt;bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO);
+        $Qupdate-&gt;bindInt(':customers_info_id', $osC_Customer-&gt;id);
+        $Qupdate-&gt;execute();
+
+// reset the session variables
+        if (ACCOUNT_GENDER &gt; -1) {
+          $osC_Customer-&gt;setGender($_POST['gender']);
+        }
+        $osC_Customer-&gt;setFirstName(trim($_POST['firstname']));
+        $osC_Customer-&gt;setLastName(trim($_POST['lastname']));
+        $osC_Customer-&gt;setFullName();
+        $osC_Customer-&gt;setEmailAddress(trim($_POST['email_address']));
+
+        $messageStack-&gt;add_session('account', SUCCESS_ACCOUNT_UPDATED, 'success');
+
+        tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', '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