fully implement rename folder action on tree popup menu action. Subfolders are now subscribed and Re-Ided

This commit is contained in:
Klaus Leithoff 2013-05-10 07:24:27 +00:00
parent 59b78094da
commit af6c57208a
2 changed files with 63 additions and 1 deletions

View File

@ -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'] = '<b>'.$fS['shortDisplayName'].' ('.$fS['unseen'].')</b>';
}
else
{
$oA[$oldFolderName]['desc'] = $fS['shortDisplayName'];
}
}
}
}
//error_log(__METHOD__.__LINE__.array2string($oA));

View File

@ -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)