forked from extern/egroupware
simple dialog for moveFolder action
This commit is contained in:
parent
72b01700e5
commit
1b873c4372
@ -341,6 +341,10 @@ class mail_ui
|
||||
'caption' => 'Rename Folder',
|
||||
'onExecute' => 'javaScript:app.mail.mail_RenameFolder'
|
||||
),
|
||||
'move' => array(
|
||||
'caption' => 'Move Folder',
|
||||
'onExecute' => 'javaScript:app.mail.mail_MoveFolder'
|
||||
),
|
||||
'delete' => array(
|
||||
'caption' => 'Delete Folder',
|
||||
'onExecute' => 'javaScript:app.mail.mail_DeleteFolder'
|
||||
@ -583,8 +587,9 @@ class mail_ui
|
||||
$fetchCounters = !is_null($_nodeID);
|
||||
list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
|
||||
if (!empty($_folderName)) $fetchCounters = true;
|
||||
error_log(__METHOD__.__LINE__.':'.$nodeID.'->'.array2string($fetchCounters));
|
||||
$data = $this->getFolderTree($fetchCounters, $nodeID, $subscribedOnly);
|
||||
//error_log(__METHOD__.__LINE__.':'.$nodeID.'->'.array2string($data));
|
||||
error_log(__METHOD__.__LINE__.':'.$nodeID.'->'.array2string($data));
|
||||
if (!is_null($_nodeID)) return $data;
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($data);
|
||||
@ -3279,6 +3284,83 @@ blockquote[type=cite] {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax_refreshNode - its called via json, so the function must start with ajax (or the class-name must contain ajax)
|
||||
* @param string $_folderName folder to refresh
|
||||
* @param string $_subscribedOnly wether to fetch subscribed or unsubscribed too
|
||||
* @return nothing
|
||||
*/
|
||||
function ajax_refreshNode($_folderName, $_subscribedOnly)
|
||||
{
|
||||
//lang("Rename Folder %1 to:",$OldFolderName);
|
||||
//lang("Rename Folder %1 ?",$OldFolderName);
|
||||
error_log(__METHOD__.__LINE__.' FolderName:'.array2string($_folderName).' subscribedOnly:'.array2string($_subscribedOnly));
|
||||
if ($_folderName)
|
||||
{
|
||||
$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
|
||||
$del = $this->mail_bo->getHierarchyDelimiter(false);
|
||||
$oA = array();
|
||||
list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
|
||||
$hasChildren = false;
|
||||
error_log(__METHOD__.__LINE__.' FolderName:'.array2string($folderName).' profile:'.array2string($profileID).'<->'.$this->mail_bo->profileID);
|
||||
if (is_numeric($profileID))
|
||||
{
|
||||
if ($profileID != $this->mail_bo->profileID) return; // only current connection
|
||||
$pA = explode($del,$folderName);
|
||||
array_pop($pA);
|
||||
$parentFolder = implode($del,$pA);
|
||||
$this->mail_bo->resetFolderObjectCache($profileID);
|
||||
//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
|
||||
$success=true;
|
||||
$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
|
||||
{
|
||||
$id=$profileID.self::$delimiter.$folder;
|
||||
$oA[$id]['id'] = $id;
|
||||
$fS = $this->mail_bo->getFolderStatus($folder,false);
|
||||
if ($fS['unseen'])
|
||||
{
|
||||
$oA[$id]['desc'] = '<b>'.$fS['shortDisplayName'].' ('.$fS['unseen'].')</b>';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$oA[$id]['desc'] = $fS['shortDisplayName'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($folderName==$this->mail_bo->sessionData['mailbox'])
|
||||
{
|
||||
$this->mail_bo->sessionData['mailbox']=$folderName;
|
||||
$this->mail_bo->saveSessionData();
|
||||
}
|
||||
error_log(__METHOD__.__LINE__.' '.$folderName.' status of method:'.$success.' ->'.array2string($oA));
|
||||
$response = egw_json_response::get();
|
||||
if ($oA && $success)
|
||||
{
|
||||
$response->call('app.mail.mail_setLeaf',$oA,'mail');
|
||||
}
|
||||
else
|
||||
{
|
||||
$response->call('egw_refresh',lang('failed to refresh %1 ! Reason: %2',$oldFolderName,$msg),'mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ajax_renameFolder - its called via json, so the function must start with ajax (or the class-name must contain ajax)
|
||||
* @param string $_folderName folder to rename and refresh
|
||||
@ -3407,9 +3489,9 @@ blockquote[type=cite] {
|
||||
$this->mail_bo->saveSessionData();
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.array2string($oA));
|
||||
$response = egw_json_response::get();
|
||||
if ($oA && $success)
|
||||
{
|
||||
$response = egw_json_response::get();
|
||||
$response->call('app.mail.mail_setLeaf',$oA,'mail');
|
||||
}
|
||||
else
|
||||
@ -3767,4 +3849,16 @@ blockquote[type=cite] {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* move folder
|
||||
*
|
||||
* @param array _folderName folder to vove
|
||||
* @param array _target target folder
|
||||
*
|
||||
* @return xajax response
|
||||
*/
|
||||
function ajax_MoveFolder($_folderName, $_target)
|
||||
{
|
||||
error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
|
||||
}
|
||||
}
|
||||
|
@ -1938,6 +1938,57 @@ app.classes.mail = AppJS.extend(
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* mail_MoveFolder - implementation of the MoveFolder action of right click options on the tree
|
||||
*
|
||||
* @param _action
|
||||
* @param _senders - the representation of the tree leaf to be manipulated
|
||||
*/
|
||||
mail_MoveFolder: function(action,_senders) {
|
||||
//console.log(action,_senders);
|
||||
//action.id == 'rename'
|
||||
//_senders.iface.id == target leaf / leaf to edit
|
||||
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
|
||||
OldFolderName = ftree.getLabel(_senders[0].iface.id);
|
||||
if (jQuery(OldFolderName).text().length>0) OldFolderName = jQuery(OldFolderName).text();
|
||||
OldFolderName = OldFolderName.trim();
|
||||
OldFolderName = OldFolderName.replace(/\([0-9]*\)/g,'').trim();
|
||||
//console.log(OldFolderName);
|
||||
var buttons = [
|
||||
{text: this.egw.lang("Move"), id: "move", class: "ui-priority-primary", "default": true},
|
||||
{text: this.egw.lang("Cancel"), id:"cancel"},
|
||||
];
|
||||
var dialog = et2_createWidget("dialog",{
|
||||
// If you use a template, the second parameter will be the value of the template, as if it were submitted.
|
||||
callback: function(_button_id, _value) {
|
||||
var senders = this.my_data.data;
|
||||
var NewFolderName = null;
|
||||
if (typeof _value.folder[0] != 'undefined' && _value.folder[0].length>0) NewFolderName = _value.folder[0];
|
||||
//alert(NewFolderName);
|
||||
if (NewFolderName && NewFolderName.length>0)
|
||||
{
|
||||
switch (_button_id)
|
||||
{
|
||||
case "move":
|
||||
egw.json('mail.mail_ui.ajax_MoveFolder',[senders[0].iface.id, NewFolderName])
|
||||
.sendRequest(true);
|
||||
return;
|
||||
case "cancel":
|
||||
}
|
||||
}
|
||||
},
|
||||
buttons: buttons,
|
||||
title: this.egw.lang("Move Folder %1 ?",OldFolderName),
|
||||
template:egw.webserverUrl+"/mail/templates/default/moveFolder.xet",
|
||||
value: { content: {selectedLeaf:OldFolderName}, sel_options: {}}
|
||||
});
|
||||
|
||||
// setting required data for callback in as my_data
|
||||
dialog.my_data = {
|
||||
data: _senders,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* mail_DeleteFolder - implementation of the DeleteFolder action of right click options on the tree
|
||||
*
|
||||
@ -2289,8 +2340,9 @@ app.classes.mail = AppJS.extend(
|
||||
* Show/Hide unsubscribed folders
|
||||
*
|
||||
* @param {action} _action selected action from tree context menu
|
||||
* @param {sender} _senders
|
||||
*/
|
||||
all_folders: function(_action)
|
||||
all_folders: function(_action,_senders)
|
||||
{
|
||||
var mailbox = _senders[0].id.split('::');
|
||||
acc_id = mailbox[0];
|
||||
@ -2301,8 +2353,8 @@ app.classes.mail = AppJS.extend(
|
||||
/**
|
||||
* Subscribe selected unsubscribed folder
|
||||
*
|
||||
* @param {sender} _senders
|
||||
* @param {action} _action
|
||||
* @param {sender} _senders
|
||||
*/
|
||||
subscribe_folder: function(_action,_senders)
|
||||
{
|
||||
@ -2315,8 +2367,8 @@ app.classes.mail = AppJS.extend(
|
||||
/**
|
||||
* Unsubscribe selected subscribed folder
|
||||
*
|
||||
* @param {sender} _senders
|
||||
* @param {action} _action
|
||||
* @param {sender} _senders
|
||||
*/
|
||||
unsubscribe_folder: function(_action,_senders)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user