diff --git a/mail/inc/class.mail_bo.inc.php b/mail/inc/class.mail_bo.inc.php index 9c92b84651..2945e5a286 100644 --- a/mail/inc/class.mail_bo.inc.php +++ b/mail/inc/class.mail_bo.inc.php @@ -2008,24 +2008,40 @@ class mail_bo // fetch and sort all folders //echo $type.'->'.$foldersNameSpace[$type]['prefix'].'->'.($type=='shared'?0:2)."
"; - $allMailboxesExt = $this->icServer->getMailboxes($foldersNameSpace[$type]['prefix'],2,true); - if( PEAR::isError($allMailboxesExt) ) + try { - error_log(__METHOD__.__LINE__.' Failed to retrieve all Boxes:'.$allMailboxesExt->message); + $allMailboxesExt = $this->icServer->getMailboxes($foldersNameSpace[$type]['prefix'],2,true); + } + catch (Exception $e) + { + error_log(__METHOD__.__LINE__.' Failed to retrieve all Boxes:'.$e->getMessage()); $allMailboxesExt = array(); } if (empty($allMailboxesExt) && $type == 'shared') { - $allMailboxesExt = $this->icServer->getMailboxes('',0,true); + try + { + $allMailboxesExt = $this->icServer->getMailboxes('',0,true); + } + catch (Exception $e) + { + $allMailboxesExt = array(); + } } else { if ($prefix_present=='forced' && $type=='personal') // you cannot trust dovecots assumed prefix { - $allMailboxesExtAll = $this->icServer->getMailboxes('',0,true); + try + { + $allMailboxesExtAll = $this->icServer->getMailboxes('',0,true); + } + catch (Exception $e) + { + $allMailboxesExtAll=array(); + } foreach ($allMailboxesExtAll as $kaMEA => $aMEA) { - if( PEAR::isError($aMEA) ) continue; if (!in_array($aMEA,$allMailboxesExt)) $allMailboxesExt[] = $aMEA; } } @@ -2187,6 +2203,8 @@ class mail_bo #echo "$folderName failed to be here
"; continue; } + if (isset($folders[$folderName])) continue; + if (isset($autoFolderObjects[$folderName])) continue; $folderParts = explode($delimiter, $folderName); $shortName = array_pop($folderParts); @@ -2227,6 +2245,7 @@ class mail_bo } else { $folders[$folderName] = $folderObject; } + //error_log(__METHOD__.__LINE__.':'.$folderObject->folderName); } } } diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 2f4230baba..10b790cc61 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -3487,6 +3487,45 @@ blockquote[type=cite] { } } + /** + * reload node + * + * @param string _folderName folder to reload + * + * @return void + */ + function ajax_reloadNode($_folderName,$_subscribedOnly=true) + { + translation::add_app('mail'); + $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); + $del = $this->mail_bo->getHierarchyDelimiter(false); + $oA = array(); + list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); + if ($profileID != $this->mail_bo->profileID) return; // only current connection + $parentFolder=(!empty($folderName)?$folderName:'INBOX'); + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false); + if ($folderInfo['unseen']) + { + $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')'; + } + if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName']) + { + $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName']; + } + + $refreshData = array( + $profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']); + + // Send full info back in the response + $response = egw_json_response::get(); + foreach($refreshData as $folder => &$name) + { + $name = $this->getFolderTree(true, $folder, $_subscribedOnly); + } + $response->call('app.mail.mail_reloadNode',$refreshData); + + } + /** * move folder * diff --git a/mail/js/app.js b/mail/js/app.js index 86c2c35ddc..3835ed3fbc 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -2570,9 +2570,13 @@ app.classes.mail = AppJS.extend( */ all_folders: function(_action,_senders) { - var mailbox = _senders[0].id.split('::'); - acc_id = mailbox[0]; - egw.json('mail.mail_ui.ajax_foldertree',[acc_id,!_action.checked]) + //console.log(_action,_senders); + this.lock_tree(); + var mailbox = _senders[0].id.split('::'); + acc_id = mailbox[0]; + egw.json('mail.mail_ui.ajax_reloadNode',[acc_id,!_action.checked], jQuery.proxy(function() { + this.unlock_tree(); + },this)) .sendRequest(); },