]> git.wh0rd.org - tt-rss.git/blobdiff - classes/article.php
use hashed guids in a hopefully backwards compatible fashion
[tt-rss.git] / classes / article.php
index bf1e5566208b3ffcfb73b43293fa21563a52edde..f31a225d1da39731a1495cf7a296769555e27412 100644 (file)
@@ -88,7 +88,7 @@ class Article extends Handler_Protected {
        static function create_published_article($link, $title, $url, $content, $labels_str,
                        $owner_uid) {
 
-               $guid = sha1($url . $owner_uid); // include owner_uid to prevent global GUID clash
+               $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash
                $content_hash = sha1($content);
 
                if ($labels_str != "") {
@@ -284,4 +284,63 @@ 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 "<ul>";
+               while ($line = db_fetch_assoc($result)) {
+                       print "<li>" . $line["tag_name"] . "</li>";
+               }
+               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);
+       }
+
+
+
 }