* eMail: offer last moveTo folder as direct menuaction; try to avoid to access --topfolder--

This commit is contained in:
Klaus Leithoff 2012-12-19 14:49:20 +00:00
parent c6b2086ba0
commit 660976b77f
3 changed files with 48 additions and 2 deletions

View File

@ -46,6 +46,14 @@ class ajaxfelamimail
function ajaxfelamimail() function ajaxfelamimail()
{ {
if($this->_debug) error_log("ajaxfelamimail::ajaxfelamimail"); if($this->_debug) error_log("ajaxfelamimail::ajaxfelamimail");
$folderToSelect = null; // attempt to select the right folder at initialization
if (isset($_GET['menuaction']) && $_GET['menuaction']=='felamimail.ajaxfelamimail.updateMessageView')
{
//error_log("ajaxfelamimail::ajaxfelamimail".array2string(json_decode($_POST['json_data'])));
if (isset($_POST['json_data'])) $r = json_decode($_POST['json_data']);
if (isset($r->request->parameters[0])) $folderToSelect = $r->request->parameters[0];
if ($folderToSelect=="--topfolder--") $folderToSelect = null;
}
if (isset($GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID'])) if (isset($GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID']))
$this->imapServerID = (int)$GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID']; $this->imapServerID = (int)$GLOBALS['egw_info']['user']['preferences']['felamimail']['ActiveProfileID'];
//error_log("ajaxfelamimail::ajaxfelamimail ActiveProfile:".$this->imapServerID ); //error_log("ajaxfelamimail::ajaxfelamimail ActiveProfile:".$this->imapServerID );
@ -64,6 +72,7 @@ class ajaxfelamimail
if(!isset($this->sessionDataAjax['folderName'])) { if(!isset($this->sessionDataAjax['folderName'])) {
$this->sessionDataAjax['folderName'] = $this->sessionData['mailbox']?$this->sessionData['mailbox']:'INBOX'; $this->sessionDataAjax['folderName'] = $this->sessionData['mailbox']?$this->sessionData['mailbox']:'INBOX';
} }
if(isset($this->sessionDataAjax['folderName'])) $this->bofelamimail->reopen((isset($folderToSelect)?$folderToSelect:$this->sessionDataAjax['folderName']));
//error_log("ajaxfelamimail::ajaxfelamimail ActiveProfile:".$this->imapServerID.' activeFolder:'.$this->sessionDataAjax['folderName'].'./.'.$this->sessionData['mailbox'].' ConnectionStatus:'.array2string($this->_connectionStatus)); //error_log("ajaxfelamimail::ajaxfelamimail ActiveProfile:".$this->imapServerID.' activeFolder:'.$this->sessionDataAjax['folderName'].'./.'.$this->sessionData['mailbox'].' ConnectionStatus:'.array2string($this->_connectionStatus));
} }
@ -982,6 +991,9 @@ class ajaxfelamimail
$response->addScript('onNodeSelect("'.$this->sessionData['mailbox'].'");'); $response->addScript('onNodeSelect("'.$this->sessionData['mailbox'].'");');
return $response->getXML(); return $response->getXML();
} }
$lastFolderUsedForMove = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
$lastFolderUsedForMove[$this->imapServerID] = $folderName;
egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFolderUsedForMove,$expiration=60*60*1);
} else { } else {
if($this->_debug) error_log("ajaxfelamimail::moveMessages-> same folder than current selected"); if($this->_debug) error_log("ajaxfelamimail::moveMessages-> same folder than current selected");
} }
@ -1704,7 +1716,7 @@ class ajaxfelamimail
// unset the previewID, as the Message will not be available on another folder // unset the previewID, as the Message will not be available on another folder
if ($folderName != $this->sessionData['mailbox']) unset($this->sessionData['previewMessage']); if ($folderName != $this->sessionData['mailbox']) unset($this->sessionData['previewMessage']);
$this->sessionData['mailbox'] = $folderName; $this->sessionData['mailbox'] = $this->sessionDataAjax['folderName'] = $folderName;
$this->sessionData['startMessage'] = 1; $this->sessionData['startMessage'] = 1;
$this->saveSessionData(); $this->saveSessionData();

View File

