implement getMailboxes and listSubscribedMailboxes, to get listview back on the road; attachment info still missing, and filters to be implemented

This commit is contained in:
Klaus Leithoff 2013-10-25 13:37:53 +00:00
parent c3d3ca9973
commit 628806c289

View File

@ -760,23 +760,24 @@ class mail_bo
$delimiter = $this->getHierarchyDelimiter(); $delimiter = $this->getHierarchyDelimiter();
// TODO: cache by $this->icServer->ImapServerId // TODO: cache by $this->icServer->ImapServerId
if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray();
//error_log(__METHOD__.__LINE__.array2string($nameSpace));
if (is_array($nameSpace)) { if (is_array($nameSpace)) {
foreach($nameSpace as $type => $singleNameSpace) { foreach($nameSpace as $type => $singleNameSpace) {
$prefix_present = false; $prefix_present = false;
if($type == 'personal' && ($singleNameSpace[2]['name'] == '#mh/' || count($nameSpace) == 1) && ($this->folderExists('Mail')||$this->folderExists('INBOX'))) if($type == 'personal' && ($singleNameSpace['name'] == '#mh/' || count($nameSpace) == 1) && ($this->folderExists('Mail')||$this->folderExists('INBOX')))
{ {
$foldersNameSpace[$type]['prefix_present'] = 'forced'; $foldersNameSpace[$type]['prefix_present'] = 'forced';
// uw-imap server with mailbox prefix or dovecot maybe // uw-imap server with mailbox prefix or dovecot maybe
$foldersNameSpace[$type]['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace[0]['name'])?$singleNameSpace[0]['name']:'')); $foldersNameSpace[$type]['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:''));
} }
elseif($type == 'personal' && ($singleNameSpace[2]['name'] == '#mh/' || count($nameSpace) == 1) && $this->folderExists('mail')) elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/' || count($nameSpace) == 1) && $this->folderExists('mail'))
{ {
$foldersNameSpace[$type]['prefix_present'] = 'forced'; $foldersNameSpace[$type]['prefix_present'] = 'forced';
// uw-imap server with mailbox prefix or dovecot maybe // uw-imap server with mailbox prefix or dovecot maybe
$foldersNameSpace[$type]['prefix'] = 'mail'; $foldersNameSpace[$type]['prefix'] = 'mail';
} else { } else {
$foldersNameSpace[$type]['prefix_present'] = true; $foldersNameSpace[$type]['prefix_present'] = true;
$foldersNameSpace[$type]['prefix'] = $singleNameSpace[0]['name']; $foldersNameSpace[$type]['prefix'] = $singleNameSpace['name'];
} }
$foldersNameSpace[$type]['delimiter'] = $delimiter; $foldersNameSpace[$type]['delimiter'] = $delimiter;
//echo "############## $type->".print_r($foldersNameSpace[$type],true)." ###################<br>"; //echo "############## $type->".print_r($foldersNameSpace[$type],true)." ###################<br>";
@ -956,8 +957,8 @@ class mail_bo
static $folderBasicInfo; static $folderBasicInfo;
if (is_null($folderBasicInfo)) if (is_null($folderBasicInfo))
{ {
// $folderBasicInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); $folderBasicInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
// $folderInfoCache = $folderBasicInfo[$this->profileID]; $folderInfoCache = $folderBasicInfo[$this->profileID];
} }
if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName]; if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName];
$retValue = array(); $retValue = array();
@ -971,27 +972,26 @@ class mail_bo
if (is_null($folderInfoCache) || !isset($folderInfoCache[$_folderName])) $folderInfoCache[$_folderName] = $this->icServer->getMailboxes('', $_folderName, true); if (is_null($folderInfoCache) || !isset($folderInfoCache[$_folderName])) $folderInfoCache[$_folderName] = $this->icServer->getMailboxes('', $_folderName, true);
$folderInfo = $folderInfoCache[$_folderName]; $folderInfo = $folderInfoCache[$_folderName];
//error_log(__METHOD__.__LINE__.array2string($folderInfo).'->'.function_backtrace()); //error_log(__METHOD__.__LINE__.array2string($folderInfo).'->'.function_backtrace());
if(($folderInfo instanceof PEAR_Error) || !is_array($folderInfo)) { if(($folderInfo instanceof PEAR_Error) || !is_array($folderInfo[0])) {
if (self::$debug||$folderInfo instanceof PEAR_Error) error_log(__METHOD__." returned Info for folder $_folderName:".print_r($folderInfo->message,true)); if (self::$debug||$folderInfo instanceof PEAR_Error) error_log(__METHOD__." returned Info for folder $_folderName:".print_r($folderInfo->message,true));
if ( ($folderInfo instanceof PEAR_Error) || PEAR::isError($r = $this->_getStatus($_folderName)) || $r == 0) return false; if ( ($folderInfo instanceof PEAR_Error) || PEAR::isError($r = $this->_getStatus($_folderName)) || $r == 0) return false;
if (!is_array($folderInfo)) if (!is_array($folderInfo[0]))
{ {
// no folder info, but there is a status returned for the folder: something is wrong, try to cope with it // no folder info, but there is a status returned for the folder: something is wrong, try to cope with it
$folderInfo = is_array($folderInfo)?$folderInfo:array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), $folderInfo[0] = is_array($folderInfo)?$folderInfo:array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(),
'ATTRIBUTES' => ''); 'ATTRIBUTES' => '');
if (empty($folderInfo['HIERACHY_DELIMITER']) || (isset($folderInfo['delimiter']) && empty($folderInfo['delimiter']))) if (empty($folderInfo[0]['HIERACHY_DELIMITER']) || (isset($folderInfo[0]['delimiter']) && empty($folderInfo[0]['delimiter'])))
{ {
//error_log(__METHOD__.__LINE__.array2string($folderInfo)); //error_log(__METHOD__.__LINE__.array2string($folderInfo));
$folderInfo['HIERACHY_DELIMITER'] = $this->getHierarchyDelimiter(); $folderInfo[0]['HIERACHY_DELIMITER'] = $this->getHierarchyDelimiter();
} }
} }
} }
#if(!is_array($folderInfo[0])) { #if(!is_array($folderInfo[0])) {
# return false; # return false;
#} #}
error_log(__METHOD__.__LINE__.$folderInfo); $retValue['delimiter'] = ($folderInfo[0]['HIERACHY_DELIMITER']?$folderInfo[0]['HIERACHY_DELIMITER']:$folderInfo[0]['delimiter']);
$retValue['delimiter'] = ($folderInfo['HIERACHY_DELIMITER']?$folderInfo['HIERACHY_DELIMITER']:$folderInfo['delimiter']); $retValue['attributes'] = ($folderInfo[0]['ATTRIBUTES']?$folderInfo[0]['ATTRIBUTES']:$folderInfo[0]['attributes']);
$retValue['attributes'] = ($folderInfo['ATTRIBUTES']?$folderInfo['ATTRIBUTES']:$folderInfo['attributes']);
$shortNameParts = explode($retValue['delimiter'], $_folderName); $shortNameParts = explode($retValue['delimiter'], $_folderName);
$retValue['shortName'] = array_pop($shortNameParts); $retValue['shortName'] = array_pop($shortNameParts);
$retValue['displayName'] = $this->encodeFolderName($_folderName); $retValue['displayName'] = $this->encodeFolderName($_folderName);
@ -1856,7 +1856,7 @@ error_log(__METHOD__.__LINE__.$folderInfo);
if ($_useCacheIfPossible && 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'); //error_log(__METHOD__.__LINE__.' using Cached folderObjects');
return $folders2return[$this->icServer->ImapServerId]; //return $folders2return[$this->icServer->ImapServerId];
} }
} }
$isUWIMAP = false; $isUWIMAP = false;
@ -1913,7 +1913,7 @@ error_log(__METHOD__.__LINE__.$folderInfo);
continue; continue;
} }
$foldersNameSpace[$type]['subscribed'] = $subscribedMailboxes; $foldersNameSpace[$type]['subscribed'] = $subscribedMailboxes;
if (is_array($foldersNameSpace[$type]['subscribed'])) sort($foldersNameSpace[$type]['subscribed']); //if (is_array($foldersNameSpace[$type]['subscribed'])) sort($foldersNameSpace[$type]['subscribed']);
//_debug_array($foldersNameSpace); //_debug_array($foldersNameSpace);
if ($_subscribedOnly == true) { if ($_subscribedOnly == true) {
$foldersNameSpace[$type]['all'] = (is_array($foldersNameSpace[$type]['subscribed']) ? $foldersNameSpace[$type]['subscribed'] :array()); $foldersNameSpace[$type]['all'] = (is_array($foldersNameSpace[$type]['subscribed']) ? $foldersNameSpace[$type]['subscribed'] :array());