forked from extern/egroupware
use icServer folder infos for specialuse folder and trash/sent/draft/template folder retrieval (if no valid pref is set)
This commit is contained in:
parent
b20bd49817
commit
cce5514771
@ -168,6 +168,7 @@ class mail_bo
|
|||||||
*/
|
*/
|
||||||
public static function getInstance($_restoreSession=true, $_profileID=0, $_validate=true)
|
public static function getInstance($_restoreSession=true, $_profileID=0, $_validate=true)
|
||||||
{
|
{
|
||||||
|
$_restoreSession=false;
|
||||||
//error_log(__METHOD__.__LINE__.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace());
|
//error_log(__METHOD__.__LINE__.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace());
|
||||||
if ($_profileID == 0)
|
if ($_profileID == 0)
|
||||||
{
|
{
|
||||||
@ -740,10 +741,10 @@ class mail_bo
|
|||||||
{
|
{
|
||||||
//error_log(__METHOD__.__LINE__.array2string($specialUseFolders[$this->icServer->ImapServerId]));
|
//error_log(__METHOD__.__LINE__.array2string($specialUseFolders[$this->icServer->ImapServerId]));
|
||||||
// array('Drafts', 'Templates', 'Sent', 'Trash', 'Junk', 'Outbox');
|
// array('Drafts', 'Templates', 'Sent', 'Trash', 'Junk', 'Outbox');
|
||||||
if (empty($this->icServer->trashfolder) && ($f = array_search('Trash',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->trashfolder = $f;
|
if (empty($this->icServer->acc_folder_trash) && ($f = array_search('Trash',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_trash = $f;
|
||||||
if (empty($this->icServer->draftfolder) && ($f = array_search('Drafts',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->draftfolder = $f;
|
if (empty($this->icServer->acc_folder_draft) && ($f = array_search('Drafts',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_draft = $f;
|
||||||
if (empty($this->icServer->sentfolder) && ($f = array_search('Sent',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->sentfolder = $f;
|
if (empty($this->icServer->acc_folder_sent) && ($f = array_search('Sent',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_sent = $f;
|
||||||
if (empty($this->icServer->templatefolder) && ($f = array_search('Templates',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->templatefolder = $f;
|
if (empty($this->icServer->acc_folder_template) && ($f = array_search('Templates',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_template = $f;
|
||||||
}
|
}
|
||||||
//error_log(__METHOD__.__LINE__.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
|
//error_log(__METHOD__.__LINE__.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
|
||||||
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; // make sure this one is set on function call
|
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; // make sure this one is set on function call
|
||||||
@ -777,10 +778,10 @@ class mail_bo
|
|||||||
egw_cache::setCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, $expiration=60*60*24*5);
|
egw_cache::setCache(egw_cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, $expiration=60*60*24*5);
|
||||||
}
|
}
|
||||||
//error_log(__METHOD__.__LINE__.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
|
//error_log(__METHOD__.__LINE__.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
|
||||||
if (empty($this->icServer->trashfolder) && ($f = array_search('Trash',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->trashfolder = $f;
|
if (empty($this->icServer->acc_folder_trash) && ($f = array_search('Trash',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_trash = $f;
|
||||||
if (empty($this->icServer->draftfolder) && ($f = array_search('Drafts',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->draftfolder = $f;
|
if (empty($this->icServer->acc_folder_draft) && ($f = array_search('Drafts',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_draft = $f;
|
||||||
if (empty($this->icServer->sentfolder) && ($f = array_search('Sent',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->sentfolder = $f;
|
if (empty($this->icServer->acc_folder_sent) && ($f = array_search('Sent',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_sent = $f;
|
||||||
if (empty($this->icServer->templatefolder) && ($f = array_search('Templates',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->templatefolder = $f;
|
if (empty($this->icServer->acc_folder_template) && ($f = array_search('Templates',(array)$_specialUseFolders[$this->icServer->ImapServerId]))) $this->icServer->acc_folder_template = $f;
|
||||||
}
|
}
|
||||||
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; // make sure this one is set on function call
|
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; // make sure this one is set on function call
|
||||||
//error_log(__METHOD__.__LINE__.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
|
//error_log(__METHOD__.__LINE__.array2string($_specialUseFolders[$this->icServer->ImapServerId]));
|
||||||
@ -924,14 +925,14 @@ class mail_bo
|
|||||||
$retValue['uidvalidity'] = $folderStatus['UIDVALIDITY'];
|
$retValue['uidvalidity'] = $folderStatus['UIDVALIDITY'];
|
||||||
$retValue['unseen'] = $folderStatus['UNSEEN'];
|
$retValue['unseen'] = $folderStatus['UNSEEN'];
|
||||||
if (//$retValue['unseen']==0 &&
|
if (//$retValue['unseen']==0 &&
|
||||||
(isset($this->mailPreferences->preferences['trustServersUnseenInfo']) && // some servers dont serve the UNSEEN information
|
(isset($this->mailPreferences['trustServersUnseenInfo']) && // some servers dont serve the UNSEEN information
|
||||||
$this->mailPreferences->preferences['trustServersUnseenInfo']==false) ||
|
$this->mailPreferences['trustServersUnseenInfo']==false) ||
|
||||||
(isset($this->mailPreferences->preferences['trustServersUnseenInfo']) &&
|
(isset($this->mailPreferences['trustServersUnseenInfo']) &&
|
||||||
$this->mailPreferences->preferences['trustServersUnseenInfo']==2 &&
|
$this->mailPreferences['trustServersUnseenInfo']==2 &&
|
||||||
$prefix != '' && stripos($_folderName,$prefix) !== false)
|
$prefix != '' && stripos($_folderName,$prefix) !== false)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences->preferences['trustServersUnseenInfo']);
|
//error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']);
|
||||||
// we filter for the combined status of unseen and undeleted, as this is what we show in list
|
// we filter for the combined status of unseen and undeleted, as this is what we show in list
|
||||||
$sortResult = $this->getSortedList($_folderName, $_sort=0, $_reverse=1, $_filter=array('status'=>array('UNSEEN','UNDELETED')),$byUid=true,false);
|
$sortResult = $this->getSortedList($_folderName, $_sort=0, $_reverse=1, $_filter=array('status'=>array('UNSEEN','UNDELETED')),$byUid=true,false);
|
||||||
$retValue['unseen'] = $sortResult['count'];
|
$retValue['unseen'] = $sortResult['count'];
|
||||||
@ -1772,8 +1773,8 @@ class mail_bo
|
|||||||
}
|
}
|
||||||
// force unsubscribed by preference showAllFoldersInFolderPane
|
// force unsubscribed by preference showAllFoldersInFolderPane
|
||||||
if ($_subscribedOnly == true &&
|
if ($_subscribedOnly == true &&
|
||||||
isset($this->mailPreferences->preferences['showAllFoldersInFolderPane']) &&
|
isset($this->mailPreferences['showAllFoldersInFolderPane']) &&
|
||||||
$this->mailPreferences->preferences['showAllFoldersInFolderPane']==1)
|
$this->mailPreferences['showAllFoldersInFolderPane']==1)
|
||||||
{
|
{
|
||||||
$_subscribedOnly = false;
|
$_subscribedOnly = false;
|
||||||
}
|
}
|
||||||
@ -1916,14 +1917,14 @@ class mail_bo
|
|||||||
$folderPrefixAsInbox = 'INBOX';
|
$folderPrefixAsInbox = 'INBOX';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$_alwaysGetDefaultFolders && $this->mailPreferences->preferences['notavailableautofolders'] && !empty($this->mailPreferences->preferences['notavailableautofolders']))
|
if (!$_alwaysGetDefaultFolders && $this->mailPreferences['notavailableautofolders'] && !empty($this->mailPreferences['notavailableautofolders']))
|
||||||
{
|
{
|
||||||
$foldersToCheck = array_diff(self::$autoFolders,explode(',',$this->mailPreferences->preferences['notavailableautofolders']));
|
$foldersToCheck = array_diff(self::$autoFolders,explode(',',$this->mailPreferences['notavailableautofolders']));
|
||||||
} else {
|
} else {
|
||||||
$foldersToCheck = self::$autoFolders;
|
$foldersToCheck = self::$autoFolders;
|
||||||
}
|
}
|
||||||
//error_log(__METHOD__.__LINE__." foldersToCheck:".array2string($foldersToCheck));
|
//error_log(__METHOD__.__LINE__." foldersToCheck:".array2string($foldersToCheck));
|
||||||
//error_log(__METHOD__.__LINE__." foldersToCheck:".array2string( $this->mailPreferences->preferences['sentFolder']));
|
//error_log(__METHOD__.__LINE__." foldersToCheck:".array2string( $this->mailPreferences['sentFolder']));
|
||||||
foreach($foldersToCheck as $personalFolderName) {
|
foreach($foldersToCheck as $personalFolderName) {
|
||||||
$folderName = (!empty($personalPrefix) ? $folderPrefix.$personalFolderName : $personalFolderName);
|
$folderName = (!empty($personalPrefix) ? $folderPrefix.$personalFolderName : $personalFolderName);
|
||||||
//error_log(__METHOD__.__LINE__." foldersToCheck: $personalFolderName / $folderName");
|
//error_log(__METHOD__.__LINE__." foldersToCheck: $personalFolderName / $folderName");
|
||||||
@ -1937,7 +1938,7 @@ class mail_bo
|
|||||||
$createfolder=false;
|
$createfolder=false;
|
||||||
break;
|
break;
|
||||||
case 'Junk': //] => Spammails
|
case 'Junk': //] => Spammails
|
||||||
if ($this->mailPreferences->preferences['junkFolder'] && $this->mailPreferences->preferences['junkFolder']=='none')
|
if ($this->mailPreferences['junkFolder'] && $this->mailPreferences['junkFolder']=='none')
|
||||||
$createfolder=false;
|
$createfolder=false;
|
||||||
break;
|
break;
|
||||||
case 'Sent': //] => Gesendet
|
case 'Sent': //] => Gesendet
|
||||||
@ -1957,7 +1958,7 @@ class mail_bo
|
|||||||
$createfolder=false;
|
$createfolder=false;
|
||||||
break;
|
break;
|
||||||
case 'Outbox': // Nokia Outbox for activesync
|
case 'Outbox': // Nokia Outbox for activesync
|
||||||
//if ($this->mailPreferences->preferences['outboxFolder'] && $this->mailPreferences->preferences['outboxFolder']=='none')
|
//if ($this->mailPreferences['outboxFolder'] && $this->mailPreferences['outboxFolder']=='none')
|
||||||
$createfolder=false;
|
$createfolder=false;
|
||||||
if ($GLOBALS['egw_info']['user']['apps']['activesync']) $createfolder = true;
|
if ($GLOBALS['egw_info']['user']['apps']['activesync']) $createfolder = true;
|
||||||
break;
|
break;
|
||||||
@ -2202,10 +2203,10 @@ class mail_bo
|
|||||||
function _getSpecialUseFolder($_type, $_checkexistance=TRUE)
|
function _getSpecialUseFolder($_type, $_checkexistance=TRUE)
|
||||||
{
|
{
|
||||||
static $types = array(
|
static $types = array(
|
||||||
'Drafts'=>array('prefName'=>'draftFolder','profileKey'=>'draftfolder','autoFolderName'=>'Drafts'),
|
'Drafts'=>array('prefName'=>'draftFolder','profileKey'=>'draftfolder','acc_folder_draft'=>'Drafts'),
|
||||||
'Template'=>array('prefName'=>'templateFolder','profileKey'=>'templatefolder','autoFolderName'=>'Templates'),
|
'Template'=>array('prefName'=>'templateFolder','profileKey'=>'acc_folder_template','autoFolderName'=>'Templates'),
|
||||||
'Trash'=>array('prefName'=>'trashFolder','profileKey'=>'trashfolder','autoFolderName'=>'Trash'),
|
'Trash'=>array('prefName'=>'trashFolder','profileKey'=>'acc_folder_trash','autoFolderName'=>'Trash'),
|
||||||
'Sent'=>array('prefName'=>'sentFolder','profileKey'=>'sentfolder','autoFolderName'=>'Sent'),
|
'Sent'=>array('prefName'=>'sentFolder','profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'),
|
||||||
);
|
);
|
||||||
if (!isset($types[$_type]))
|
if (!isset($types[$_type]))
|
||||||
{
|
{
|
||||||
@ -2215,9 +2216,9 @@ class mail_bo
|
|||||||
if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders();
|
if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders();
|
||||||
|
|
||||||
//highest precedence
|
//highest precedence
|
||||||
$_folderName = $this->mailPreferences->ic_server[$this->profileID]->$types[$_type]['profileKey'];
|
$_folderName = $this->ic_server->$types[$_type]['profileKey'];
|
||||||
//check prefs next
|
//check prefs next
|
||||||
if (empty($_folderName)) $_folderName = $this->mailPreferences->preferences[$types[$_type]['prefName']];
|
if (empty($_folderName)) $_folderName = $this->mailPreferences[$types[$_type]['prefName']];
|
||||||
// does the folder exist???
|
// does the folder exist???
|
||||||
if ($_checkexistance && $_folderName !='none' && !self::folderExists($_folderName)) {
|
if ($_checkexistance && $_folderName !='none' && !self::folderExists($_folderName)) {
|
||||||
$_folderName = false;
|
$_folderName = false;
|
||||||
@ -2437,10 +2438,10 @@ class mail_bo
|
|||||||
{
|
{
|
||||||
// some servers dont serve the LIST command in certain cases; this is a ServerBUG and
|
// some servers dont serve the LIST command in certain cases; this is a ServerBUG and
|
||||||
// we try to work around it here.
|
// we try to work around it here.
|
||||||
if ((isset($this->mailPreferences->preferences['trustServersUnseenInfo']) &&
|
if ((isset($this->mailPreferences['trustServersUnseenInfo']) &&
|
||||||
$this->mailPreferences->preferences['trustServersUnseenInfo']==false) ||
|
$this->mailPreferences['trustServersUnseenInfo']==false) ||
|
||||||
(isset($this->mailPreferences->preferences['trustServersUnseenInfo']) &&
|
(isset($this->mailPreferences['trustServersUnseenInfo']) &&
|
||||||
$this->mailPreferences->preferences['trustServersUnseenInfo']==2)
|
$this->mailPreferences['trustServersUnseenInfo']==2)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$nameSpace = $this->_getNameSpaces();
|
$nameSpace = $this->_getNameSpaces();
|
||||||
@ -2481,7 +2482,7 @@ class mail_bo
|
|||||||
$this->icServer->openMailbox($folderName);
|
$this->icServer->openMailbox($folderName);
|
||||||
|
|
||||||
if($folderName == $trashFolder && $deleteOptions == "move_to_trash") {
|
if($folderName == $trashFolder && $deleteOptions == "move_to_trash") {
|
||||||
$this->icServer->deleteMessages('1:*');
|
$this->deleteMessages('all');
|
||||||
$this->icServer->expunge();
|
$this->icServer->expunge();
|
||||||
} else {
|
} else {
|
||||||
$this->icServer->expunge();
|
$this->icServer->expunge();
|
||||||
@ -2515,8 +2516,13 @@ class mail_bo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$uidsToDelete = new Horde_Imap_Client_Ids();
|
||||||
|
$uidsToDelete->add($_messageUID);
|
||||||
|
}
|
||||||
$deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method
|
$deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method
|
||||||
if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions = ($this->mailPreferences->preferences['deleteOptions']?$this->mailPreferences->preferences['deleteOptions']:"mark_as_deleted");
|
if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted");
|
||||||
//error_log(__METHOD__.__LINE__.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
|
//error_log(__METHOD__.__LINE__.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions);
|
||||||
$trashFolder = $this->getTrashFolder();
|
$trashFolder = $this->getTrashFolder();
|
||||||
$draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder'];
|
$draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder'];
|
||||||
@ -2538,7 +2544,7 @@ class mail_bo
|
|||||||
if (self::$debug) error_log(__METHOD__.__LINE__.implode(' : ', $_messageUID));
|
if (self::$debug) error_log(__METHOD__.__LINE__.implode(' : ', $_messageUID));
|
||||||
if (self::$debug) error_log(__METHOD__.__LINE__."$trashFolder <= $_folder / ". $this->sessionData['mailbox']);
|
if (self::$debug) error_log(__METHOD__.__LINE__."$trashFolder <= $_folder / ". $this->sessionData['mailbox']);
|
||||||
// copy messages
|
// copy messages
|
||||||
//$retValue = $this->icServer->copy($_folder, $trashFolder, array('ids'=>$_messageUID,'move'=>true));
|
$retValue = $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete,'move'=>true));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2558,11 +2564,6 @@ class mail_bo
|
|||||||
{
|
{
|
||||||
$this->flagMessages('undelete', $uid, $_folder);
|
$this->flagMessages('undelete', $uid, $_folder);
|
||||||
}
|
}
|
||||||
if ( PEAR::isError($retValue)) {
|
|
||||||
if (self::$debug) error_log(__METHOD__." failed to mark as deleted for Message(s) from $_folder: ".implode(',',$_messageUID));
|
|
||||||
throw new egw_exception("failed to mark as deleted for Message(s) from $_folder: ".implode(',',$_messageUID).' due to:'.array2string($retValue->message));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "remove_immediately":
|
case "remove_immediately":
|
||||||
@ -2572,11 +2573,6 @@ class mail_bo
|
|||||||
//flag messages, that are flagged for deletion as seen too
|
//flag messages, that are flagged for deletion as seen too
|
||||||
$this->flagMessages('delete', $uid, $_folder);
|
$this->flagMessages('delete', $uid, $_folder);
|
||||||
}
|
}
|
||||||
if ( PEAR::isError($retValue)) {
|
|
||||||
if (self::$debug) error_log(__METHOD__." failed to remove immediately Message(s) from $_folder: ".implode(',',$_messageUID));
|
|
||||||
throw new egw_exception("failed to remove immediately Message(s) from $_folder: ".implode(',',$_messageUID).' due to:'.array2string($retValue->message));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// delete the messages finaly
|
// delete the messages finaly
|
||||||
$this->icServer->expunge();
|
$this->icServer->expunge();
|
||||||
break;
|
break;
|
||||||
|
@ -129,6 +129,7 @@ class mail_ui
|
|||||||
//openConnection gathers SpecialUseFolderInformation and Delimiter Info
|
//openConnection gathers SpecialUseFolderInformation and Delimiter Info
|
||||||
$this->mail_bo->openConnection(self::$icServerID);
|
$this->mail_bo->openConnection(self::$icServerID);
|
||||||
$GLOBALS['egw']->session->commit_session();
|
$GLOBALS['egw']->session->commit_session();
|
||||||
|
//_debug_array($this->mail_bo->mailPreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1013,7 +1014,7 @@ class mail_ui
|
|||||||
),
|
),
|
||||||
'delete' => array(
|
'delete' => array(
|
||||||
'caption' => 'Delete',
|
'caption' => 'Delete',
|
||||||
'hint' => $deleteOptions[$this->mail_bo->mailPreferences->preferences['deleteOptions']],
|
'hint' => $deleteOptions[$this->mail_bo->mailPreferences['deleteOptions']],
|
||||||
'group' => ++$group,
|
'group' => ++$group,
|
||||||
'onExecute' => 'javaScript:app.mail.mail_delete',
|
'onExecute' => 'javaScript:app.mail.mail_delete',
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user