* eSync/Mail: allow to override the settingregarding the date range for syncing mail when no limit is set clientside (preventing client crash that may be caused by too many mails/too much data (default is half a year)). If you want to sync way-back into the past: set a large number

This commit is contained in:
leithoff 2016-07-28 15:47:54 +02:00
parent 3e1f7613de
commit 0e93274657

View File

@ -67,6 +67,9 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
static $profileID; static $profileID;
// to control how deep one may dive into the past
const PAST_LIMIT = 178;
/** /**
* debugLevel - enables more debug * debugLevel - enables more debug
* *
@ -172,6 +175,15 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
'default' => 'sendifnocalnotif', 'default' => 'sendifnocalnotif',
'admin' => False, 'admin' => False,
); );
$settings['mail-maximumSyncRange'] = array(
'type' => 'input',
'label' => lang('How many days to sync in the past when client does not specify a date-range (default %1)', self::PAST_LIMIT),
'name' => 'mail-maximumSyncRange',
'help' => 'if the client sets no sync range, you may override the setting (preventing client crash that may be caused by too many mails/too much data). If you want to sync way-back into the past: set a large number',
'xmlrpc' => True,
'admin' => False,
);
/* /*
$sigOptions = array( $sigOptions = array(
'send'=>'yes, always add EGroupware signatures to outgoing mails', 'send'=>'yes, always add EGroupware signatures to outgoing mails',
@ -1373,8 +1385,13 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
} }
else else
{ {
$cutoffdate = Api\DateTime::to('now','ts')-(3600*24*28*3); $maximumSyncRangeInDays = self::PAST_LIMIT; // corresponds to our default value
ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using 12 weeks.'.date("d-M-Y", $cutoffdate)); if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange']))
{
$maximumSyncRangeInDays = $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-maximumSyncRange'];
}
$cutoffdate = (is_numeric($maximumSyncRangeInDays) ? Api\DateTime::to('now','ts')-(3600*24*$maximumSyncRangeInDays):null);
if (is_numeric($maximumSyncRangeInDays)) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.' Client set no truncationdate. Using '.$maximumSyncRangeInDays.' days.'.date("d-M-Y", $cutoffdate));
} }
return $this->fetchMessages($folderid, $cutoffdate); return $this->fetchMessages($folderid, $cutoffdate);
} }