From 3e0f2090bfe90756b6a0a8f803ec5c407b50c41e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 2 Jul 2014 10:38:59 +0400 Subject: [PATCH] mail plugin: cleanup disabled completion, add configurable destination email list --- include/functions2.php | 4 +-- plugins/mail/init.php | 68 +++++++++++++++++++++++++++++++++++++----- plugins/mail/mail.js | 4 +-- 3 files changed, 64 insertions(+), 12 deletions(-) diff --git a/include/functions2.php b/include/functions2.php index 507c5343..d6a399ff 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -1747,7 +1747,7 @@ return $rv; } - function save_email_address($email) { + /* function save_email_address($email) { // FIXME: implement persistent storage of emails if (!$_SESSION['stored_emails']) @@ -1755,7 +1755,7 @@ if (!in_array($email, $_SESSION['stored_emails'])) array_push($_SESSION['stored_emails'], $email); - } + } */ function get_feed_access_key($feed_id, $is_cat, $owner_uid = false) { diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 5fcdf32a..b2d73d4e 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -13,12 +13,61 @@ class Mail extends Plugin { $this->host = $host; $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); + $host->add_hook($host::HOOK_PREFS_TAB, $this); } function get_js() { return file_get_contents(dirname(__FILE__) . "/mail.js"); } + function save() { + $addresslist = db_escape_string($_POST["addresslist"]); + + $this->host->set($this, "addresslist", $addresslist); + + echo __("Mail addresses saved."); + } + + function hook_prefs_tab($args) { + if ($args != "prefPrefs") return; + + print "
"; + + print "

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

"; + + print "
"; + + print ""; + + print ""; + print ""; + print ""; + + $addresslist = $this->host->get($this, "addresslist"); + + print ""; + + print "

"; + + print "

"; + + print "
"; + } + function hook_article_button($line) { return "readTemplateFromFile("templates/email_article_template.txt"); @@ -96,16 +144,20 @@ class Mail extends Plugin { print ""; + $addresslist = explode(",", $this->host->get($this, "addresslist")); + print __('To:'); print ""; - print ""; + name=\"destination\" id=\"emailArticleDlg_destination\">"; */ - print "
"; + print_select("destination", "", $addresslist, 'dojoType="dijit.form.FilteringSelect"'); + +/* print "
"; */ print ""; @@ -155,14 +207,14 @@ class Mail extends Plugin { if (!$rc) { $reply['error'] = $mail->ErrorInfo; } else { - save_email_address(db_escape_string($destination)); + //save_email_address(db_escape_string($destination)); $reply['message'] = "UPDATE_COUNTERS"; } print json_encode($reply); } - function completeEmails() { + /* function completeEmails() { $search = db_escape_string($_REQUEST["search"]); print ""; - } + } */ function api_version() { return 2; diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 6166f01c..db0503ff 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -44,13 +44,13 @@ function emailArticle(id) { }, href: query}); - var tmph = dojo.connect(dialog, 'onLoad', function() { + /* 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(); -- 2.39.5