diff --git a/mail/inc/class.mail_bo.inc.php b/mail/inc/class.mail_bo.inc.php index 7c08533541..021888919f 100644 --- a/mail/inc/class.mail_bo.inc.php +++ b/mail/inc/class.mail_bo.inc.php @@ -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]; diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 5f422ee990..7d862cc873 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -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(); diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index ca02e6221c..10d9c71eaf 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -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)); diff --git a/mail/templates/default/compose.xet b/mail/templates/default/compose.xet index 6718df9071..4ee610b411 100644 --- a/mail/templates/default/compose.xet +++ b/mail/templates/default/compose.xet @@ -4,25 +4,29 @@