summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-10-31 15:17:49 +0400
committerAndrew Dolgov <[email protected]>2012-10-31 15:17:49 +0400
commit29064218d07081fb1325102a380cd828704324f0 (patch)
treee5cfce8b0e88d1bec1d7cd084673efac32f1f66f
parentbeb6ce2761f18bf95a3de62ee2c3858853c4f033 (diff)
allow batch setting of article scores
-rw-r--r--classes/feeds.php3
-rw-r--r--classes/rpc.php4
-rw-r--r--js/viewfeed.js45
3 files changed, 50 insertions, 2 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index 1926d0c39..99d8efc7b 100644
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -45,6 +45,8 @@ class Feeds extends Handler_Protected {
$tog_marked_link = "selectionToggleMarked()";
$tog_published_link = "selectionTogglePublished()";
+ $set_score_link = "setSelectionScore()";
+
if ($is_cat) $cat_q = "&is_cat=$is_cat";
if ($search) {
@@ -107,6 +109,7 @@ class Feeds extends Handler_Protected {
$reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";
$reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";
+ $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";
if ($feed_id != "0") {
$reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";
diff --git a/classes/rpc.php b/classes/rpc.php
index 88c6f1ddc..984187915 100644
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -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))));
diff --git a/js/viewfeed.js b/js/viewfeed.js
index cbb10c3f1..7daf02126 100644
--- a/js/viewfeed.js
+++ b/js/viewfeed.js
@@ -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");