diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 45f9dc71e..d40dc87c0 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -8,7 +8,7 @@ class Pref_Prefs extends Handler_Protected { private $profile_blacklist = []; function csrf_ignore($method) { - $csrf_ignored = array("index", "updateself", "editprefprofiles", "otpqrcode"); + $csrf_ignored = array("index", "updateself", "otpqrcode"); return array_search($method, $csrf_ignored) !== false; } diff --git a/classes/pref/users.php b/classes/pref/users.php index 16c2d3142..5c622a9b1 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -12,7 +12,7 @@ class Pref_Users extends Handler_Protected { } function csrf_ignore($method) { - $csrf_ignored = array("index", "edit", "userdetails"); + $csrf_ignored = array("index", "userdetails"); return array_search($method, $csrf_ignored) !== false; } diff --git a/js/App.js b/js/App.js index 07cb45481..cd96dfe2a 100644 --- a/js/App.js +++ b/js/App.js @@ -1,6 +1,6 @@ 'use strict'; -/* global __, Article, Ajax, Headlines, Filters */ +/* global __, Article, Ajax, Headlines, Filters, fox */ /* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds, Cookie */ /* global CommonDialogs, Plugins, Effect */ @@ -313,7 +313,7 @@ const App = { }, helpDialog: function(topic) { xhrPost("backend.php", {op: "backend", method: "help", topic: topic}, (transport) => { - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ title: __("Help"), content: transport.responseText, }); @@ -333,7 +333,7 @@ const App = { let dialog = dijit.byId("infoBox"); if (!dialog) { - dialog = new dijit.Dialog({ + dialog = new fox.SingleUseDialog({ title: title, id: 'infoBox', onCancel: function () { @@ -577,9 +577,6 @@ const App = { } try { - if (dijit.byId("exceptionDlg")) - dijit.byId("exceptionDlg").destroyRecursive(); - let stack_msg = ""; if (error.stack) @@ -599,7 +596,7 @@ const App = { `; - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ id: "exceptionDlg", title: params.title || __("Unhandled exception"), content: content diff --git a/js/Article.js b/js/Article.js index 538377f45..d6e7bbad9 100644 --- a/js/Article.js +++ b/js/Article.js @@ -1,6 +1,6 @@ 'use strict' -/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Ajax */ +/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Ajax, fox */ const Article = { _scroll_reset_timeout: false, @@ -250,12 +250,9 @@ const Article = { return false; }, editTags: function (id) { - if (dijit.byId("editTagsDlg")) - dijit.byId("editTagsDlg").destroyRecursive(); - xhrPost("backend.php", {op: "article", method: "editarticletags", param: id}, (transport) => { - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ id: "editTagsDlg", title: __("Edit article Tags"), content: transport.responseText, diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index b41065c63..700867e73 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -1,6 +1,6 @@ 'use strict' -/* global __, ngettext, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect */ +/* global __, ngettext, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect, fox */ /* exported CommonDialogs */ const CommonDialogs = { @@ -75,16 +75,11 @@ const CommonDialogs = { return false; }, quickAddFeed: function() { - - // overlapping widgets - if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive(); - if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive(); - xhrPost("backend.php", {op: "feeds", method: "quickAddFeed"}, (transport) => { - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ id: "feedAddDlg", title: __("Subscribe to Feed"), content: transport.responseText, @@ -192,10 +187,7 @@ const CommonDialogs = { showFeedsWithErrors: function() { const query = {op: "pref-feeds", method: "feedsWithErrors"}; - if (dijit.byId("errorFeedsDlg")) - dijit.byId("errorFeedsDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ id: "errorFeedsDlg", title: __("Feeds with update errors"), getSelectedFeeds: function () { @@ -298,13 +290,7 @@ const CommonDialogs = { console.log("editFeed", query); - if (dijit.byId("filterEditDlg")) - dijit.byId("filterEditDlg").destroyRecursive(); - - if (dijit.byId("feedEditDlg")) - dijit.byId("feedEditDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ id: "feedEditDlg", title: __("Edit Feed"), execute: function () { @@ -363,10 +349,7 @@ const CommonDialogs = { xhrJson("backend.php", {op: "pref-feeds", method: "getOPMLKey"}, (reply) => { try { - if (dijit.byId("publicOPMLDlg")) - dijit.byId("publicOPMLDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ title: __("Public OPML URL"), id: 'publicOPMLDlg', onCancel: function () { @@ -411,14 +394,10 @@ const CommonDialogs = { xhrJson("backend.php", {op: "pref-feeds", method: "getFeedKey", id: feed, is_cat: is_cat}, (reply) => { try { - if (dijit.byId("genFeedDlg")) - dijit.byId("genFeedDlg").destroyRecursive(); - const feed_title = Feeds.getName(feed, is_cat); - const secret_url = rss_url + "&key=" + encodeURIComponent(reply.link); - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ title: __("Show as feed"), id: 'genFeedDlg', onCancel: function () { diff --git a/js/CommonFilters.js b/js/CommonFilters.js index e0e8034ea..1d5b9236b 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -1,6 +1,6 @@ 'use strict' -/* global __, App, Article, Lists, Effect */ +/* global __, App, Article, Lists, Effect, fox */ /* global xhrPost, dojo, dijit, Notify, $$, Feeds */ const Filters = { @@ -138,10 +138,7 @@ const Filters = { }, test: function(params) { - if (dijit.byId("filterTestDlg")) - dijit.byId("filterTestDlg").destroyRecursive(); - - const test_dlg = new dijit.Dialog({ + const test_dlg = new fox.SingleUseDialog({ id: "filterTestDlg", title: "Test Filter", results: 0, @@ -249,128 +246,127 @@ const Filters = { console.log('Filters.edit', query); xhrPost("backend.php", query, function (transport) { - if (dijit.byId("feedEditDlg")) - dijit.byId("feedEditDlg").destroyRecursive(); + try { + const dialog = new fox.SingleUseDialog({ + id: "filterEditDlg", + title: __("Create Filter"), + test: function () { + Filters.test(this.attr('value')); + }, + selectRules: function (select) { + Lists.select("filterDlg_Matches", select); + }, + selectActions: function (select) { + Lists.select("filterDlg_Actions", select); + }, + editRule: function (e) { + const li = e.closest('li'); + const rule = li.querySelector('input[name="rule[]"]').value - if (dijit.byId("filterEditDlg")) - dijit.byId("filterEditDlg").destroyRecursive(); + Filters.addFilterRule(li, rule); + }, + editAction: function (e) { + const li = e.closest('li'); + const action = li.querySelector('input[name="action[]"]').value - const dialog = new dijit.Dialog({ - id: "filterEditDlg", - title: __("Create Filter"), - test: function () { - Filters.test(this.attr('value')); - }, - selectRules: function (select) { - Lists.select("filterDlg_Matches", select); - }, - selectActions: function (select) { - Lists.select("filterDlg_Actions", select); - }, - editRule: function (e) { - const li = e.closest('li'); - const rule = li.querySelector('input[name="rule[]"]').value + Filters.addFilterAction(li, action); + }, + removeFilter: function () { + const msg = __("Remove filter?"); - Filters.addFilterRule(li, rule); - }, - editAction: function (e) { - const li = e.closest('li'); - const action = li.querySelector('input[name="action[]"]').value + if (confirm(msg)) { + this.hide(); - Filters.addFilterAction(li, action); - }, - removeFilter: function () { - const msg = __("Remove filter?"); + Notify.progress("Removing filter..."); - if (confirm(msg)) { - this.hide(); + const query = {op: "pref-filters", method: "remove", ids: this.attr('value').id}; - Notify.progress("Removing filter..."); + xhrPost("backend.php", query, () => { + const tree = dijit.byId("filterTree"); - const query = {op: "pref-filters", method: "remove", ids: this.attr('value').id}; - - xhrPost("backend.php", query, () => { - const tree = dijit.byId("filterTree"); - - if (tree) tree.reload(); + if (tree) tree.reload(); + }); + } + }, + addAction: function () { + Filters.addFilterAction(); + }, + addRule: function () { + Filters.addFilterRule(); + }, + deleteAction: function () { + $$("#filterDlg_Actions li[class*=Selected]").each(function (e) { + e.parentNode.removeChild(e) }); - } - }, - addAction: function () { - Filters.addFilterAction(); - }, - addRule: function () { - Filters.addFilterRule(); - }, - deleteAction: function () { - $$("#filterDlg_Actions li[class*=Selected]").each(function (e) { - e.parentNode.removeChild(e) - }); - }, - deleteRule: function () { - $$("#filterDlg_Matches li[class*=Selected]").each(function (e) { - e.parentNode.removeChild(e) - }); - }, - execute: function () { - if (this.validate()) { - - Notify.progress("Saving data...", true); - - xhrPost("backend.php", this.attr('value'), () => { - dialog.hide(); - - const tree = dijit.byId("filterTree"); - if (tree) tree.reload(); + }, + deleteRule: function () { + $$("#filterDlg_Matches li[class*=Selected]").each(function (e) { + e.parentNode.removeChild(e) }); - } - }, - content: transport.responseText - }); + }, + execute: function () { + if (this.validate()) { - if (!App.isPrefs()) { - /* global getSelectionText */ - const selectedText = getSelectionText(); + Notify.progress("Saving data...", true); - const lh = dojo.connect(dialog, "onShow", function () { - dojo.disconnect(lh); + xhrPost("backend.php", this.attr('value'), () => { + dialog.hide(); - if (selectedText != "") { - - const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) : - Feeds.getActive(); - - const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1}; - - Filters.addFilterRule(null, dojo.toJson(rule)); - - } else { - - const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()}; - - xhrPost("backend.php", query, (transport) => { - const reply = JSON.parse(transport.responseText); - - let title = false; - - if (reply && reply.title) title = reply.title; - - if (title || Feeds.getActive() || Feeds.activeIsCat()) { - - console.log(title + " " + Feeds.getActive()); - - const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) : - Feeds.getActive(); - - const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1}; - - Filters.addFilterRule(null, dojo.toJson(rule)); - } - }); - } + const tree = dijit.byId("filterTree"); + if (tree) tree.reload(); + }); + } + }, + content: transport.responseText }); + + if (!App.isPrefs()) { + /* global getSelectionText */ + const selectedText = getSelectionText(); + + const lh = dojo.connect(dialog, "onShow", function () { + dojo.disconnect(lh); + + if (selectedText != "") { + + const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) : + Feeds.getActive(); + + const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1}; + + Filters.addFilterRule(null, dojo.toJson(rule)); + + } else { + + const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()}; + + xhrPost("backend.php", query, (transport) => { + const reply = JSON.parse(transport.responseText); + + let title = false; + + if (reply && reply.title) title = reply.title; + + if (title || Feeds.getActive() || Feeds.activeIsCat()) { + + console.log(title + " " + Feeds.getActive()); + + const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) : + Feeds.getActive(); + + const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1}; + + Filters.addFilterRule(null, dojo.toJson(rule)); + } + }); + } + }); + } + dialog.show(); + + } catch (e) { + App.Error.report(e); } - dialog.show(); }); }, }; diff --git a/js/Feeds.js b/js/Feeds.js index 45b8193e4..986936285 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -1,6 +1,6 @@ 'use strict' -/* global __, App, Headlines, xhrPost, dojo, dijit, Form, fox, PluginHost, Notify, $$ */ +/* global __, App, Headlines, xhrPost, dojo, dijit, Form, fox, PluginHost, Notify, $$, fox */ const Feeds = { counters_last_request: 0, @@ -223,10 +223,7 @@ const Feeds = { if (App.getInitParam("is_default_pw")) { console.warn("user password is at default value"); - if (dijit.byId("defaultPasswordDlg")) - dijit.byId("defaultPasswordDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ title: __("Your password is at default value"), content: `