2011-12-21 04:46:39 +00:00
|
|
|
function shareArticle(id) {
|
|
|
|
try {
|
|
|
|
if (dijit.byId("shareArticleDlg"))
|
|
|
|
dijit.byId("shareArticleDlg").destroyRecursive();
|
|
|
|
|
2012-12-23 10:52:18 +00:00
|
|
|
var query = "backend.php?op=pluginhandler&plugin=share&method=shareArticle¶m=" + param_escape(id);
|
2011-12-21 04:46:39 +00:00
|
|
|
|
|
|
|
dialog = new dijit.Dialog({
|
|
|
|
id: "shareArticleDlg",
|
|
|
|
title: __("Share article by URL"),
|
|
|
|
style: "width: 600px",
|
2013-07-11 10:03:40 +00:00
|
|
|
newurl: function() {
|
2018-11-30 10:05:59 +00:00
|
|
|
if (confirm(__("Generate new share URL for this article?"))) {
|
2013-07-11 10:03:40 +00:00
|
|
|
|
|
|
|
notify_progress("Trying to change URL...", true);
|
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
const query = { op: "pluginhandler", plugin: "share", method: "newkey", id: id };
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
xhrJson("backend.php", query, (reply) => {
|
|
|
|
if (reply) {
|
|
|
|
const new_link = reply.link;
|
|
|
|
const e = $('gen_article_url');
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
if (new_link) {
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
|
|
|
|
"&key=" + new_link);
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
e.href = e.href.replace(/\&key=.*$/,
|
|
|
|
"&key=" + new_link);
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
new Effect.Highlight(e);
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
const img = $("SHARE-IMG-" + id);
|
|
|
|
if (img) img.src = img.src.replace("notshared.png", "share.png");
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
notify('');
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
} else {
|
|
|
|
notify_error("Could not change URL.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-07-11 10:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
unshare: function() {
|
2018-11-30 10:05:59 +00:00
|
|
|
if (confirm(__("Remove sharing for this article?"))) {
|
2013-07-11 10:03:40 +00:00
|
|
|
|
|
|
|
notify_progress("Trying to unshare...", true);
|
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
const query = { op: "pluginhandler", plugin: "share", method: "unshare", id: id };
|
2013-07-11 10:03:40 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
xhrPost("backend.php", query, () => {
|
|
|
|
notify("Article unshared.");
|
2013-07-11 12:20:24 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
var img = $("SHARE-IMG-" + id);
|
|
|
|
if (img) img.src = img.src.replace("share.png", "notshared.png");
|
2013-07-11 12:20:24 +00:00
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
dialog.hide();
|
|
|
|
});
|
2013-07-11 10:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
2011-12-21 04:46:39 +00:00
|
|
|
href: query});
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
|
2018-11-30 12:23:48 +00:00
|
|
|
const img = $("SHARE-IMG-" + id);
|
2013-07-11 12:20:24 +00:00
|
|
|
if (img) img.src = img.src.replace("notshared.png", "share.png");
|
|
|
|
|
2011-12-21 04:46:39 +00:00
|
|
|
} catch (e) {
|
2013-07-11 10:03:40 +00:00
|
|
|
exception_error("shareArticle", e);
|
2011-12-21 04:46:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|