Separate action to mark all messages in a folder as \Seen (#5006)

with possibility to do this in all folders or in a folder and its subfolders (#5076)
pull/5468/head
Aleksander Machniak 8 years ago
parent 4936159f31
commit d305f4f0fd

@ -1,6 +1,8 @@
CHANGELOG Roundcube Webmail
===========================
- Implement separate action to mark all messages in a folder as \Seen (#5006)
- Implement marking as \Seen in all folders or in a folder and its subfolders (#5076)
- Archive: Don't reload messages list when it's not needed (#5225)
- Archive: Add option to automatically mark archived messages as \Seen (#5142)
- Improve randomness of password salts and random hashes (#5266)

@ -617,7 +617,10 @@ function rcube_webmail()
.addEventListener('collapse', function(node) { ref.folder_collapsed(node) })
.addEventListener('expand', function(node) { ref.folder_collapsed(node) })
.addEventListener('beforeselect', function(node) { return !ref.busy; })
.addEventListener('select', function(node) { ref.triggerEvent('selectfolder', { folder:node.id, prefix:'rcmli' }) });
.addEventListener('select', function(node) {
ref.triggerEvent('selectfolder', { folder:node.id, prefix:'rcmli' });
ref.mark_all_read_state();
});
}
// activate html5 file drop feature (if browser supports it and if configured)
@ -3938,7 +3941,7 @@ function rcube_webmail()
if (mbox == this.env.mailbox) {
lock = this.set_busy(true, 'loading');
post_data._reload = 1;
}
}
// send request to server
this.http_post('purge', post_data, lock);
@ -3955,6 +3958,98 @@ function rcube_webmail()
));
};
// Mark all messages as read in:
// - selected folder (mode=cur)
// - selected folder and its subfolders (mode=sub)
// - all folders (mode=all)
this.mark_all_read = function(mbox, mode)
{
var state, content, nodes = [],
list = this.message_list,
folder = mbox || this.env.mailbox,
post_data = {_uid: '*', _flag: 'read', _mbox: folder, _folders: mode};
if (typeof mode != 'string') {
state = this.mark_all_read_state(folder);
if (!state)
return;
if (state > 1) {
// build content of the dialog
$.each({cur: 1, sub: 2, all: 4}, function(i, v) {
var label = $('<label>').attr('style', 'display:block; line-height:22px'),
text = $('<span>').text(ref.get_label('folders-' + i)),
input = $('<input>').attr({type: 'radio', value: i, name: 'mode'});
if (!(state & v)) {
label.attr('class', 'disabled');
input.attr('disabled', true);
}
nodes.push(label.append(input).append(text));
});
content = $('<div>').append(nodes);
$('input:not([disabled]):first', content).attr('checked', true);
this.show_popup_dialog(content, this.get_label('markallread'),
[{
'class': 'mainaction',
text: this.get_label('mark'),
click: function() {
ref.mark_all_read(folder, $('input:checked', this).val());
$(this).dialog('close');
}
},
{
text: this.get_label('cancel'),
click: function() {
$(this).dialog('close');
}
}]
);
return;
}
post_data._folders = 'cur'; // only current folder has unread messages
}
// mark messages on the list
$.each(list ? list.rows : [], function(uid, row) {
if (!row.unread)
return;
var mbox = ref.env.messages[uid].mbox;
if (mode == 'all' || mbox == ref.env.mailbox
|| (mode == 'sub' && mbox.startsWith(ref.env.mailbox + ref.env.delimiter))
) {
ref.set_message(uid, 'unread', false);
}
});
// send the request
this.http_post('mark', post_data, this.display_message(this.get_label('markingmessage'), 'loading'));
};
// Enable/disable mark-all-read action depending on folders state
this.mark_all_read_state = function(mbox)
{
var state = 0,
li = this.treelist.get_item(mbox || this.env.mailbox),
folder_item = $(li).is('.unread') ? 1 : 0,
subfolder_items = $('li.unread', li).length,
all_items = $('li.unread', ref.gui_objects.folderlist).length;
state += folder_item;
state += subfolder_items ? 2 : 0;
state += all_items > folder_item + subfolder_items ? 4 : 0;
this.enable_command('mark-all-read', state > 0);
return state;
};
/*********************************************************/
/********* login form methods *********/
@ -7584,6 +7679,8 @@ function rcube_webmail()
this.mark_folder(mbox, mark, '', true);
else if (!count)
this.unmark_folder(mbox, 'recent', '', true);
this.mark_all_read_state();
};
// update the mailbox count display

@ -153,6 +153,10 @@ $labels['markunread'] = 'As unread';
$labels['markflagged'] = 'As flagged';
$labels['markunflagged'] = 'As unflagged';
$labels['moreactions'] = 'More actions...';
$labels['markallread'] = 'Mark all as read';
$labels['folders-cur'] = 'Selected folder only';
$labels['folders-sub'] = 'Selected folder and its subfolders';
$labels['folders-all'] = 'All folders';
$labels['more'] = 'More';
$labels['back'] = 'Back';
$labels['options'] = 'Options';

@ -109,7 +109,8 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
'movingmessage', 'copyingmessage', 'deletingmessage', 'markingmessage',
'copy', 'move', 'quota', 'replyall', 'replylist', 'stillsearching',
'flagged', 'unflagged', 'unread', 'deleted', 'replied', 'forwarded',
'priority', 'withattachment', 'fileuploaderror');
'priority', 'withattachment', 'fileuploaderror', 'mark', 'markallread',
'folders-cur', 'folders-sub', 'folders-all', 'cancel');
}
}

