* Mail: allow to define an existing folder as archive folder and allow to move messages to the specified folder with either right-click action or EGW-shortcut

This commit is contained in:
Klaus Leithoff 2016-04-29 11:23:05 +00:00
parent 248fde6fef
commit 8e02180904
11 changed files with 101 additions and 12 deletions

View File

@ -374,7 +374,7 @@ class admin_mail
//_debug_array($content); //_debug_array($content);
$sel_options['acc_folder_sent'] = $sel_options['acc_folder_trash'] = $sel_options['acc_folder_sent'] = $sel_options['acc_folder_trash'] =
$sel_options['acc_folder_draft'] = $sel_options['acc_folder_template'] = $sel_options['acc_folder_draft'] = $sel_options['acc_folder_template'] =
$sel_options['acc_folder_junk'] = self::mailboxes($imap, $content); $sel_options['acc_folder_junk'] = $sel_options['acc_folder_archive'] = self::mailboxes($imap, $content);
} }
catch(Exception $e) { catch(Exception $e) {
$content['msg'] = $e->getMessage(); $content['msg'] = $e->getMessage();
@ -419,6 +419,7 @@ class admin_mail
'acc_folder_draft' => array('\\drafts', 'drafts'), 'acc_folder_draft' => array('\\drafts', 'drafts'),
'acc_folder_template' => array('', 'templates'), 'acc_folder_template' => array('', 'templates'),
'acc_folder_junk' => array('\\junk', 'junk', 'spam'), 'acc_folder_junk' => array('\\junk', 'junk', 'spam'),
'acc_folder_archive' => array('', 'archive'),
) as $name => $common_names) ) as $name => $common_names)
{ {
// first check special-use attributes // first check special-use attributes

View File

@ -118,7 +118,7 @@
</rows> </rows>
</grid> </grid>
</template> </template>
<template id="admin.mailaccount.folder" template="" lang="" group="0" version="1.9.001"> <template id="admin.mailaccount.folder" template="" lang="" group="0" version="1.9.002">
<grid width="100%"> <grid width="100%">
<columns> <columns>
<column width="115"/> <column width="115"/>
@ -146,7 +146,11 @@
<taglist id="acc_folder_junk" empty_label="Select one ..." maxSelection="1" autocomplete_url=""/> <taglist id="acc_folder_junk" empty_label="Select one ..." maxSelection="1" autocomplete_url=""/>
</row> </row>
<row> <row>
<description for="acc_folder_junk" value="Notify about new mail in this folders"/> <description for="acc_folder_archive" value="Archive folder"/>
<taglist id="acc_folder_archive" empty_label="Select one ..." maxSelection="1" autocomplete_url=""/>
</row>
<row>
<description for="notify_folders" value="Notify about new mail in this folders"/>
<vbox> <vbox>
<taglist id="notify_folders" empty_label="Select one ..." autocomplete_url="" onchange="app.admin.change_folders"/> <taglist id="notify_folders" empty_label="Select one ..." autocomplete_url="" onchange="app.admin.change_folders"/>
<checkbox id="notify_save_default" label="save as default"/> <checkbox id="notify_save_default" label="save as default"/>

View File

@ -12,7 +12,7 @@
/* Basic information about this app */ /* Basic information about this app */
$setup_info['api']['name'] = 'api'; $setup_info['api']['name'] = 'api';
$setup_info['api']['title'] = 'EGroupware API'; $setup_info['api']['title'] = 'EGroupware API';
$setup_info['api']['version'] = '16.1'; $setup_info['api']['version'] = '16.1.001';
$setup_info['api']['versions']['current_header'] = '1.29'; $setup_info['api']['versions']['current_header'] = '1.29';
$setup_info['api']['enable'] = 3; $setup_info['api']['enable'] = 3;
$setup_info['api']['app_order'] = 1; $setup_info['api']['app_order'] = 1;

View File

@ -432,6 +432,7 @@ $phpgw_baseline = array(
'acc_folder_trash' => array('type' => 'varchar','precision' => '128','comment' => 'trash folder'), 'acc_folder_trash' => array('type' => 'varchar','precision' => '128','comment' => 'trash folder'),
'acc_folder_draft' => array('type' => 'varchar','precision' => '128','comment' => 'draft folder'), 'acc_folder_draft' => array('type' => 'varchar','precision' => '128','comment' => 'draft folder'),
'acc_folder_template' => array('type' => 'varchar','precision' => '128','comment' => 'template folder'), 'acc_folder_template' => array('type' => 'varchar','precision' => '128','comment' => 'template folder'),
'acc_folder_archive' => array('type' => 'varchar','precision' => '128','comment' => 'archive folder'),
'acc_smtp_host' => array('type' => 'varchar','precision' => '128','comment' => 'smtp hostname'), 'acc_smtp_host' => array('type' => 'varchar','precision' => '128','comment' => 'smtp hostname'),
'acc_smtp_ssl' => array('type' => 'int','precision' => '1','nullable' => False,'default' => '0','comment' => '0=none, 1=starttls, 2=tls, 3=ssl, &8=validate certificate'), 'acc_smtp_ssl' => array('type' => 'int','precision' => '1','nullable' => False,'default' => '0','comment' => '0=none, 1=starttls, 2=tls, 3=ssl, &8=validate certificate'),
'acc_smtp_port' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '25','comment' => 'smtp port'), 'acc_smtp_port' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '25','comment' => 'smtp port'),

View File

@ -49,4 +49,15 @@ function api_upgrade14_3_907()
} }
return $GLOBALS['setup_info']['api']['currentver'] = '16.1'; return $GLOBALS['setup_info']['api']['currentver'] = '16.1';
} }
function api_upgrade16_1()
{
$GLOBALS['egw_setup']->oProc->AddColumn('egw_ea_accounts','acc_folder_archive', array(
'type' => 'varchar',
'precision' => '128',
'comment' => 'archive folder'
));
return $GLOBALS['setup_info']['api']['currentver'] = '16.1.001';
}

View File

@ -1058,6 +1058,7 @@ class Mail
//if (!empty($this->icServer->acc_folder_template) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template])) //if (!empty($this->icServer->acc_folder_template) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]))
$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates'; $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates';
$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk]='Junk'; $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk]='Junk';
$_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive]='Archive';
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer));
self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId];
Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, 60*60*24*5); Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, 60*60*24*5);
@ -3303,6 +3304,7 @@ class Mail
'Sent' => array('profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'), 'Sent' => array('profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'),
'Junk' => array('profileKey'=>'acc_folder_junk','autoFolderName'=>'Junk'), 'Junk' => array('profileKey'=>'acc_folder_junk','autoFolderName'=>'Junk'),
'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'), 'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'),
'Archive' => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'),
); );
if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'!
$created = false; $created = false;
@ -3324,8 +3326,17 @@ class Mail
if ($_type != 'Outbox') error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage()); if ($_type != 'Outbox') error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage());
$_folderName = false; $_folderName = false;
} }
// do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist
if ($_type == 'Archive') {
if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) {
return false;
} else {
return $_folderName;
}
}
// does the folder exist??? (is configured/preset, but non-existent) // does the folder exist??? (is configured/preset, but non-existent)
if ($_folderName && $_checkexistance && $_folderName !='none' && !$this->folderExists($_folderName,true)) { if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) {
try try
{ {
$error = null; $error = null;
@ -3391,7 +3402,7 @@ class Mail
} }
/** /**
* getDraftFolder wrapper for _getSpecialUseFolder Type Drafts * getJunkFolder wrapper for _getSpecialUseFolder Type Junk
* @param boolean $_checkexistance trigger check for existance * @param boolean $_checkexistance trigger check for existance
* @return mixed string or false * @return mixed string or false
*/ */
@ -3450,6 +3461,16 @@ class Mail
return $this->_getSpecialUseFolder('Outbox', $_checkexistance); return $this->_getSpecialUseFolder('Outbox', $_checkexistance);
} }
/**
* getArchiveFolder wrapper for _getSpecialUseFolder Type Archive
* @param boolean $_checkexistance trigger check for existance . We do no autocreation for configured Archive folder
* @return mixed string or false
*/
function getArchiveFolder($_checkexistance=TRUE)
{
return $this->_getSpecialUseFolder('Archive', $_checkexistance);
}
/** /**
* isSentFolder is the given folder the sent folder or at least a subfolder of it * isSentFolder is the given folder the sent folder or at least a subfolder of it
* @param string $_folderName folder to perform the check on * @param string $_folderName folder to perform the check on

View File

@ -472,7 +472,8 @@ class mail_tree
// mark on account if Sieve is enabled // mark on account if Sieve is enabled
'data' => array( 'data' => array(
'sieve' => $accObj->imapServer()->acc_sieve_enabled, 'sieve' => $accObj->imapServer()->acc_sieve_enabled,
'spamfolder'=> $accObj->imapServer()->acc_folder_junk?true:false 'spamfolder'=> $accObj->imapServer()->acc_folder_junk&&(strtolower($accObj->imapServer()->acc_folder_junk)!='none')?true:false,
'archivefolder'=> $accObj->imapServer()->acc_folder_archive&&(strtolower($accObj->imapServer()->acc_folder_archive)!='none')?true:false
), ),
Tree::NOCHECKBOX => $_noCheckbox Tree::NOCHECKBOX => $_noCheckbox
); );

View File

@ -853,6 +853,8 @@ class mail_ui
// todo: real hierarchical folder list // todo: real hierarchical folder list
$lastFolderUsedForMove = null; $lastFolderUsedForMove = null;
$moveactions = array(); $moveactions = array();
$archiveFolder = $this->mail_bo->getArchiveFolder();
$currentArchiveActionKey = 'move_'.$this->mail_bo->profileID.self::$delimiter.$archiveFolder;
$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); $lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
//error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont)); //error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont));
//error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])); //error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]));
@ -884,7 +886,8 @@ class mail_ui
if ($_folder!=$i) if ($_folder!=$i)
{ {
$moveaction .= $lastFolderUsedForMoveCont; $moveaction .= $lastFolderUsedForMoveCont;
//error_log(__METHOD__.__LINE__.'#'.$moveaction);
//error_log(__METHOD__.__LINE__.'#'.$currentArchiveActionKey);
if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders
{ {
$fS['profileID'] = $this->mail_bo->profileID; $fS['profileID'] = $this->mail_bo->profileID;
@ -1008,13 +1011,31 @@ class mail_ui
array( array(
'caption' => lang('Move selected to'), 'caption' => lang('Move selected to'),
'icon' => 'move', 'icon' => 'move',
'group' => $group++, 'group' => $group,
'children' => $children, 'children' => $children,
) )
) )
); );
} else {
$group++;
} }
//error_log(__METHOD__.__LINE__.$archiveFolder);
$actions = array_merge($actions,
array(
'move2'.$this->mail_bo->profileID.self::$delimiter.$archiveFolder => array( //toarchive
'caption' => 'Move to archive',
'hint' => 'move selected mails to archive',
'icon' => 'move',
'group' => $group++,
'enabled' => 'javaScript:app.mail.archivefolder_enabled',
//'hideOnDisabled' => true, // does not work as expected on message-list
'onExecute' => 'javaScript:app.mail.mail_move2folder',
'shortcut' => egw_keymanager::shortcut(egw_keymanager::A, true, true),
'allowOnMultiple' => true,
'toolbarDefault' => false
)));
$actions = array_merge($actions, $actions = array_merge($actions,
array( array(
@ -4736,8 +4757,11 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
list($targetProfileID,$targetFolder) = explode(self::$delimiter,$_folderName,2); list($targetProfileID,$targetFolder) = explode(self::$delimiter,$_folderName,2);
$lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); $lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
$changeFolderActions = false; $changeFolderActions = false;
//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder");
//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder])) if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]))
{ {
//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]));
if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3) if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3)
{ {
$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]); $keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
@ -4748,6 +4772,7 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
} }
//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID])); //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
} }
//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName");
$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$_folderName; $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$_folderName;
$changeFolderActions = true; $changeFolderActions = true;
} }
@ -4896,6 +4921,7 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
} }
if ($changeFolderActions == true) if ($changeFolderActions == true)
{ {
//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
$actionsnew = self::get_actions(); $actionsnew = self::get_actions();
$actionsnew = etemplate_widget_nextmatch::egw_actions($actionsnew); $actionsnew = etemplate_widget_nextmatch::egw_actions($actionsnew);

View File

@ -1386,10 +1386,28 @@ app.classes.mail = AppJS.extend(
}, },
/**
* Check if archiveFolder is enabled on that account
*
* ArchiveFolder enabled is stored as data { archivefolder: true/false } on account node.
*
* @param {object} _action
* @param {object} _senders the representation of the tree leaf to be manipulated
* @param {object} _currentNode
*/
archivefolder_enabled: function(_action,_senders,_currentNode)
{
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
var acc_id = _senders[0].id.split('::')[2]; // this is operating on mails
var node = ftree ? ftree.getNode(acc_id) : null;
return node && node.data && node.data.archivefolder;
},
/** /**
* Check if Sieve is enabled on that account * Check if Sieve is enabled on that account
* *
* Sieve enabled is stored as data { acl: true/false } on account node. * Sieve enabled is stored as data { sieve: true/false } on account node.
* *
* @param {object} _action * @param {object} _action
* @param {object} _senders the representation of the tree leaf to be manipulated * @param {object} _senders the representation of the tree leaf to be manipulated

View File

@ -42,6 +42,7 @@ any status mail de Alle Status
append mail de hinzufügen append mail de hinzufügen
appended after reply before sending mail de Einfügen nach dem zitierten Text im Zuge des Versendens appended after reply before sending mail de Einfügen nach dem zitierten Text im Zuge des Versendens
application mail expected but got: %1 mail de Anwendung Mail erwarted, aber %1 erhalten! application mail expected but got: %1 mail de Anwendung Mail erwarted, aber %1 erhalten!
archive folder mail de Archivordner
are you sure you want to delete all selected folders? mail de Sollen alle selektierten Ordner gelöcht werden? are you sure you want to delete all selected folders? mail de Sollen alle selektierten Ordner gelöcht werden?
are you sure you want to move folder %1 to folder %2? mail de Soll der Ordner %1 in den Ordner %2 verschoben werden? are you sure you want to move folder %1 to folder %2? mail de Soll der Ordner %1 in den Ordner %2 verschoben werden?
arrival mail de Empfangsdatum arrival mail de Empfangsdatum
@ -290,7 +291,9 @@ message send failed: %1 mail de Nachricht konnte nicht versendet werden: %1
message send successfully. mail de Nachricht wurde erfolgreich versendet. message send successfully. mail de Nachricht wurde erfolgreich versendet.
miscellaneous mail de Verschiedenes miscellaneous mail de Verschiedenes
move folder mail de Ordner verschieben move folder mail de Ordner verschieben
move selected mails to archive mail de Verschiebe ausgewählte Nachrichten in den konfigurierten Archiv Ordner
move selected to mail de Verschiebe ausgewählte nach move selected to mail de Verschiebe ausgewählte nach
move to archive mail de Verschiebe in den Archivordner
move to mail de verschieben move to mail de verschieben
move to trash mail de in den Papierkorb verschieben move to trash mail de in den Papierkorb verschieben
moved %1 message(s) from %2 to %3 mail de %1 Nachrichten wurden von %2 nach %3 verschoben moved %1 message(s) from %2 to %3 mail de %1 Nachrichten wurden von %2 nach %3 verschoben

View File

@ -42,6 +42,7 @@ any status mail en any status
append mail en append append mail en append
appended after reply before sending mail en Appended after reply before sending appended after reply before sending mail en Appended after reply before sending
application mail expected but got: %1 mail en Application mail expected but got: %1 application mail expected but got: %1 mail en Application mail expected but got: %1
archive folder mail en Archive folder
are you sure you want to delete all selected folders? mail en Are you sure you want to delete all selected folders? are you sure you want to delete all selected folders? mail en Are you sure you want to delete all selected folders?
are you sure you want to move folder %1 to folder %2? mail en Are you sure you want to move folder %1 to folder %2? are you sure you want to move folder %1 to folder %2? mail en Are you sure you want to move folder %1 to folder %2?
arrival mail en Recieved arrival mail en Recieved
@ -290,7 +291,9 @@ message send failed: %1 mail en Message send failed: %1
message send successfully. mail en Message send successfully. message send successfully. mail en Message send successfully.
miscellaneous mail en Miscellaneous miscellaneous mail en Miscellaneous
move folder mail en Move Folder move folder mail en Move Folder
move selected mails to archive mail en Move selected mails to archive
move selected to mail en Move selected to move selected to mail en Move selected to
move to archive mail en Move to archive folder
move to mail en Move to move to mail en Move to
move to trash mail en move to trash move to trash mail en move to trash
moved %1 message(s) from %2 to %3 mail en moved %1 message(s) from %2 to %3 moved %1 message(s) from %2 to %3 mail en moved %1 message(s) from %2 to %3
@ -320,7 +323,7 @@ no valid %1 folder configured! mail en No valid %1 folder configured!
non mail en Non non mail en Non
none, create all mail en none, create all none, create all mail en none, create all
nothing to change. mail en Nothing to change. nothing to change. mail en Nothing to change.
notify about new mail in this folders mail en Notify about new mail in this folders notify about new mail in this folders mail en Notify about new mail in these folders
notify when new mails arrive in these folders mail en notify when new mails arrive in these folders notify when new mails arrive in these folders mail en notify when new mails arrive in these folders
on mail en on on mail en on
one address is not valid mail en One address is not valid one address is not valid mail en One address is not valid