From d719b062404f551594bbe5ee37f1eb306061c118 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:41:41 +0400 Subject: rpc: move setScore to article --- classes/article.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'classes/article.php') diff --git a/classes/article.php b/classes/article.php index 79c94f59b..6e4236936 100644 --- a/classes/article.php +++ b/classes/article.php @@ -208,5 +208,16 @@ class Article extends Handler_Protected { } + function setScore() { + $ids = db_escape_string($this->link, $_REQUEST['id']); + $score = (int)db_escape_string($this->link, $_REQUEST['score']); + + db_query($this->link, "UPDATE ttrss_user_entries SET + score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]); + + print json_encode(array("id" => $id, + "score_pic" => get_score_pic($score))); + } + } -- cgit v1.2.3-54-g00ecf From 5df8be5c0ac69db8716fcb29a27b2bbc3fbcbace Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:52:21 +0400 Subject: rpc: move setArticleTags to article --- classes/article.php | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++- classes/rpc.php | 64 --------------------------------------------------- 2 files changed, 65 insertions(+), 65 deletions(-) (limited to 'classes/article.php') diff --git a/classes/article.php b/classes/article.php index 6e4236936..bf1e55662 100644 --- a/classes/article.php +++ b/classes/article.php @@ -185,7 +185,7 @@ class Article extends Handler_Protected { $tags_str = join(", ", $tags); print ""; - print ""; + print ""; print ""; print "
"; @@ -220,4 +220,68 @@ class Article extends Handler_Protected { } + function setArticleTags() { + + $id = db_escape_string($this->link, $_REQUEST["id"]); + + $tags_str = db_escape_string($this->link, $_REQUEST["tags_str"]); + $tags = array_unique(trim_array(explode(",", $tags_str))); + + db_query($this->link, "BEGIN"); + + $result = db_query($this->link, "SELECT int_id FROM ttrss_user_entries WHERE + ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1"); + + if (db_num_rows($result) == 1) { + + $tags_to_cache = array(); + + $int_id = db_fetch_result($result, 0, "int_id"); + + db_query($this->link, "DELETE FROM ttrss_tags WHERE + post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'"); + + foreach ($tags as $tag) { + $tag = sanitize_tag($tag); + + if (!tag_is_valid($tag)) { + continue; + } + + if (preg_match("/^[0-9]*$/", $tag)) { + continue; + } + + // print ""; + + if ($tag != '') { + db_query($this->link, "INSERT INTO ttrss_tags + (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')"); + } + + array_push($tags_to_cache, $tag); + } + + /* update tag cache */ + + sort($tags_to_cache); + $tags_str = join(",", $tags_to_cache); + + db_query($this->link, "UPDATE ttrss_user_entries + SET tag_cache = '$tags_str' WHERE ref_id = '$id' + AND owner_uid = " . $_SESSION["uid"]); + } + + db_query($this->link, "COMMIT"); + + $tags = get_article_tags($this->link, $id); + $tags_str = format_tags_string($tags, $id); + $tags_str_full = join(", ", $tags); + + if (!$tags_str_full) $tags_str_full = __("no tags"); + + print json_encode(array("id" => (int)$id, + "content" => $tags_str, "content_full" => $tags_str_full)); + } + } diff --git a/classes/rpc.php b/classes/rpc.php index 3593bd5d8..a78e079ca 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -347,70 +347,6 @@ class RPC extends Handler_Protected { print json_encode($reply); } - function setArticleTags() { - - $id = db_escape_string($this->link, $_REQUEST["id"]); - - $tags_str = db_escape_string($this->link, $_REQUEST["tags_str"]); - $tags = array_unique(trim_array(explode(",", $tags_str))); - - db_query($this->link, "BEGIN"); - - $result = db_query($this->link, "SELECT int_id FROM ttrss_user_entries WHERE - ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1"); - - if (db_num_rows($result) == 1) { - - $tags_to_cache = array(); - - $int_id = db_fetch_result($result, 0, "int_id"); - - db_query($this->link, "DELETE FROM ttrss_tags WHERE - post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'"); - - foreach ($tags as $tag) { - $tag = sanitize_tag($tag); - - if (!tag_is_valid($tag)) { - continue; - } - - if (preg_match("/^[0-9]*$/", $tag)) { - continue; - } - - // print ""; - - if ($tag != '') { - db_query($this->link, "INSERT INTO ttrss_tags - (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')"); - } - - array_push($tags_to_cache, $tag); - } - - /* update tag cache */ - - sort($tags_to_cache); - $tags_str = join(",", $tags_to_cache); - - db_query($this->link, "UPDATE ttrss_user_entries - SET tag_cache = '$tags_str' WHERE ref_id = '$id' - AND owner_uid = " . $_SESSION["uid"]); - } - - db_query($this->link, "COMMIT"); - - $tags = get_article_tags($this->link, $id); - $tags_str = format_tags_string($tags, $id); - $tags_str_full = join(", ", $tags); - - if (!$tags_str_full) $tags_str_full = __("no tags"); - - print json_encode(array("id" => (int)$id, - "content" => $tags_str, "content_full" => $tags_str_full)); - } - function completeLabels() { $search = db_escape_string($this->link, $_REQUEST["search"]); -- cgit v1.2.3-54-g00ecf From c83554bdddd1efb8a600d2dc6dbd119e3104013c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:53:36 +0400 Subject: rpc: move completeTags to article --- classes/article.php | 17 +++++++++++++++++ classes/rpc.php | 16 ---------------- js/viewfeed.js | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) (limited to 'classes/article.php') diff --git a/classes/article.php b/classes/article.php index bf1e55662..e75af0e7a 100644 --- a/classes/article.php +++ b/classes/article.php @@ -284,4 +284,21 @@ class Article extends Handler_Protected { "content" => $tags_str, "content_full" => $tags_str_full)); } + + function completeTags() { + $search = db_escape_string($this->link, $_REQUEST["search"]); + + $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags + WHERE owner_uid = '".$_SESSION["uid"]."' AND + tag_name LIKE '$search%' ORDER BY tag_name + LIMIT 10"); + + print "
    "; + while ($line = db_fetch_assoc($result)) { + print "
  • " . $line["tag_name"] . "
  • "; + } + print "
