Add a warning when citing a retracted item

This commit is contained in:
Adomas Venčkauskas 2019-06-07 12:59:42 +03:00
parent 30849303a4
commit 75b38caf6f
2 changed files with 43 additions and 1 deletions

View file

@ -23,6 +23,8 @@
***** END LICENSE BLOCK *****
*/
Components.utils.import("resource://gre/modules/Services.jsm");
var Zotero_Citation_Dialog = new function () {
// Array value [0] is property name.
// Array value [1] is default value of property.
@ -600,6 +602,28 @@ var Zotero_Citation_Dialog = new function () {
io.citation.properties.custom = citation;
}
if (io.citation.citationItems.length) {
for (let item of io.citation.citationItems) {
if (Zotero.Retractions.isRetracted({id: parseInt(item.id)})) {
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var result = ps.confirmEx(null,
Zotero.getString('general.warning'),
Zotero.getString('retraction.citeWarning.text1') + '\n\n'
+ Zotero.getString('retraction.citeWarning.text2'),
buttonFlags,
Zotero.getString('general.continue'),
null,
null, null, {});
if (result != 0) {
return false;
}
break;
}
}
}
io.accept();
_accepted = true;
return true;

View file

@ -716,11 +716,29 @@ var Zotero_QuickFormat = new function () {
if(!referenceBox.hasChildNodes() || !referenceBox.selectedItem) return false;
var citationItem = {"id":referenceBox.selectedItem.getAttribute("zotero-item")};
if(typeof citationItem.id === "string" && citationItem.id.indexOf("/") !== -1) {
if (typeof citationItem.id === "string" && citationItem.id.indexOf("/") !== -1) {
var item = Zotero.Cite.getItem(citationItem.id);
citationItem.uris = item.cslURIs;
citationItem.itemData = item.cslItemData;
}
else if (Zotero.Retractions.isRetracted({id: parseInt(citationItem.id)})) {
referencePanel.hidden = true;
var ps = Services.prompt;
var buttonFlags = ps.BUTTON_POS_0 * ps.BUTTON_TITLE_IS_STRING
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var result = ps.confirmEx(null,
Zotero.getString('general.warning'),
Zotero.getString('retraction.citeWarning.text1') + '\n\n'
+ Zotero.getString('retraction.citeWarning.text2'),
buttonFlags,
Zotero.getString('general.continue'),
null,
null, null, {});
referencePanel.hidden = false;
if (result != 0) {
return false;
}
}
_updateLocator(_getEditorContent());
if(currentLocator) {