]> git.wh0rd.org - tt-rss.git/commitdiff
rpc: move setArticleTags to article
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 2 Apr 2013 10:52:21 +0000 (14:52 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 2 Apr 2013 10:52:21 +0000 (14:52 +0400)
classes/article.php
classes/rpc.php

index 6e42369366f34017263955fe9bcaf2709f2888aa..bf1e5566208b3ffcfb73b43293fa21563a52edde 100644 (file)
@@ -185,7 +185,7 @@ class Article extends Handler_Protected {
                $tags_str = join(", ", $tags);
 
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$param\">";
-               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"article\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setArticleTags\">";
 
                print "<table width='100%'><tr><td>";
@@ -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 "<!-- $id : $int_id : $tag -->";
+
+                               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));
+       }
+
 }
index 3593bd5d8094242f7fe57fa7ea9e2f57e7216401..a78e079caf6934a057c3607c440e185f6bebb396 100644 (file)
@@ -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 "<!-- $id : $int_id : $tag -->";
-
-                               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"]);