summaryrefslogtreecommitdiff
path: root/plugins/mail/mail.js
blob: 1dc383b007e15a808d39f71b56e564f9cc48ea95 (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
53
54
55
56
57
function emailArticle(id) {
	try {
		if (!id) {
			var ids = Headlines.getSelectedArticleIds2();

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

			id = ids.toString();
		}

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

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

		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();

	} catch (e) {
		exception_error("emailArticle", e);
	}
}