]> git.wh0rd.org - tt-rss.git/commitdiff
allow forwarding multiple articles by email
authorAndrew Dolgov <fox@fakecake.org>
Sat, 6 Nov 2010 08:13:07 +0000 (11:13 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Sat, 6 Nov 2010 08:13:07 +0000 (11:13 +0300)
functions.php
modules/popup-dialog.php
templates/email_article_template.txt
viewfeed.js

index 18e7b23f1d3c1912c83fe8c750a5837cf5a5d534..abc52b43ede473d1dc18aa6f78f4f48f4b8c8a5c 100644 (file)
 
                        } 
 
+                       print "<li onclick=\"emailArticle(false)\">&nbsp;&nbsp;".
+                               __('Forward by email')."</li>";
+
                        //print "<li><span class=\"insensitive\">--------</span></li>";
                        print "<li class=\"insensitive\">".__('Assign label:')."</li>";
 
index fb19212917235f87cd1332e134c1634bf9a473c4..c37e392e6953cd3e3573718004e6539a982655fe 100644 (file)
                        print "<input type=\"hidden\" name=\"op\" value=\"rpc\">";
                        print "<input type=\"hidden\" name=\"subop\" value=\"sendEmail\">"; 
 
+                       $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;
 
                        $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 "<input type=\"hidden\" name=\"replyto\" value=\"$user_email\">"; 
-                       //print "<input type=\"hidden\" name=\"fromname\" value=\"$user_name\">"; 
+                               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);
 
index 035ee5c97bd13ff6356381236aa8127772f1d239..0d151d18c2cd55101e92294aaa0f874720813f6b 100644 (file)
@@ -1,12 +1,11 @@
 <!-- $BeginBlock email -->
 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:
+<!-- $BeginBlock article -->
+* ${ARTICLE_TITLE}
+  ${ARTICLE_URL}
+<!-- $EndBlock article -->
 Sincerely yours, 
        ${USER_NAME} <${USER_EMAIL}>.
 
index ac76be70bf2e190a303649c57a39f20caadef906..1e9a11a1656a165f4a24fa2f33eac251e1f631aa 100644 (file)
@@ -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'];