Update of /cvsroot/tep/catalog/catalog/includes/functions
In directory sc8-pr-cvs1:/tmp/cvs-serv19329/includes/functions
Modified Files:
general.php
Log Message:
introduce two new functions that are used in the My Account proposal
realization
Index: general.php
===================================================================
RCS file: /cvsroot/tep/catalog/catalog/includes/functions/general.php,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -d -r1.221 -r1.222
--- general.php 14 May 2003 17:39:34 -0000 1.221
+++ general.php 19 May 2003 19:46:55 -0000 1.222
@@ -570,7 +570,7 @@
// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
// NOTE: Includes a workaround for dates before 01/01/1970 that fail on
windows servers
function tep_date_short($raw_date) {
- if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return
false;
+ if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return
false;
$year = substr($raw_date, 0, 4);
$month = (int)substr($raw_date, 5, 2);
@@ -1221,5 +1221,51 @@
}
return $ip;
+ }
+
+ function tep_count_customer_orders($id = '', $check_session = true) {
+ global $customer_id;
+
+ if (is_numeric($id) == false) {
+ if (tep_session_is_registered('customer_id')) {
+ $id = $customer_id;
+ } else {
+ return 0;
+ }
+ }
+
+ if ($check_session == true) {
+ if ( (tep_session_is_registered('customer_id') == false) || ($id !=
$customer_id) ) {
+ return 0;
+ }
+ }
+
+ $orders_check_query = tep_db_query("select count(*) as total from " .
TABLE_ORDERS . " where customers_id = '" . (int)$id . "'");
+ $orders_check = tep_db_fetch_array($orders_check_query);
+
+ return $orders_check['total'];
+ }
+
+ function tep_count_customer_address_book_entries($id = '', $check_session =
true) {
+ global $customer_id;
+
+ if (is_numeric($id) == false) {
+ if (tep_session_is_registered('customer_id')) {
+ $id = $customer_id;
+ } else {
+ return 0;
+ }
+ }
+
+ if ($check_session == true) {
+ if ( (tep_session_is_registered('customer_id') == false) || ($id !=
$customer_id) ) {
+ return 0;
+ }
+ }
+
+ $addresses_query = tep_db_query("select count(*) as total from " .
TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$id . "'");
+ $addresses = tep_db_fetch_array($addresses_query);
+
+ return $addresses['total'];
}
?>
-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
|