* eMail: some Servers have very limited SEARCH capability; (no OR allowed/supported) try to detect and act accordingly

This commit is contained in:
Klaus Leithoff 2014-04-11 13:52:58 +00:00
parent dd19f4ffff
commit 40136cff9b
3 changed files with 121 additions and 9 deletions

View File

@ -1724,9 +1724,15 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
//}
if (isset($searchquery['query'][0]['value']['FolderId'])) $folderid = $searchquery['query'][0]['value']['FolderId'];
// other types may be possible - we support quicksearch first (freeText in subject and from (or TO in Sent Folder))
if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
{
emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10);
if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
}
if (isset($searchquery['query'][0]['value']['Search:FreeText']))
{
$type = 'quick';
$type = (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject');
$searchText = $searchquery['query'][0]['value']['Search:FreeText'];
}
if (!$folderid)
@ -1740,7 +1746,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
//if (isset($searchquery['query'][0]['value'][subquery][1][value][POOMMAIL:DateReceived]));
//$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate));
$rv = $this->splitID($folderid,$account,$_folderName,$id);
$_filter = array('type'=> 'quick',
$_filter = array('type'=> (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'),
'string'=> $searchText,
'status'=>'any',
);

View File

@ -450,11 +450,24 @@ class mail_ui
'keyword5' => 'later', //lang('later'),
));
}
else
{
foreach(array('keyword1','keyword2','keyword3','keyword4','keyword5') as $i => $k)
{
if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
}
}
if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
$content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder'];
//$sel_options['cat_id'] = array(1=>'none');
if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
{
emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10);
if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
}
if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]) unset($this->searchTypes['quick']);
$sel_options['filter2'] = $this->searchTypes;
$sel_options['filter'] = $this->statusTypes;
//if (!isset($content[self::$nm_index]['cat_id'])) $content[self::$nm_index]['cat_id'] = 'All';
@ -622,7 +635,7 @@ class mail_ui
// sending preview toolbar actions
$etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2']='quick';
if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2']=(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject');
$readonlys = $preserv = array();
if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
@ -1472,7 +1485,12 @@ unset($query['actions']);
if (!empty($query['search']))
{
//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
$filter = array('filterName' => lang('quicksearch'),'type' => ($query['filter2']?$query['filter2']:'quick'),'string' => $query['search'],'status' => 'any');
if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
{
emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10);
if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
}
$filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => 'any');
}
else
{
@ -3981,11 +3999,54 @@ $this->partID = $partID;
$refreshData['vacationnotice'] = '';
$refreshData['vacationrange'] = '';
}
$response = egw_json_response::get();
$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
}
/**
* ajax_refreshFilters - its called via json, so the function must start with ajax (or the class-name must contain ajax)
* Note: only the activeProfile Filters are refreshed
* @param int $icServerId profileId / server ID to work on; may be empty -> then activeProfile is used
* if other than active profile; nothing is done!
* @return nothing
*/
function ajax_refreshFilters($icServerId=null)
{
//error_log(__METHOD__.__LINE__.array2string($icServerId));
if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]))
{
emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10);
if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true;
}
if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])
{
unset($this->searchTypes['quick']);
}
if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
{
$this->statusTypes = array_merge($this->statusTypes,array(
'keyword1' => 'important',//lang('important'),
'keyword2' => 'job', //lang('job'),
'keyword3' => 'personal',//lang('personal'),
'keyword4' => 'to do', //lang('to do'),
'keyword5' => 'later', //lang('later'),
));
}
else
{
foreach(array('keyword1','keyword2','keyword3','keyword4','keyword5') as $i => $k)
{
if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
}
}
$response = egw_json_response::get();
$response->call('app.mail.mail_refreshFilter2Options',$this->searchTypes);
$response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes);
}
/**
* ajax_refreshQuotaDisplay - its called via json, so the function must start with ajax (or the class-name must contain ajax)
*

View File

@ -793,6 +793,7 @@ app.classes.mail = AppJS.extend(
mail_setQuotaDisplay: function(_data)
{
//this.et2 should do the same as etemplate2.getByApplication('mail')[0].widgetContainer
if (!this.et2) this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
var quotabox = this.et2.getWidgetById(this.nm_index+'[quotainpercent]');
// Check to make sure it's there
@ -825,7 +826,7 @@ app.classes.mail = AppJS.extend(
//var vacationrange = this.et2.getWidgetById(this.nm_index+'[vacationrange]');
//console.log(_data,vacationnotice,vacationrange);
//try to set it via set_value and set label
if (!this.et2) return;
if (!this.et2) this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
if (_data == null)
{
this.et2.getWidgetById(this.nm_index+'[vacationnotice]').set_value('');
@ -838,6 +839,47 @@ app.classes.mail = AppJS.extend(
}
},
/**
* mail_refreshFilter2Options, function to call with appropriate data to refresh the filter2 options for the active server
*
*/
mail_refreshFilter2Options: function(_data)
{
//alert('mail_refreshFilter2Options');
if (_data == null) return;
if (!this.et2) this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
var filter2 = this.et2.getWidgetById('filter2');
var current = filter2.value;
var currentexists=false;
for (var k in _data)
{
if (k==current) currentexists=true;
}
if (!currentexists) filter2.set_value('subject');
filter2.set_select_options(_data);
},
/**
* mail_refreshFilterOptions, function to call with appropriate data to refresh the filter options for the active server
*
*/
mail_refreshFilterOptions: function(_data)
{
//alert('mail_refreshFilterOptions');
if (_data == null) return;
if (!this.et2) this.et2 = etemplate2.getByApplication('mail')[0].widgetContainer;
var filter = this.et2.getWidgetById('filter');
var current = filter.value;
var currentexists=false;
for (var k in _data)
{
if (k==current) currentexists=true;
}
if (!currentexists) filter.set_value('any');
filter.set_select_options(_data);
},
/**
* Queues a refreshFolderList request for 10ms. Actually this will just execute the
* code after the calling script has finished.
@ -1280,8 +1322,11 @@ app.classes.mail = AppJS.extend(
this.mail_refreshQuotaDisplay(server[0]);
this.mail_fetchCurrentlyFocussed(null,true);
this.mail_preview();
if (server[0]!=previousServer[0]) this.mail_callRefreshVacationNotice(server[0]);
if (server[0]!=previousServer[0])
{
this.mail_callRefreshVacationNotice(server[0]);
egw.jsonq('mail.mail_ui.ajax_refreshFilters',[server[0]]);
}
},
/**
@ -2850,4 +2895,4 @@ $j(function() {
}
}).tooltip("open");
});
});
});