do stuff to implement a store to folder input field

This commit is contained in:
Klaus Leithoff 2013-07-20 13:10:17 +00:00
parent 2beadad730
commit 9d072f9b0b
4 changed files with 66 additions and 21 deletions

View File

@ -1769,17 +1769,18 @@ class mail_bo
* @param boolean _getCounters get get messages counters
* @param boolean _alwaysGetDefaultFolders this triggers to ignore the possible notavailableautofolders - preference
* as activeSync needs all folders like sent, trash, drafts, templates and outbox - if not present devices may crash
* @param boolean _useCacheIfPossible - if set to false cache will be ignored and reinitialized
*
* @return array with folder objects. eg.: INBOX => {inbox object}
*/
function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false)
function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true)
{
if (self::$debug) error_log(__METHOD__.__LINE__.' '."subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders");
static $folders2return;
if ($_subscribedOnly && $_getCounters===false)
{
if (is_null($folders2return)) $folders2return = egw_cache::getCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
if (isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId]))
{
//error_log(__METHOD__.__LINE__.' using Cached folderObjects');
return $folders2return[$this->icServer->ImapServerId];

View File

@ -80,11 +80,12 @@ class mail_compose
}
$this->displayCharset = $GLOBALS['egw']->translation->charset();
$profileID = 0;
if (isset($GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID']))
$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID'];
if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']))
$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
$this->bosignatures = new felamimail_bosignatures();
$this->mail_bo = mail_bo::getInstance(true,$profileID);
$profileID = $GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID'] = $this->mail_bo->profileID;
$profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->mail_bo->profileID;
$this->bopreferences =& $this->mail_bo->bopreferences;
$this->preferences =& $this->mail_bo->mailPreferences; // $this->bopreferences->getPreferences();
// we should get away from this $this->preferences->preferences should hold the same info
@ -2489,10 +2490,48 @@ $content['mailtext'] = 'garbage';
return $_string;
}
}
function ajax_decodeFolderName($_folderName) {
$folderName = translation::convert(html_entity_decode($_folderName, ENT_QUOTES, $this->charset),'UTF7-IMAP', $this->charset);
//$response->add("decodedFolder ='".$folderName."'");
function ajax_searchIdentities() {
}
function ajax_searchFolder() {
static $useCacheIfPossible;
if (is_null($useCacheIfPossible)) $useCacheIfPossible = true;
$_searchString = trim($_REQUEST['query']);
$results = array();
if (strlen($_searchString)>=2 && isset($this->mail_bo->icServer))
{
//error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId);
if (!($this->mail_bo->icServer->_connected == 1)) $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
if (count($folderObjects)<=1) {
$useCacheIfPossible = false;
}
else
{
$useCacheIfPossible = true;
}
$searchString = translation::convert($_searchString, mail_bo::$displayCharset,'UTF7-IMAP');
foreach ($folderObjects as $k =>$fA)
{
error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName);
$f=false;
if (stripos($fA->displayName,$_searchString)!==false)
{
$f=true;
$results[] = array('id'=>$k, 'label' => htmlspecialchars($fA->displayName));
}
if ($f==false && stripos($k,$searchString)!==false)
{
$results[] = array('id'=>$k, 'label' => htmlspecialchars($fA->displayName));
}
}
}
//error_log(__METHOD__.__LINE__.' IcServer:'.$this->mail_bo->icServer->ImapServerId.':'.array2string($results));
//$folderName = translation::convert(html_entity_decode($_folderName, ENT_QUOTES, $this->charset),'UTF7-IMAP', $this->charset);
//$response->add("decodedFolder ='".$folderName."'");
header('Content-Type: application/json; charset=utf-8');
echo json_encode($results);
common::egw_exit();

View File

@ -113,7 +113,7 @@ class mail_ui
emailadmin_bo::unsetCachedObjects(self::$icServerID);
}
$this->mail_bo = mail_bo::getInstance(false,$icServerID);
$this->mail_bo = mail_bo::getInstance(false,self::$icServerID);
if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
// no icServer Object: something failed big time
if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config
@ -1623,6 +1623,7 @@ unset($query['actions']);
if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
{
if (!isset($envelope[$field])) continue;
foreach($envelope[$field] as $field_data)
{
//error_log(__METHOD__.__LINE__.array2string($field_data));

View File

@ -4,25 +4,29 @@
<template id="mail.compose" template="" lang="" group="0" version="1.9.001">
<html id="msg"/>
<vbox class="mailCompose mailComposeHeaderSection" width="100%">
<hbox class="mailComposeHeaders" width="100%">
<description value="From"/>
<taglist id="TO" autocomplete_url='mail.mail_compose.ajax_searchAddress' autocomplete_params='' onclick="app.mail.address_click"/>
<hbox class="mailComposeHeaders" width="99%">
<description value="To"/>
<taglist id="TO" width="98%" autocomplete_url='mail.mail_compose.ajax_searchAddress' autocomplete_params='' onclick="app.mail.address_click"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<hbox class="mailComposeHeaders" width="99%">
<description value="Cc"/>
<taglist id="CC" onclick="app.mail.address_click"/>
<taglist id="CC" width="98%" autocomplete_url='mail.mail_compose.ajax_searchAddress' autocomplete_params='' onclick="app.mail.address_click"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<hbox class="mailComposeHeaders" width="99%">
<description value="Bcc"/>
<taglist id="BCC" onclick="app.mail.address_click"/>
<taglist id="BCC" width="98%" autocomplete_url='mail.mail_compose.ajax_searchAddress' autocomplete_params='' onclick="app.mail.address_click"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<description value="Date"/>
<date-time align="left" id="mail_composedate" readonly="true"/>
<hbox class="mailComposeHeaders" width="99%">
<description value="Reply To"/>
<taglist id="REPLYTO" width="98%" autocomplete_url='mail.mail_compose.ajax_searchIdentities' autocomplete_params='' onclick="app.mail.address_click"/>
</hbox>
<hbox class="mailComposeHeaders" width="100%">
<hbox class="mailComposeHeaders" width="99%">
<description value="Store to Folder"/>
<taglist id="FOLDER" width="98%" autocomplete_url='mail.mail_compose.ajax_searchFolder' autocomplete_params='' onclick="app.mail.address_click"/>
</hbox>
<hbox class="mailComposeHeaders" width="99%">
<description value="Subject"/>
<description align="left" id="mail_composesubject" readonly="true"/>
<textbox align="left" width="95%" id="mail_composesubject"/>
</hbox>
<hbox class="mail_Composeicons">
<html id="mail_composeicons"/>