search: add support for label:XXX search keyword
Labels: enforce case-insensitive lookups when creating/looking for labels
This commit is contained in:
parent
586ed55178
commit
44b1f0fcc0
|
@ -2267,6 +2267,24 @@ class Feeds extends Handler_Protected {
|
||||||
if (!$not) array_push($search_words, $k);
|
if (!$not) array_push($search_words, $k);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "label":
|
||||||
|
if ($commandpair[1]) {
|
||||||
|
$label_id = Labels::find_id($commandpair[1], $_SESSION["uid"]);
|
||||||
|
|
||||||
|
if ($label_id) {
|
||||||
|
array_push($query_keywords, "($not
|
||||||
|
(ttrss_entries.id IN (
|
||||||
|
SELECT article_id FROM ttrss_user_labels2 WHERE
|
||||||
|
label_id = ".$pdo->quote($label_id).")))");
|
||||||
|
} else {
|
||||||
|
array_push($query_keywords, "(false)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").")
|
||||||
|
OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))");
|
||||||
|
if (!$not) array_push($search_words, $k);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "unread":
|
case "unread":
|
||||||
if ($commandpair[1]) {
|
if ($commandpair[1]) {
|
||||||
if ($commandpair[1] == "true")
|
if ($commandpair[1] == "true")
|
||||||
|
@ -2323,7 +2341,10 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($query_keywords) > 0)
|
||||||
$search_query_part = implode("AND", $query_keywords);
|
$search_query_part = implode("AND", $query_keywords);
|
||||||
|
else
|
||||||
|
$search_query_part = "false";
|
||||||
|
|
||||||
return array($search_query_part, $search_words);
|
return array($search_query_part, $search_words);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Labels
|
||||||
static function find_id($label, $owner_uid) {
|
static function find_id($label, $owner_uid) {
|
||||||
$pdo = Db::pdo();
|
$pdo = Db::pdo();
|
||||||
|
|
||||||
$sth = $pdo->prepare("SELECT id FROM ttrss_labels2 WHERE caption = ?
|
$sth = $pdo->prepare("SELECT id FROM ttrss_labels2 WHERE LOWER(caption) = LOWER(?)
|
||||||
AND owner_uid = ? LIMIT 1");
|
AND owner_uid = ? LIMIT 1");
|
||||||
$sth->execute([$label, $owner_uid]);
|
$sth->execute([$label, $owner_uid]);
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class Labels
|
||||||
}
|
}
|
||||||
|
|
||||||
$sth = $pdo->prepare("SELECT id FROM ttrss_labels2
|
$sth = $pdo->prepare("SELECT id FROM ttrss_labels2
|
||||||
WHERE caption = ? AND owner_uid = ?");
|
WHERE LOWER(caption) = LOWER(?) AND owner_uid = ?");
|
||||||
$sth->execute([$caption, $owner_uid]);
|
$sth->execute([$caption, $owner_uid]);
|
||||||
|
|
||||||
if (!$sth->fetch()) {
|
if (!$sth->fetch()) {
|
||||||
|
|
Loading…
Reference in New Issue