@ -37,9 +37,12 @@ $a_flags_map = array(
'unflagged' => 'UNFLAGGED',
);
if (($_uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST))
&& ($flag = rcube_utils::get_input_value('_flag', rcube_utils::INPUT_POST))
) {
$_uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST);
$flag = rcube_utils::get_input_value('_flag', rcube_utils::INPUT_POST);
$folders = rcube_utils::get_input_value('_folders', rcube_utils::INPUT_POST);
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
if ($_uids && $flag) {
$flag = $a_flags_map[$flag] ?: strtoupper($flag);
if ($flag == 'DELETED' && $skip_deleted && $_POST['_from'] != 'show') {
@ -48,7 +51,24 @@ if (($_uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST))
$old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
}
foreach (rcmail::get_uids() as $mbox => $uids) {
if ($folders == 'all') {
$mboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail');
$input = array_combine($mboxes, array_fill(0, count($mboxes), '*'));
}
else if ($folders == 'sub') {
$delim = $RCMAIL->storage->get_hierarchy_delimiter();
$mboxes = $RCMAIL->storage->list_folders_subscribed($mbox . $delim, '*', 'mail');
array_unshift($mboxes, $mbox);
$input = array_combine($mboxes, array_fill(0, count($mboxes), '*'));
}
else if ($folders == 'cur') {
$input = array($mbox => '*');
}
else {
$input = rcmail::get_uids();
}
foreach ($input as $mbox => $uids) {
$marked += (int)$RCMAIL->storage->set_flag($uids, $flag, $mbox);
$count += count($uids);
}
@ -79,7 +99,7 @@ if (($_uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST))
}
if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$skip_deleted)) {
foreach (rcmail::get_uids() as $mbox => $uids) {
foreach ($input as $mbox => $uids) {
rcmail_send_unread_count($mbox);
}
}

@ -145,6 +145,7 @@
<ul>
<li><roundcube:button command="expunge" type="link" label="compact" classAct="active" /></li>
<li><roundcube:button command="purge" type="link" label="empty" classAct="active" /></li>
<li><roundcube:button command="mark-all-read" type="link" label="markallread" classAct="active" /></li>
<li class="separator_below"><roundcube:button command="import-messages" name="messageimport" type="link" classAct="active" label="importmessages" id="uploadformlink" onclick="if(rcmail.command_enabled('import-messages'))rcmail_ui.show_popup('uploadform', true); return false" /></li>
<li><roundcube:button command="folders" task="settings" type="link" label="managefolders" classAct="active" /></li>
<roundcube:container name="mailboxoptions" id="mailboxoptionsmenu" />

@ -171,6 +171,7 @@
<ul class="toolbarmenu" id="mailboxoptionsmenu" role="menu" aria-labelledby="aria-label-mailboxmenu">
<roundcube:button command="expunge" type="link-menuitem" label="compact" classAct="active" />
<roundcube:button command="purge" type="link-menuitem" label="empty" classAct="active" />
<roundcube:button command="mark-all-read" type="link-menuitem" label="markallread" classAct="active" />
<roundcube:button command="import-messages" type="link-menuitem" name="messageimport" classAct="active" label="importmessages" onclick="if (rcmail.command_enabled('import-messages')) rcmail.upload_input('uploadform')" />
<roundcube:button command="folders" task="settings" type="link-menuitem" label="managefolders" classAct="active" />
<roundcube:container name="mailboxoptions" id="mailboxoptionsmenu" />

Loading…
Cancel
Save