From 78d2bc33a9b7c121a36310fa2c4c781503418fff Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Fri, 26 Feb 2016 13:04:35 +0000 Subject: [PATCH] support SINCE, BEFORE, BETWEEN and ON as (range) date filters; use it in mail_zpush and add example usage to get_rows --- mail/inc/class.mail_ui.inc.php | 13 ++++++++++++- mail/inc/class.mail_zpush.inc.php | 15 ++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index af41c8ca92..73519c17fa 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -1308,11 +1308,15 @@ class mail_ui emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true; } } + //$cutoffdate = egw_time::to('now','ts')-(3600*24*3);//SINCE, enddate + //$cutoffdate2 = egw_time::to('now','ts');//-(3600*24*2);//BEFORE, startdate $filter = array( 'filterName' => (emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), 'type' => ($query['cat_id']?$query['cat_id']:(emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), 'string' => $query['search'], - 'status' => 'any'); + 'status' => 'any', + //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) + ); } else { @@ -1330,6 +1334,13 @@ class mail_ui $GLOBALS['egw']->preferences->save_repository(true); } //error_log(__METHOD__.__LINE__.' maxMessages:'.$maxMessages.' Offset:'.$offset.' Filter:'.array2string($mail_ui->sessionData['messageFilter'])); +/* +$cutoffdate = egw_time::to('now','ts')-(3600*24*6);//SINCE, enddate +$cutoffdate2 = egw_time::to('now','ts')-(3600*24*3);//BEFORE, startdate +$filter['range'] = "BETWEEN";// we support SINCE, BEFORE, BETWEEN and ON +$filter['since'] = date("d-M-Y", $cutoffdate); +$filter['before']= date("d-M-Y", $cutoffdate2); +*/ try { if ($maxMessages > 75) diff --git a/mail/inc/class.mail_zpush.inc.php b/mail/inc/class.mail_zpush.inc.php index ec35d9ac52..4855b5ac6e 100644 --- a/mail/inc/class.mail_zpush.inc.php +++ b/mail/inc/class.mail_zpush.inc.php @@ -255,7 +255,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, */ private function _disconnect() { - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); + if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__); if ($this->mail) $this->mail->closeConnection(); unset($this->mail); @@ -271,24 +271,24 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, public function GetFolderList() { $folderlist = array(); - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); + if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__); /*foreach($available_accounts as $account)*/ $account = 0; { $this->_connect($account); if (!isset($this->folders)) $this->folders = $this->mail->getFolderObjects(true,false,$_alwaysGetDefaultFolders=true); - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); + if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($this->folders)); foreach ($this->folders as $folder => $folderObj) { - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); + if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' folder='.$folder); $folderlist[] = $f = array( 'id' => $this->createID($account,$folder), 'mod' => $folderObj->shortDisplayName, 'parent' => $this->getParentID($account,$folder), ); - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); + if ($this->debugLevel>1) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($f)); } } - ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); + if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."() returning ".array2string($folderlist)); return $folderlist; } @@ -1067,6 +1067,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, //mail AND meeting. we dont want this. accepting meeting requests with the mobile does nothing $output->meetingrequest->globalobjid = activesync_backend::uid2globalObjId($id); $output->messageclass = "IPM.Schedule.Meeting.Request"; + //$output->messageclass = "IPM.Schedule.Meeting"; unset($attachment); continue; // do NOT add attachment as attachment } @@ -1364,7 +1365,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, } $messagelist = $_filter = array(); // if not connected, any further action must fail - if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); + if (!empty($cutoffdate)) $_filter = array('status'=>array('UNDELETED'),'range'=>"SINCE",'date'=> date("d-M-Y", $cutoffdate)); if ($this->debugLevel>1) $starttime = microtime (true); $account = $_folderName = $id = null; $this->splitID($folderid,$account,$_folderName,$id);