summaryrefslogtreecommitdiff
path: root/plugins/mail/mail.js
blob: 87e354b42e7f98f758b75b30a28eaa568d654d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function emailArticle(id) {
	if (!id) {
		let ids = Headlines.getSelected();

		if (ids.length == 0) {
			alert(__("No articles selected."));
			return;
		}

		id = ids.toString();
	}

	if (dijit.byId("emailArticleDlg"))
		dijit.byId("emailArticleDlg").destroyRecursive();

	const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle&param=" + encodeURIComponent(id);

	const dialog = new dijit.Dialog({
		id: "emailArticleDlg",
		title: __("Forward article by email"),
		style: "width: 600px",
		execute: function() {
			if (this.validate()) {
				xhrJson("backend.php", this.attr('value'), (reply) => {
					if (reply) {
						const error = reply['error'];

						if (error) {
							alert(__('Error sending email:') + ' ' + error);
						} else {
							Notify.info('Your message has been sent.');
							dialog.hide();
						}

					}
				});
			}
		},
		href: query});

	/* var tmph = dojo.connect(dialog, 'onLoad', function() {
	dojo.disconnect(tmph);

	   new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
		   "backend.php?op=pluginhandler&plugin=mail&method=completeEmails",
		   { tokens: '', paramName: "search" });
	}); */

	dialog.show();
}