[geeklog-hg] geeklog: Search Class now attempts to figure out start and end d...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri Dec 21 16:25:56 EST 2012


changeset 8884:f65d153d776f
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/f65d153d776f
user: Tom <websitemaster at cogeco.net>
date: Fri Dec 21 16:22:33 2012 -0500
description:
Search Class now attempts to figure out start and end dates. (bug #0000853)

diffstat:

 public_html/lib-common.php              |   4 ++--
 system/classes/searchcriteria.class.php |  29 +++++++++++++++++++----------
 2 files changed, 21 insertions(+), 12 deletions(-)

diffs (54 lines):

diff -r 1ea82ba0227a -r f65d153d776f public_html/lib-common.php
--- a/public_html/lib-common.php	Fri Dec 21 15:35:42 2012 -0500
+++ b/public_html/lib-common.php	Fri Dec 21 16:22:33 2012 -0500
@@ -34,8 +34,8 @@
 // +---------------------------------------------------------------------------+
 
 // Prevent PHP from reporting uninitialized variables
-error_reporting(E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR | E_USER_ERROR);
-
+//error_reporting(E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR | E_USER_ERROR);
+error_reporting(E_ALL);
 /**
 * This is the common library for Geeklog.  Through our code, you will see
 * functions with the COM_ prefix (e.g. COM_siteHeader()).  Any such functions
diff -r 1ea82ba0227a -r f65d153d776f system/classes/searchcriteria.class.php
--- a/system/classes/searchcriteria.class.php	Fri Dec 21 15:35:42 2012 -0500
+++ b/system/classes/searchcriteria.class.php	Fri Dec 21 16:22:33 2012 -0500
@@ -226,17 +226,26 @@
 
     function getDateRangeSQL( $type = 'WHERE', $column, $datestart, $dateend )
     {
-        if (!empty($datestart) && !empty($dateend))
-        {
-            $delim = substr($datestart, 4, 1);
-            if (!empty($delim))
-            {
-                $DS = explode($delim, $datestart);
-                $DE = explode($delim, $dateend);
-                $startdate = mktime(0,0,0,$DS[1],$DS[2],$DS[0]);
-                $enddate = mktime(23,59,59,$DE[1],$DE[2],$DE[0]);
-                return " $type (UNIX_TIMESTAMP($column) BETWEEN '$startdate' AND '$enddate') ";
+        if (!empty($datestart) || !empty($dateend)) {
+            // Do some date checking and fill in missing dates
+            $delim = '-';
+            if (empty($datestart) || (strtotime($datestart) == false)) {
+                $datestart = "0000-00-00";
+            } else {
+                $datestart = date('Y-m-d', strtotime($datestart));
             }
+            if (empty($dateend) || (strtotime($dateend) == false)) {
+                $dateend = date('Y-m-d');
+            } else {
+                $dateend = date('Y-m-d', strtotime($dateend));
+            }
+            
+            $DS = explode($delim, $datestart);
+            $DE = explode($delim, $dateend);
+            $startdate = mktime(0,0,0,$DS[1],$DS[2],$DS[0]);
+            $enddate = mktime(23,59,59,$DE[1],$DE[2],$DE[0]);
+            
+            return " $type (UNIX_TIMESTAMP($column) BETWEEN '$startdate' AND '$enddate') ";
         }
 
         return '';



More information about the geeklog-cvs mailing list