From af6c57208a3177c80445d3a8e83854560327eb16 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Fri, 10 May 2013 07:24:27 +0000 Subject: [PATCH] fully implement rename folder action on tree popup menu action. Subfolders are now subscribed and Re-Ided --- mail/inc/class.mail_ui.inc.php | 61 ++++++++++++++++++++++++++++++++++ mail/js/app.js | 3 +- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 1aa711550e..8193cc1dca 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -2187,6 +2187,7 @@ blockquote[type=cite] { $del = $this->mail_bo->getHierarchyDelimiter(false); $oA = array(); list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); + $hasChildren = false; if (is_numeric($profileID)) { if ($profileID != $this->mail_bo->profileID) return; // only current connection @@ -2197,6 +2198,32 @@ blockquote[type=cite] { { //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false); + //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) + { + $hasChildren=true; // translates to: hasChildren -> dynamicLoading + $delimiter = $this->mail_bo->getHierarchyDelimiter(); + $nameSpace = $this->mail_bo->_getNameSpaces(); + $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); + //error_log(__METHOD__.__LINE__.'->'."$_folderName, $delimiter, $prefix"); + $fragments = array(); + $subFolders = $this->mail_bo->getMailBoxesRecursive($folderName, $delimiter, $prefix); + foreach ($subFolders as $k => $folder) + { + // we do not monitor failure or success on subfolders + if ($folder == $folderName) + { + unset($subFolders[$k]); + } + else + { + $rv = $this->mail_bo->subscribe($folder, false); + $fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName)); + } + } + //error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments)); + } + $this->mail_bo->reopen('INBOX'); if($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)) { $this->mail_bo->resetFolderObjectCache($profileID); @@ -2207,6 +2234,24 @@ blockquote[type=cite] { $this->mail_bo->reopen($newFolderName); $fS = $this->mail_bo->getFolderStatus($newFolderName,false); //error_log(__METHOD__.__LINE__.array2string($fS)); + if ($hasChildren) + { + $subFolders = $this->mail_bo->getMailBoxesRecursive($newFolderName, $delimiter, $prefix); + foreach ($subFolders as $k => $folder) + { + // we do not monitor failure or success on subfolders + if ($folder == $folderName) + { + unset($subFolders[$k]); + } + else + { + $rv = $this->mail_bo->subscribe($folder, true); + } + } + //error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($subFolders)); + } + $oA[$_folderName]['id'] = $profileID.self::$delimiter.$newFolderName; $oA[$_folderName]['olddesc'] = $oldFolderInfo['shortDisplayName']; if ($fS['unseen']) @@ -2218,6 +2263,22 @@ blockquote[type=cite] { { $oA[$_folderName]['desc'] = $fS['shortDisplayName']; } + foreach($fragments as $oldFolderName => $fragment) + { + //error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment); + $oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment; + $oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#'; + $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false); + if ($fS['unseen']) + { + $oA[$oldFolderName]['desc'] = ''.$fS['shortDisplayName'].' ('.$fS['unseen'].')'; + + } + else + { + $oA[$oldFolderName]['desc'] = $fS['shortDisplayName']; + } + } } } //error_log(__METHOD__.__LINE__.array2string($oA)); diff --git a/mail/js/app.js b/mail/js/app.js index bd9f0a4a98..b8eb23c1c0 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -188,7 +188,8 @@ app.mail = AppJS.extend( var selectedNode = ftree.getSelectedNode(); for (var i in _status) { - app.mail.app_refresh(egw.lang("Renamed Folder %1 to %2",_status[i]['olddesc'],_status[i]['desc'], 'mail')); + // if olddesc is undefined or #skip# then skip the message, as we process subfolders + if (typeof _status[i]['olddesc'] !== 'undefined' && _status[i]['olddesc'] !== '#skip-user-interaction-message#') app.mail.app_refresh(egw.lang("Renamed Folder %1 to %2",_status[i]['olddesc'],_status[i]['desc'], 'mail')); ftree.renameItem(i,_status[i]['id'],_status[i]['desc']); //alert(i +'->'+_status[i]['id']+'+'+_status[i]['desc']); if (_status[i]['id']==selectedNode.id)