Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion program/actions/mail/compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public function run($args = [])
'selectimportfile', 'messageissent', 'loadingdata', 'nopubkeyfor', 'nopubkeyforsender',
'encryptnoattachments', 'encryptedsendialog', 'searchpubkeyservers', 'importpubkeys',
'encryptpubkeysfound', 'search', 'close', 'import', 'keyid', 'keylength', 'keyexpired',
'keyrevoked', 'keyimportsuccess', 'keyservererror', 'attaching', 'namex', 'attachmentrename'
'keyrevoked', 'keyimportsuccess', 'keyservererror', 'attaching', 'namex', 'attachmentrename',
'deletingmessage', 'discardmessage', 'draftdiscarded', 'discarddraftwarning'
);

$rcmail->output->set_pagetitle($rcmail->gettext('compose'));
Expand Down
24 changes: 23 additions & 1 deletion program/actions/mail/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,24 @@ public function run($args = [])

if (empty($deleted)) {
// send error message
if ($_POST['_from'] != 'show') {
if ($_POST['_from'] != 'show' && $_POST['_from'] != 'compose') {
$rcmail->output->command('list_mailbox');
}

self::display_server_error('errordeleting');
$rcmail->output->send();
} elseif (!empty($_POST['_from']) && $_POST['_from'] == 'compose') {
$COMPOSE_ID = rcube_utils::get_input_string('_compose_id', rcube_utils::INPUT_POST);
$COMPOSE = &$_SESSION['compose_data_' . $COMPOSE_ID];

// Sanity checks
if (isset($COMPOSE['id'])) {
self::delete_compose_data($COMPOSE_ID);
}

$drafts_mbox = $rcmail->config->get('drafts_mbox');
$rcmail->output->command('sent_successfully', 'confirmation', $rcmail->gettext('draftdiscarded'), [$drafts_mbox]);
$rcmail->output->send();
} else {
$rcmail->output->show_message('messagedeleted', 'confirmation');
}
Expand Down Expand Up @@ -136,4 +148,14 @@ public function run($args = [])
// send response
$rcmail->output->send();
}

public static function delete_compose_data($COMPOSE_ID)
{
$rcmail = rcmail::get_instance();
$rcmail->delete_uploaded_files($COMPOSE_ID);
$rcmail->session->remove('compose_data_' . $COMPOSE_ID);
$_SESSION['last_compose_session'] = $COMPOSE_ID;

$rcmail->output->command('remove_compose_data', $COMPOSE_ID);
}
}
6 changes: 1 addition & 5 deletions program/actions/mail/send.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,7 @@ public function run($args = [])