@ -57,6 +57,7 @@ class uiwidgets
$this->_connectionStatus = $this->bofelamimail->openConnection($this->profileID); $this->_connectionStatus = $this->bofelamimail->openConnection($this->profileID);
$this->sessionData =& $GLOBALS['egw']->session->appsession('session_data','felamimail'); $this->sessionData =& $GLOBALS['egw']->session->appsession('session_data','felamimail');
$this->bofelamimail->reopen($this->sessionData['mailbox']);
$this->sessionData['folderStatus'] = egw_cache::getCache(egw_cache::INSTANCE,'email','folderStatus'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1); $this->sessionData['folderStatus'] = egw_cache::getCache(egw_cache::INSTANCE,'email','folderStatus'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*1);
$previewFrameHeight = -1; $previewFrameHeight = -1;
if ($GLOBALS['egw_info']['user']['preferences']['felamimail']['PreViewFrameHeight'] && if ($GLOBALS['egw_info']['user']['preferences']['felamimail']['PreViewFrameHeight'] &&
@ -316,7 +317,23 @@ class uiwidgets
'Drafts' => 'Drafts', 'Drafts' => 'Drafts',
'Sent' => 'Sent', 'Sent' => 'Sent',
); );
$lastFolderUsedForMove = null;
$moveaction = 'move_';
$lastFolderUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
if (isset($lastFolderUsedForMoveCont[$this->profileID]))
{
$_folder = $this->bofelamimail->icServer->getCurrentMailbox();
//error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFolderUsedForMoveCont[$this->profileID].function_backtrace());
//if ($_folder!=$lastFolderUsedForMoveCont[$this->profileID]) $this->bofelamimail->icServer->selectMailbox($lastFolderUsedForMoveCont[$this->profileID]);
if ($_folder!=$lastFolderUsedForMoveCont[$this->profileID])
{
$lastFolderUsedForMove = $this->bofelamimail->getFolderStatus($lastFolderUsedForMoveCont[$this->profileID]);
//error_log(array2string($lastFolderUsedForMove));
$moveaction .= $lastFolderUsedForMoveCont[$this->profileID];
}
//if ($_folder!=$lastFolderUsedForMoveCont[$this->profileID]) $this->bofelamimail->icServer->selectMailbox($_folder);
}
$actions = array( $actions = array(
'open' => array( 'open' => array(
'caption' => lang('Open'), 'caption' => lang('Open'),
@ -374,6 +391,13 @@ class uiwidgets
'onExecute' => 'javaScript:mail_compose', 'onExecute' => 'javaScript:mail_compose',
'allowOnMultiple' => false, 'allowOnMultiple' => false,
), ),
$moveaction => array(
'caption' => lang('Move to Folder').' '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''),
'icon' => 'move',
'group' => ++$group,
'onExecute' => 'javaScript:mail_move2folder',
'allowOnMultiple' => true,
),
'infolog' => array( 'infolog' => array(
'caption' => 'InfoLog', 'caption' => 'InfoLog',
'hint' => 'Save as InfoLog', 'hint' => 'Save as InfoLog',
@ -630,6 +654,10 @@ class uiwidgets
{ {
unset($actions['tracker']); unset($actions['tracker']);
} }
if (empty($lastFolderUsedForMove))
{
unset($actions[$moveaction]);
}
// note this one is NOT a real CAPABILITY reported by the server, but added by selectMailbox // note this one is NOT a real CAPABILITY reported by the server, but added by selectMailbox
if (!$this->bofelamimail->icServer->hasCapability('SUPPORTS_KEYWORDS')) if (!$this->bofelamimail->icServer->hasCapability('SUPPORTS_KEYWORDS'))
{ {

View File

@ -637,7 +637,7 @@ function onNodeSelect(_nodeID) {
*/ */
CopyOrMoveCalled = false; CopyOrMoveCalled = false;
//- } else { //- } else {
if (_nodeID=='--topfolder--') _nodeID = 'INBOX';
mail_resetMessageSelect(); mail_resetMessageSelect();
egw_appWindow('felamimail').setStatusMessage('<span style="font-weight: bold;">' + egw_appWindow('felamimail').lang_loading + ' ' + top.tree.getUserData(_nodeID, 'folderName') + '</span>'); egw_appWindow('felamimail').setStatusMessage('<span style="font-weight: bold;">' + egw_appWindow('felamimail').lang_loading + ' ' + top.tree.getUserData(_nodeID, 'folderName') + '</span>');
mail_cleanup(); mail_cleanup();
@ -1556,6 +1556,12 @@ function mail_CopyOrMove(_action, _elems) {
CopyOrMoveCalled = true; CopyOrMoveCalled = true;
} }
function mail_move2folder(_action, _elems) {
//alert('Copy or Move Called:'+_action.id);
// _action.id holds folder target information
mail_move(_action, _elems, null);
}
/** /**
* Move (multiple) messages to given folder * Move (multiple) messages to given folder
* *