pass Horde_Date objects to dateSearch()
authorChuck Hagenbuch <chuck@horde.org>
Sun, 18 Jan 2009 03:57:38 +0000 (22:57 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 18 Jan 2009 03:57:38 +0000 (22:57 -0500)
imp/lib/Maintenance/Task/purge_sentmail.php
imp/lib/Maintenance/Task/purge_spam.php
imp/lib/Maintenance/Task/purge_trash.php
imp/lib/Search.php

index 7399831..cf79d04 100644 (file)
@@ -32,9 +32,6 @@ class Maintenance_Task_purge_sentmail extends Maintenance_Task
          * in 'purge_sentmail_keep'.  If a message has a timestamp prior to
          * this value, it will be deleted. */
         $del_time = new Horde_Date(time() - ($prefs->getValue('purge_sentmail_keep') * 86400));
-        $month = $del_time->format('n');
-        $day = $del_time->format('j');
-        $year = $del_time->format('Y');
 
         foreach ($mbox_list as $mbox) {
             /* Make sure the sent-mail mailbox exists. */
@@ -45,7 +42,7 @@ class Maintenance_Task_purge_sentmail extends Maintenance_Task
             /* Open the sent-mail mailbox and get the list of messages older
              * than 'purge_sentmail_keep' days. */
             $query = new Horde_Imap_Client_Search_Query();
-            $query->dateSearch($month, $day, $year, Horde_Imap_Client_Search_Query::DATE_BEFORE);
+            $query->dateSearch($del_time, Horde_Imap_Client_Search_Query::DATE_BEFORE);
             $msg_ids = $GLOBALS['imp_search']->runSearchQuery($query, $mbox);
             if (empty($msg_ids)) {
                 continue;
index 2ee177f..d37b1cb 100644 (file)
@@ -38,13 +38,10 @@ class Maintenance_Task_purge_spam extends Maintenance_Task
            specified in 'purge_spam_keep'.  If a message has a
            timestamp prior to this value, it will be deleted. */
         $del_time = new Horde_Date(time() - ($prefs->getValue('purge_spam_keep') * 86400));
-        $month = $del_time->format('n');
-        $day = $del_time->format('j');
-        $year = $del_time->format('Y');
 
         /* Get the list of messages older than 'purge_spam_keep' days. */
         $query = new Horde_Imap_Client_Search_Query();
-        $query->dateSearch($month, $day, $year, Horde_Imap_Client_Search_Query::DATE_BEFORE);
+        $query->dateSearch($del_time, Horde_Imap_Client_Search_Query::DATE_BEFORE);
         $msg_ids = $GLOBALS['imp_search']->runSearchQuery($query, $mbox);
         if (empty($msg_ids)) {
             return false;
index 40d32a0..e0782e7 100644 (file)
@@ -38,13 +38,10 @@ class Maintenance_Task_purge_trash extends Maintenance_Task
            specified in 'purge_trash_keep'.  If a message has a
            timestamp prior to this value, it will be deleted. */
         $del_time = new Horde_Date(time() - ($prefs->getValue('purge_trash_keep') * 86400));
-        $month = $del_time->format('n');
-        $day = $del_time->format('j');
-        $year = $del_time->format('Y');
 
         /* Get the list of messages older than 'purge_trash_keep' days. */
         $query = new Horde_Imap_Client_Search_Query();
-        $query->dateSearch($month, $day, $year, Horde_Imap_Client_Search_Query::DATE_BEFORE);
+        $query->dateSearch($del_time, Horde_Imap_Client_Search_Query::DATE_BEFORE);
         $msg_ids = $GLOBALS['imp_search']->runSearchQuery($query, $mbox);
         if (empty($msg_ids)) {
             return false;
index 5a17044..9b4dfa9 100644 (file)
@@ -835,7 +835,8 @@ class IMP_Search
                     if (!empty($search['date'][$key]['day']) &&
                         !empty($search['date'][$key]['month']) &&
                         !empty($search['date'][$key]['year'])) {
-                        $ob->dateSearch($search['date'][$key]['month'], $search['date'][$key]['day'], $search['date'][$key]['year'], ($val == 'date_on') ? Horde_Imap_Client_Search_Query::DATE_ON : (($val == 'date_until') ? Horde_Imap_Client_Search_Query::DATE_BEFORE : Horde_Imap_Client_Search_Query::DATE_SINCE));
+                        $date = new Horde_Date($search['date']);
+                        $ob->dateSearch($date, ($val == 'date_on') ? Horde_Imap_Client_Search_Query::DATE_ON : (($val == 'date_until') ? Horde_Imap_Client_Search_Query::DATE_BEFORE : Horde_Imap_Client_Search_Query::DATE_SINCE));
                         $search_array[] = $ob;
                     }
                     break;