2021-02-19 10:44:56 +00:00
|
|
|
/* global Plugins, Headlines, dojo, App, xhr, Notify, fox, __ */
|
2021-02-12 12:22:10 +00:00
|
|
|
|
2018-12-03 11:21:50 +00:00
|
|
|
Plugins.Mail = {
|
|
|
|
send: function(id) {
|
|
|
|
if (!id) {
|
2021-02-12 12:22:10 +00:00
|
|
|
const ids = Headlines.getSelected();
|
2018-12-03 11:21:50 +00:00
|
|
|
|
|
|
|
if (ids.length == 0) {
|
|
|
|
alert(__("No articles selected."));
|
|
|
|
return;
|
|
|
|
}
|
2011-12-21 04:46:39 +00:00
|
|
|
|
2018-12-03 11:21:50 +00:00
|
|
|
id = ids.toString();
|
2011-12-21 04:46:39 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 12:22:10 +00:00
|
|
|
const dialog = new fox.SingleUseDialog({
|
2018-12-03 11:21:50 +00:00
|
|
|
title: __("Forward article by email"),
|
|
|
|
execute: function () {
|
|
|
|
if (this.validate()) {
|
2021-02-19 07:22:00 +00:00
|
|
|
xhr.json("backend.php", this.attr('value'), (reply) => {
|
2018-12-03 11:21:50 +00:00
|
|
|
if (reply) {
|
|
|
|
const error = reply['error'];
|
2011-12-21 04:46:39 +00:00
|
|
|
|
2018-12-03 11:21:50 +00:00
|
|
|
if (error) {
|
|
|
|
alert(__('Error sending email:') + ' ' + error);
|
|
|
|
} else {
|
|
|
|
Notify.info('Your message has been sent.');
|
|
|
|
dialog.hide();
|
|
|
|
}
|
2011-12-21 04:46:39 +00:00
|
|
|
|
2018-12-03 11:21:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2021-02-17 11:56:36 +00:00
|
|
|
content: __("Loading, please wait...")
|
2018-12-03 11:21:50 +00:00
|
|
|
});
|
|
|
|
|
2021-02-17 11:56:36 +00:00
|
|
|
const tmph = dojo.connect(dialog, 'onShow', function () {
|
|
|
|
dojo.disconnect(tmph);
|
2018-12-03 11:21:50 +00:00
|
|
|
|
2021-02-19 10:44:56 +00:00
|
|
|
xhr.post("backend.php", App.getPhArgs("mail", "emailArticle", {ids: id}), (reply) => {
|
|
|
|
dialog.attr('content', reply);
|
2021-02-17 11:56:36 +00:00
|
|
|
});
|
|
|
|
});
|
2018-12-03 11:21:50 +00:00
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
},
|
|
|
|
onHotkey: function(id) {
|
|
|
|
Plugins.Mail.send(id);
|
|
|
|
}
|
|
|
|
};
|