"; + } + + } diff --git a/classes/rpc.php b/classes/rpc.php index a78e079ca..04b763c46 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -363,22 +363,6 @@ class RPC extends Handler_Protected { print ""; } - - function completeTags() { - $search = db_escape_string($this->link, $_REQUEST["search"]); - - $result = db_query($this->link, "SELECT DISTINCT tag_name FROM ttrss_tags - WHERE owner_uid = '".$_SESSION["uid"]."' AND - tag_name LIKE '$search%' ORDER BY tag_name - LIMIT 10"); - - print "
    "; - while ($line = db_fetch_assoc($result)) { - print "
  • " . $line["tag_name"] . "
  • "; - } - print "
"; - } - function purge() { $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"])); $days = sprintf("%d", $_REQUEST["days"]); diff --git a/js/viewfeed.js b/js/viewfeed.js index be2b88f4d..31eff1b8a 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -1114,7 +1114,7 @@ function editArticleTags(id) { dojo.disconnect(tmph); new Ajax.Autocompleter('tags_str', 'tags_choices', - "backend.php?op=rpc&method=completeTags", + "backend.php?op=article&method=completeTags", { tokens: ',', paramName: "search" }); }); -- cgit v1.2.3-54-g00ecf From 4b7726f0b44db36ad12c0a0918a9129c8cbb1caa Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Apr 2013 14:56:08 +0400 Subject: rpc: move labelops to article --- classes/article.php | 42 ++++++++++++++++++++++++++++++++++++++++++ classes/rpc.php | 41 ----------------------------------------- js/viewfeed.js | 4 ++-- 3 files changed, 44 insertions(+), 43 deletions(-) (limited to 'classes/article.php') diff --git a/classes/article.php b/classes/article.php index e75af0e7a..9a0970140 100644 --- a/classes/article.php +++ b/classes/article.php @@ -300,5 +300,47 @@ class Article extends Handler_Protected { print ""; } + function assigntolabel() { + return $this->labelops(true); + } + + function removefromlabel() { + return $this->labelops(false); + } + + private function labelops($assign) { + $reply = array(); + + $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"])); + $label_id = db_escape_string($this->link, $_REQUEST["lid"]); + + $label = db_escape_string($this->link, label_find_caption($this->link, $label_id, + $_SESSION["uid"])); + + $reply["info-for-headlines"] = array(); + + if ($label) { + + foreach ($ids as $id) { + + if ($assign) + label_add_article($this->link, $id, $label, $_SESSION["uid"]); + else + label_remove_article($this->link, $id, $label, $_SESSION["uid"]); + + $labels = get_article_labels($this->link, $id, $_SESSION["uid"]); + + array_push($reply["info-for-headlines"], + array("id" => $id, "labels" => format_article_labels($labels, $id))); + + } + } + + $reply["message"] = "UPDATE_COUNTERS"; + + print json_encode($reply); + } + + } diff --git a/classes/rpc.php b/classes/rpc.php index de52a9e8c..a63392095 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -378,47 +378,6 @@ class RPC extends Handler_Protected { } } - function assigntolabel() { - return $this->labelops(true); - } - - function removefromlabel() { - return $this->labelops(false); - } - - function labelops($assign) { - $reply = array(); - - $ids = explode(",", db_escape_string($this->link, $_REQUEST["ids"])); - $label_id = db_escape_string($this->link, $_REQUEST["lid"]); - - $label = db_escape_string($this->link, label_find_caption($this->link, $label_id, - $_SESSION["uid"])); - - $reply["info-for-headlines"] = array(); - - if ($label) { - - foreach ($ids as $id) { - - if ($assign) - label_add_article($this->link, $id, $label, $_SESSION["uid"]); - else - label_remove_article($this->link, $id, $label, $_SESSION["uid"]); - - $labels = get_article_labels($this->link, $id, $_SESSION["uid"]); - - array_push($reply["info-for-headlines"], - array("id" => $id, "labels" => format_article_labels($labels, $id))); - - } - } - - $reply["message"] = "UPDATE_COUNTERS"; - - print json_encode($reply); - } - function updateFeedBrowser() { $search = db_escape_string($this->link, $_REQUEST["search"]); $limit = db_escape_string($this->link, $_REQUEST["limit"]); diff --git a/js/viewfeed.js b/js/viewfeed.js index 31eff1b8a..48137a136 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -678,7 +678,7 @@ function selectionRemoveLabel(id, ids) { return; } - var query = "?op=rpc&method=removeFromLabel&ids=" + + var query = "?op=article&method=removeFromLabel&ids=" + param_escape(ids.toString()) + "&lid=" + param_escape(id); console.log(query); @@ -706,7 +706,7 @@ function selectionAssignLabel(id, ids) { return; } - var query = "?op=rpc&method=assignToLabel&ids=" + + var query = "?op=article&method=assignToLabel&ids=" + param_escape(ids.toString()) + "&lid=" + param_escape(id); console.log(query); -- cgit v1.2.3-54-g00ecf