$save_error = true;
} else {
$rcmail->delete_uploaded_files($COMPOSE_ID);
$rcmail->session->remove('compose_data_' . $COMPOSE_ID);
$_SESSION['last_compose_session'] = $COMPOSE_ID;

$rcmail->output->command('remove_compose_data', $COMPOSE_ID);
rcmail_action_mail_delete::delete_compose_data($COMPOSE_ID);

if ($store_folder) {
$folders[] = $store_target;
Expand Down
44 changes: 34 additions & 10 deletions program/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ function rcube_webmail() {
'download-attachment', 'open-attachment', 'rename-attachment'];

if (this.env.drafts_mailbox) {
this.env.compose_commands.push('savedraft');
this.env.compose_commands.push('savedraft', 'delete');
}

this.enable_command(this.env.compose_commands, true);
Expand Down Expand Up @@ -840,13 +840,7 @@ function rcube_webmail() {
&& !this.compose_skip_unsavedcheck
) {
if (!this.env.is_sent && this.cmp_hash != this.compose_field_hash()) {
this.confirm_dialog(this.get_label('notsentwarning'), 'discard', function () {
// remove copy from local storage if compose screen is left intentionally
ref.remove_compose_data(ref.env.compose_id);
ref.compose_skip_unsavedcheck = true;
ref.command(command, props, obj, event);
});

this.discard_draft(null, command, props, obj, event);
return false;
}
}
Expand Down Expand Up @@ -1130,8 +1124,12 @@ function rcube_webmail() {

break;
case 'delete':
// mail: discard draft
if (this.task == 'mail' && this.env.action == 'compose') {
this.discard_draft(this.env.draft_id);
}
// mail task
if (this.task == 'mail') {
else if (this.task == 'mail') {
this.delete_messages(event);
}
// addressbook task
Expand Down Expand Up @@ -3565,6 +3563,30 @@ function rcube_webmail() {
this.show_contentframe(false);
};

this.discard_draft = function (uid, command, props, obj, event) {
var msg = uid ? this.get_label('discarddraftwarning') : this.get_label('notsentwarning');
this.confirm_dialog(msg, 'discard', function () {
if (uid) {
// if a draft has been saved then delete it
var post_data = ref.selection_post_data({ _uid: uid, _compose_id: ref.env.compose_id });
post_data._mbox = ref.env.drafts_mailbox;
ref.with_selected_messages('delete', post_data);
}
else {
// remove copy from local storage if compose screen is left intentionally
ref.remove_compose_data(ref.env.compose_id);

if (command) {
ref.compose_skip_unsavedcheck = true;
ref.command(command, props, obj, event);
}
else {
ref.sent_successfully('confirmation', 'draftdiscarded');
}
}
});
};

// Send a specific move/delete request with UIDs of all selected messages
this.with_selected_messages = function (action, post_data, lock, http_action) {
var msg, count = 0,
Expand Down Expand Up @@ -3878,7 +3900,9 @@ function rcube_webmail() {
this.set_button_titles = function () {
var label = 'deletemessage';

if (!this.env.flag_for_deletion
if (this.env.action == 'compose') {
label = 'discardmessage';
} else if (!this.env.flag_for_deletion
&& this.env.trash_mailbox && this.env.mailbox != this.env.trash_mailbox
&& (!this.env.delete_junk || !this.env.junk_mailbox || this.env.mailbox != this.env.junk_mailbox)
) {
Expand Down
1 change: 1 addition & 0 deletions program/localization/en_US/labels.inc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ $labels['editasnew'] = 'Edit as new';
$labels['send'] = 'Send';
$labels['sendmessage'] = 'Send message';
$labels['savemessage'] = 'Save as draft';
$labels['discardmessage'] = 'Discard draft';
$labels['addattachment'] = 'Attach a file';
$labels['charset'] = 'Charset';
$labels['editortype'] = 'Editor type';
Expand Down
2 changes: 2 additions & 0 deletions program/localization/en_US/messages.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ $messages['sendingmessage'] = 'Sending message...';
$messages['messagesent'] = 'Message sent successfully.';
$messages['savingmessage'] = 'Saving message...';
$messages['messagesaved'] = 'Message saved to Drafts.';
$messages['draftdiscarded'] = 'Draft discarded.';
$messages['successfullysaved'] = 'Successfully saved.';
$messages['savingresponse'] = 'Saving response text...';
$messages['deleteresponseconfirm'] = 'Do you really want to delete this response text?';
Expand Down Expand Up @@ -107,6 +108,7 @@ $messages['nosubjectwarning'] = 'The "Subject" field is empty. Would you like t
$messages['nosubjecttitle'] = 'No subject';
$messages['nobodywarning'] = 'Send this message without text?';
$messages['notsentwarning'] = 'The message has not been sent and has unsaved changes. Do you want to discard your changes?';
$messages['discarddraftwarning'] = 'Do you want to discard your saved draft and any unsaved changes of this message?';
$messages['restoresavedcomposedata'] = 'A previously composed but unsent message was found.\n\nSubject: $subject\nSaved: $date\n\nDo you want to restore this message?';
$messages['nosearchname'] = 'Please enter a contact name or email address.';
$messages['notuploadedwarning'] = 'Not all attachments have been uploaded yet. Please wait or cancel the upload.';
Expand Down
3 changes: 2 additions & 1 deletion skins/elastic/styles/widgets/menu.less
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ a.toolbar-button {
&.create:before {
content: @fa-var-plus-square;
}
&.delete:before {
&.delete:before,
&.discard:before {
content: @fa-var-trash-alt;
}
&.download:before,
Expand Down
3 changes: 3 additions & 0 deletions skins/elastic/templates/compose.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ <h2 id="aria-label-toolbar" class="voice"><roundcube:label name="arialabeltoolba
</a>
</span>
<roundcube:container name="toolbar" id="compose-toolbar" />
<span class="spacer"></span>
<roundcube:button command="delete" type="link" class="discard draft disabled" classAct="discard draft"
label="discard" title="discardmessage" tabindex="2" innerclass="inner" data-content-button="true" />
</div>
</div>
<div id="compose-content" class="formcontainer content">
Expand Down
Loading