]> git.wh0rd.org - tt-rss.git/commitdiff
allow batch setting of article scores
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 31 Oct 2012 11:17:49 +0000 (15:17 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 31 Oct 2012 11:17:49 +0000 (15:17 +0400)
classes/feeds.php
classes/rpc.php
js/viewfeed.js

index 1926d0c39707e3583807265bfaaf35bc87b121f9..99d8efc7b6c52a14fb1b31c42f6fa0f26d1ad0cf 100644 (file)
@@ -45,6 +45,8 @@ class Feeds extends Handler_Protected {
                $tog_marked_link = "selectionToggleMarked()";\r
                $tog_published_link = "selectionTogglePublished()";\r
 \r
+               $set_score_link = "setSelectionScore()";\r
+\r
                if ($is_cat) $cat_q = "&is_cat=$is_cat";\r
 \r
                if ($search) {\r
@@ -107,6 +109,7 @@ class Feeds extends Handler_Protected {
                $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";\r
 \r
                $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";\r
+               $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";\r
 \r
                if ($feed_id != "0") {\r
                        $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";\r
index 88c6f1ddc81a2b78e5fcf650a5d45ca2a6204351..984187915e79e694fe94223a79c48af4d2654b57 100644 (file)
@@ -764,11 +764,11 @@ class RPC extends Handler_Protected {
        }
 
        function setScore() {
-               $id = db_escape_string($_REQUEST['id']);
+               $ids = db_escape_string($_REQUEST['id']);
                $score = (int)db_escape_string($_REQUEST['score']);
 
                db_query($this->link, "UPDATE ttrss_user_entries SET
-                       score = '$score' WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                       score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
 
                print json_encode(array("id" => $id,
                        "score_pic" => theme_image($link, get_score_pic($score))));
index cbb10c3f14a2eed78893b1acf6b1bcbdd61104b3..7daf0212619554f169cdf273fa679cf8466fcf66 100644 (file)
@@ -2138,6 +2138,51 @@ function cancelSearch() {
        }
 }
 
+function setSelectionScore() {
+       try {
+               var ids = getSelectedArticleIds2();
+
+               if (ids.length > 0) {
+                       console.log(ids);
+
+                       var score = prompt(__("Please enter new score for selected articles:"), score);
+
+                       if (score != undefined) {
+                               var query = "op=rpc&method=setScore&id=" + param_escape(ids.toString()) +
+                                       "&score=" + param_escape(score);
+
+                               new Ajax.Request("backend.php", {
+                                       parameters: query,
+                                       onComplete: function(transport) {
+                                               var reply = JSON.parse(transport.responseText);
+                                               if (reply) {
+                                                       console.log(ids);
+
+                                                       ids.each(function(id) {
+                                                               var row = $("RROW-" + id);
+
+                                                               if (row) {
+                                                                       var pic = row.getElementsByClassName("hlScorePic")[0];
+
+                                                                       if (pic) {
+                                                                               pic.src = pic.src.replace(/score_.*?\.png/,
+                                                                                       reply["score_pic"]);
+                                                                               pic.setAttribute("score", score);
+                                                                       }
+                                                               }
+                                                       });
+                                               }
+                                       } });
+                       }
+
+               } else {
+                       alert(__("No articles are selected."));
+               }
+       } catch (e) {
+               exception_error("setSelectionScore", e);
+       }
+}
+
 function changeScore(id, pic) {
        try {
                var score = pic.getAttribute("score");