From: Andrew Dolgov Date: Sat, 6 Nov 2010 08:13:07 +0000 (+0300) Subject: allow forwarding multiple articles by email X-Git-Tag: 1.5.0~391 X-Git-Url: https://git.wh0rd.org/?p=tt-rss.git;a=commitdiff_plain;h=f72a7b6696286b2b1bb6a3d0ae33bab49e3552d0 allow forwarding multiple articles by email --- diff --git a/functions.php b/functions.php index 18e7b23f..abc52b43 100644 --- a/functions.php +++ b/functions.php @@ -4219,6 +4219,9 @@ } + print "
  •   ". + __('Forward by email')."
  • "; + //print "
  • --------
  • "; print "
  • ".__('Assign label:')."
  • "; diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index fb192129..c37e392e 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -681,6 +681,15 @@ print ""; print ""; + $result = db_query($link, "SELECT email FROM ttrss_users WHERE + id = " . $_SESSION["uid"]); + + $user_email = htmlspecialchars(db_fetch_result($result, 0, "email")); + $user_name = htmlspecialchars($_SESSION["name"]); + + $_SESSION['email_replyto'] = $user_email; + $_SESSION['email_fromname'] = $user_name; + require_once "lib/MiniTemplator.class.php"; $tpl = new MiniTemplator; @@ -688,39 +697,33 @@ $tpl->readTemplateFromFile("templates/email_article_template.txt"); - $result = db_query($link, "SELECT link, content, title - FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND - id = '$param' AND owner_uid = " . $_SESSION["uid"]); - - $line = db_fetch_assoc($result); - - $subject = htmlspecialchars(__("[Forwarded]") . " " . $line["title"]); - - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); + $tpl->setVariable('USER_NAME', $_SESSION["name"]); + $tpl->setVariable('USER_EMAIL', $user_email); + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"]); -/* $tpl->setVariable('ARTICLE_EXCERPT', - truncate_string(strip_tags($line["content"]), 200)); */ +// $tpl->addBlock('header'); - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); + $result = db_query($link, "SELECT link, content, title + FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND + id IN ($param) AND owner_uid = " . $_SESSION["uid"]); - $result = db_query($link, "SELECT email FROM ttrss_users WHERE - id = " . $_SESSION["uid"]); + if (db_num_rows($result) > 1) { + $subject = __("[Forwarded]") . " " . __("Multiple articles"); + } - $user_email = htmlspecialchars(db_fetch_result($result, 0, "email")); - $user_name = htmlspecialchars($_SESSION["name"]); + while ($line = db_fetch_assoc($result)) { - //print ""; - //print ""; + if (!$subject) + $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); - $_SESSION['email_replyto'] = $user_email; - $_SESSION['email_fromname'] = $user_name; + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); - $tpl->setVariable('USER_NAME', $_SESSION["name"]); - $tpl->setVariable('USER_EMAIL', $user_email); - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"]); + $tpl->addBlock('article'); + } $tpl->addBlock('email'); - + $content = ""; $tpl->generateOutputToString($content); diff --git a/templates/email_article_template.txt b/templates/email_article_template.txt index 035ee5c9..0d151d18 100644 --- a/templates/email_article_template.txt +++ b/templates/email_article_template.txt @@ -1,12 +1,11 @@ Hi, -I've been reading this article and thought it might interest you: - -${ARTICLE_TITLE} - -${ARTICLE_URL} - +I've been reading this and thought it might interest you: + +* ${ARTICLE_TITLE} + ${ARTICLE_URL} + Sincerely yours, ${USER_NAME} <${USER_EMAIL}>. diff --git a/viewfeed.js b/viewfeed.js index ac76be70..1e9a11a1 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -2265,6 +2265,17 @@ function publishWithNote(id, def_note) { function emailArticle(id) { try { + if (!id) { + var ids = getSelectedArticleIds2(); + + if (ids.length == 0) { + alert(__("No articles are selected.")); + return; + } + + id = ids.toString(); + } + displayDlg('emailArticle', id, function () { document.forms['article_email_form'].destination.focus(); @@ -2280,7 +2291,7 @@ function emailArticle(id) { } } -function emailArticleDo(id) { +function emailArticleDo() { try { var f = document.forms['article_email_form'];