* email: suppress empty user leaf on shared folders while in manage folders

This commit is contained in:
Klaus Leithoff 2012-06-28 13:21:37 +00:00
parent abd9edcba9
commit e61b2901c6

View File

@ -560,6 +560,7 @@ class felamimail_bo
*/
function createFolder($_parent, $_folderName, $_subscribe=false)
{
if (self::$debug) error_log(__METHOD__.__LINE__."->"."$_parent, $_folderName, $_subscribe");
$parent = $this->_encodeFolderName($_parent);
$folderName = $this->_encodeFolderName($_folderName);
@ -1615,6 +1616,7 @@ class felamimail_bo
if (is_null($_ImapServerId))
{
$folders2return = array();
$folderInfo = array();
}
else
{
@ -1623,8 +1625,14 @@ class felamimail_bo
{
unset($folders2return[$_ImapServerId]);
}
$folderInfo = egw_cache::getCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*5);
if (isset($folderInfo[$_ImapServerId]))
{
unset($folderInfo[$_ImapServerId]);
}
}
egw_cache::setCache(egw_cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return, $expiration=60*60*1);
egw_cache::setCache(egw_cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*5);
}
/**
@ -1739,6 +1747,7 @@ class felamimail_bo
if(!$_subscribedOnly) {
foreach ((array)$foldersNameSpace[$type]['subscribed'] as $folderName)
{
if ($foldersNameSpace[$type]['prefix'] == $folderName || $foldersNameSpace[$type]['prefix'] == $folderName.$foldersNameSpace[$type]['delimiter']) continue;
//echo __METHOD__."Checking $folderName for existence<br>";
if (!self::folderExists($folderName,true)) {
echo("eMail Folder $folderName failed to exist; should be unsubscribed; Trying ...");
@ -1772,16 +1781,23 @@ class felamimail_bo
#echo __METHOD__;_debug_array($allMailboxesExt);
continue;
}
$allMailBoxesExtSorted = array();
foreach ($allMailboxesExt as $mbx) {
//echo __METHOD__;_debug_array($mbx);
//error_log(__METHOD__.__LINE__.array2string($mbx));
if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])||
isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])||
(substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)]))
) continue;
//echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>";
$allMailBoxesExtSorted[$mbx['MAILBOX']] = $mbx;
}
if (is_array($allMailBoxesExtSorted)) ksort($allMailBoxesExtSorted);
//_debug_array($allMailBoxesExtSorted);
$allMailboxes = array();
foreach ((array)$allMailBoxesExtSorted as $mbx) {
#echo $mbx['MAILBOX']."<br>";
//echo $mbx['MAILBOX']."<br>";
if (in_array('\HasChildren',$mbx["ATTRIBUTES"]) || in_array('\Haschildren',$mbx["ATTRIBUTES"])) {
unset($buff);
//$buff = $this->icServer->getMailboxes($mbx['MAILBOX'].$delimiter,0,false);
@ -1895,7 +1911,7 @@ class felamimail_bo
}
}
}
#echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace);
//echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace);
$autoFolderObjects = array();
foreach( array('personal', 'others', 'shared') as $type) {
if(isset($foldersNameSpace[$type])) {
@ -1906,7 +1922,7 @@ class felamimail_bo
}
foreach((array)$listOfFolders as $folderName) {
//echo "<br>FolderToCheck:$folderName<br>";
if($_subscribedOnly && !in_array($folderName, $foldersNameSpace[$type]['all'])) {
if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) {
#echo "$folderName failed to be here <br>";
continue;
}