summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-02 14:56:08 +0400
committerAndrew Dolgov <[email protected]>2013-04-02 14:56:08 +0400
commit4b7726f0b44db36ad12c0a0918a9129c8cbb1caa (patch)
treee94ea124de84bab61a06a6c9e3120575539e7ca8
parent9c96a3e28cb360fc79d1e58f4871ce47ad55333e (diff)
rpc: move labelops to article
-rw-r--r--classes/article.php42
-rw-r--r--classes/rpc.php41
-rw-r--r--js/viewfeed.js4
3 files changed, 44 insertions, 43 deletions
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 "</ul>";
}
+ 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);