From a2e688fcb2d463a5db700ebd013c783e3a8f4971 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 22:17:13 +0300 Subject: render headline-specific toolbar on the client --- plugins/mail/init.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins/mail') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 40d147fc9..829620ebc 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -15,12 +15,17 @@ class Mail extends Plugin { $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); $host->add_hook($host::HOOK_PREFS_TAB, $this); + $host->add_hook($host::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM, $this); } function get_js() { return file_get_contents(dirname(__FILE__) . "/mail.js"); } + function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) { + return "
".__('Forward by email')."
"; + } + function save() { $addresslist = $_POST["addresslist"]; @@ -32,7 +37,7 @@ class Mail extends Plugin { function hook_prefs_tab($args) { if ($args != "prefPrefs") return; - print "
mail ".__('Mail plugin')."\">"; print "

" . __("You can set predefined email addressed here (comma-separated list):") . "

"; -- cgit v1.2.3 From 26d6b84a572b5cbd99acffc5ae727ea6d1be543a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:23:00 +0300 Subject: add namespaced controls with unified naming; deprecated old-style control shortcuts --- plugins/mail/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mail') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 829620ebc..b1263ece5 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -160,7 +160,7 @@ class Mail extends Plugin { style=\"width : 30em;\" name=\"destination\" id=\"emailArticleDlg_destination\">"; */ - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); + print \Controls\select_tag("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); /* print "
"; */ -- cgit v1.2.3 From 1f43d7916cda16e9680b9087bda1f52934e8f25b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:32:06 +0300 Subject: replace print_hidden with hidden_tag --- plugins/mail/init.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'plugins/mail') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index b1263ece5..ffd0397e0 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -58,9 +58,9 @@ class Mail extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "mail"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "mail"); $addresslist = $this->host->get($this, "addresslist"); @@ -86,9 +86,9 @@ class Mail extends Plugin { $ids = explode(",", $_REQUEST['param']); $ids_qmarks = arr_qmarks($ids); - print_hidden("op", "pluginhandler"); - print_hidden("plugin", "mail"); - print_hidden("method", "sendEmail"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("plugin", "mail"); + print \Controls\hidden_tag("method", "sendEmail"); $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE id = ?"); @@ -105,8 +105,8 @@ class Mail extends Plugin { if (!$user_name) $user_name = $_SESSION['name']; - print_hidden("from_email", "$user_email"); - print_hidden("from_name", "$user_name"); + print \Controls\hidden_tag("from_email", "$user_email"); + print \Controls\hidden_tag("from_name", "$user_name"); $tpl = new Templator(); -- cgit v1.2.3 From bdbbdbb0eddd125bec167da5f42bbd95c770151f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 16:59:21 +0300 Subject: rework controls to accept parameters as array --- plugins/mail/init.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins/mail') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index ffd0397e0..c054196df 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -160,7 +160,8 @@ class Mail extends Plugin { style=\"width : 30em;\" name=\"destination\" id=\"emailArticleDlg_destination\">"; */ - print \Controls\select_tag("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); + print \Controls\select_tag("destination", "", $addresslist, + ["style" => "width: 30em", "dojoType" => "dijit.form.ComboBox"]); /* print "
"; */ -- cgit v1.2.3 From 2b2833bb4fa6f958b89a83adea89d9e7c73daee7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 14:56:36 +0300 Subject: plugins: load dialogs via xhr instead of http --- plugins/mail/init.php | 35 ++++++++--------------------------- plugins/mail/mail.js | 19 ++++++++----------- 2 files changed, 16 insertions(+), 38 deletions(-) (limited to 'plugins/mail') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index c054196df..8a0d01aca 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -19,7 +19,7 @@ class Mail extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/mail.js"); + return file_get_contents(__DIR__ . "/mail.js"); } function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) { @@ -83,9 +83,11 @@ class Mail extends Plugin { function emailArticle() { - $ids = explode(",", $_REQUEST['param']); + $ids = explode(",", clean($_REQUEST['ids'])); $ids_qmarks = arr_qmarks($ids); + print "
"; + print \Controls\hidden_tag("op", "pluginhandler"); print \Controls\hidden_tag("plugin", "mail"); print \Controls\hidden_tag("method", "sendEmail"); @@ -156,15 +158,8 @@ class Mail extends Plugin { print ""; -/* print ""; */ - print \Controls\select_tag("destination", "", $addresslist, - ["style" => "width: 30em", "dojoType" => "dijit.form.ComboBox"]); - -/* print "
"; */ + ["style" => "width: 30em", "required" => 1, "dojoType" => "dijit.form.ComboBox"]); print ""; @@ -184,11 +179,11 @@ class Mail extends Plugin { print ""; print "
"; - print " "; - print ""; + print \Controls\submit_tag(__('Send email')); + print \Controls\cancel_dialog_tag(__('Cancel')); print "
"; - //return; + print "
"; } function sendEmail() { @@ -229,20 +224,6 @@ class Mail extends Plugin { print json_encode($reply); } - /* function completeEmails() { - $search = $_REQUEST["search"]; - - print "
    "; - - foreach ($_SESSION['stored_emails'] as $email) { - if (strpos($email, $search) !== false) { - print "
  • $email
  • "; - } - } - - print "
"; - } */ - function api_version() { return 2; } diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 5ddc0dc41..4cdf6999d 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -1,4 +1,4 @@ -/* global Plugins, Headlines, xhrJson, Notify, fox, __ */ +/* global Plugins, Headlines, dojo, xhrPost, xhrJson, Notify, fox, __ */ Plugins.Mail = { send: function(id) { @@ -13,10 +13,7 @@ Plugins.Mail = { id = ids.toString(); } - const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ - id: "emailArticleDlg", title: __("Forward article by email"), execute: function () { if (this.validate()) { @@ -35,16 +32,16 @@ Plugins.Mail = { }); } }, - href: query + content: __("Loading, please wait...") }); - /* var tmph = dojo.connect(dialog, 'onLoad', function() { - dojo.disconnect(tmph); + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); - new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices', - "backend.php?op=pluginhandler&plugin=mail&method=completeEmails", - { tokens: '', paramName: "search" }); - }); */ + xhrPost("backend.php", {op: "pluginhandler", plugin: "mail", method: "emailArticle", ids: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); + }); dialog.show(); }, -- cgit v1.2.3 From 2ac6508fe697ed5e95cc7bf73ffb9e2e0bf0d3fa Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 15:53:00 +0300 Subject: mail, mailto: cleanup markup --- plugins/mail/init.php | 150 +++++++++++++++++++++++++++----------------------- 1 file changed, 81 insertions(+), 69 deletions(-) (limited to 'plugins/mail') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 8a0d01aca..bb576a4d9 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -37,42 +37,44 @@ class Mail extends Plugin { function hook_prefs_tab($args) { if ($args != "prefPrefs") return; - print "
mail ".__('Mail plugin')."\">"; - - print "

" . __("You can set predefined email addressed here (comma-separated list):") . "

"; - - print "
"; - - print ""; + - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "mail"); +
- $addresslist = $this->host->get($this, "addresslist"); + - print ""; +
- print "

"; + - print "

"; + - print "
"; +
+ "; - - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("plugin", "mail"); - print \Controls\hidden_tag("method", "sendEmail"); $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE id = ?"); @@ -107,9 +104,6 @@ class Mail extends Plugin { if (!$user_name) $user_name = $_SESSION['name']; - print \Controls\hidden_tag("from_email", "$user_email"); - print \Controls\hidden_tag("from_name", "$user_name"); - $tpl = new Templator(); $tpl->readTemplateFromFile("email_article_template.txt"); @@ -150,40 +144,58 @@ class Mail extends Plugin { $content = ""; $tpl->generateOutputToString($content); - print ""; - - print "
"; - $addresslist = explode(",", $this->host->get($this, "addresslist")); - print __('To:'); - - print ""; - - print \Controls\select_tag("destination", "", $addresslist, - ["style" => "width: 30em", "required" => 1, "dojoType" => "dijit.form.ComboBox"]); - - print "
"; - - print __('Subject:'); - - print ""; - - print ""; - - print "
"; - - print "
"; - - print ""; - - print ""; + ?> + +
+ + + + + + + + + + +
+
+ + "width: 380px", "required" => 1, "dojoType" => "dijit.form.ComboBox"]) ?> +
+
+ +
+
+ + +
+
+ + + +
+ + +
+ +
+ Date: Wed, 17 Feb 2021 15:53:58 +0300 Subject: delete unused mail .pngs --- plugins/mail/mail.png | Bin 641 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 plugins/mail/mail.png (limited to 'plugins/mail') diff --git a/plugins/mail/mail.png b/plugins/mail/mail.png deleted file mode 100644 index 7348aed77..000000000 Binary files a/plugins/mail/mail.png and /dev/null differ -- cgit v1.2.3 From e4609c18efceebb1e021d814f53061ada7f6489a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 21:44:21 +0300 Subject: * add (disabled) shortcut syntax for plugin methods * add controls shortcut for pluginhandler tags * add similar shortcut for frontend * allow plugins to selectively exclude their methods from CSRF checking --- plugins/mail/init.php | 12 ++++-------- plugins/mail/mail.js | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'plugins/mail') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index bb576a4d9..4b62d1e64 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -45,9 +45,7 @@ class Mail extends Plugin { title="mail ">
- - - + +
@@ -70,7 +67,6 @@ class Mail extends Plugin {
- Date: Fri, 19 Feb 2021 10:22:00 +0300 Subject: migrate xhrJson invocations to the new helper --- plugins/mail/init.php | 2 +- plugins/mail/mail.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mail') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index d96006b21..16e22f342 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -152,7 +152,7 @@ class Mail extends Plugin { diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index fc0898085..d2bafe0e9 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -1,4 +1,4 @@ -/* global Plugins, Headlines, dojo, xhrPost, xhrJson, Notify, fox, __ */ +/* global Plugins, Headlines, dojo, App, xhr, Notify, fox, __ */ Plugins.Mail = { send: function(id) { @@ -38,8 +38,8 @@ Plugins.Mail = { const tmph = dojo.connect(dialog, 'onShow', function () { dojo.disconnect(tmph); - xhrPost("backend.php", App.getPhArgs("mail", "emailArticle", {ids: id}), (transport) => { - dialog.attr('content', transport.responseText); + xhr.post("backend.php", App.getPhArgs("mail", "emailArticle", {ids: id}), (reply) => { + dialog.attr('content', reply); }); }); -- cgit v1.2.3