+ static function get_article_labels($id, $owner_uid = false) {
+ $rv = array();
+
+ if (!$owner_uid) $owner_uid = $_SESSION["uid"];
+
+ $pdo = Db::pdo();
+
+ $sth = $pdo->prepare("SELECT label_cache FROM
+ ttrss_user_entries WHERE ref_id = ? AND owner_uid = ?");
+ $sth->execute([$id, $owner_uid]);
+
+ if ($row = $sth->fetch()) {
+ $label_cache = $row["label_cache"];
+
+ if ($label_cache) {
+ $tmp = json_decode($label_cache, true);
+
+ if (!$tmp || $tmp["no-labels"] == 1)
+ return $rv;
+ else
+ return $tmp;
+ }
+ }
+
+ $sth = $pdo->prepare("SELECT DISTINCT label_id,caption,fg_color,bg_color
+ FROM ttrss_labels2, ttrss_user_labels2
+ WHERE id = label_id
+ AND article_id = ?
+ AND owner_uid = ?
+ ORDER BY caption");
+ $sth->execute([$id, $owner_uid]);
+
+ while ($line = $sth->fetch()) {
+ $rk = array(Labels::label_to_feed_id($line["label_id"]),
+ $line["caption"], $line["fg_color"],
+ $line["bg_color"]);
+ array_push($rv, $rk);
+ }
+
+ if (count($rv) > 0)
+ Labels::update_cache($owner_uid, $id, $rv);
+ else
+ Labels::update_cache($owner_uid, $id, array("no-labels" => 1));
+
+ return $rv;
+ }
+