allow batch setting of article scores
This commit is contained in:
parent
beb6ce2761
commit
29064218d0
3 changed files with 50 additions and 2 deletions
|
@ -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>";
|
||||
|
|
|
@ -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))));
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue