]> git.wh0rd.org - tt-rss.git/blobdiff - plugins/auto_assign_labels/init.php
plugins/auto_assign_labels: use PDO
[tt-rss.git] / plugins / auto_assign_labels / init.php
index 36f7c32676f6fc58244ef7852f394350ed832de0..cc70e2dffea23a2ff934079f0c154af57e282966 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 class Auto_Assign_Labels extends Plugin {
 
+       /* @var PluginHost $host */
        private $host;
 
        function about() {
@@ -18,10 +19,11 @@ class Auto_Assign_Labels extends Plugin {
        function get_all_labels_filter_format($owner_uid) {
                $rv = array();
 
-               $result = db_query("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = " . $owner_uid);
+               $sth = $this->pdo->prepare("SELECT id, fg_color, bg_color, caption FROM ttrss_labels2 WHERE owner_uid = ?");
+               $sth->execute([$owner_uid]);
 
-               while ($line = db_fetch_assoc($result)) {
-                       array_push($rv, array(label_to_feed_id($line["id"]),
+               while ($line = $sth->fetch()) {
+                       array_push($rv, array(Labels::label_to_feed_id($line["id"]),
                                $line["caption"], $line["fg_color"], $line["bg_color"]));
                }
 
@@ -40,8 +42,7 @@ class Auto_Assign_Labels extends Plugin {
 
                        if ($caption && preg_match("/\b$caption\b/i", "$tags_str " . strip_tags($article["content"]) . " " . $article["title"])) {
 
-                               # defined in rssfuncs.php
-                               if (!labels_contains_caption($article["labels"], $caption)) {
+                               if (!RSSUtils::labels_contains_caption($article["labels"], $caption)) {
                                        array_push($article["labels"], $label);
                                }
                        }
@@ -53,5 +54,4 @@ class Auto_Assign_Labels extends Plugin {
        function api_version() {
                return 2;
        }
-}
-?>
+}
\ No newline at end of file