$q->setCTE("topmost(f_id,top)", "SELECT id,id from arsse_folders where owner = ? and parent is null union all select id,top from arsse_folders join topmost on parent=f_id", ["str"], [$user]);
$q->setCTE("topmost(f_id,top)", "SELECT id,id from arsse_folders where owner = ? and parent is null union all select id,top from arsse_folders join topmost on parent=f_id", ["str"], [$user]);
if ($id) {
if ($id) {
// this condition facilitates the implementation of subscriptionPropertiesGet, which would otherwise have to duplicate the complex query; it takes precedence over a specified folder
// if an ID is specified, add a suitable WHERE condition and bindings
// if an ID is specified, add a suitable WHERE condition and bindings
// this condition facilitates the implementation of subscriptionPropertiesGet, which would otherwise have to duplicate the complex query; it takes precedence over a specified folder
$q->setWhere("s.id = ?", "int", $id);
$q->setWhere("s.id = ?", "int", $id);
} elseif ($folder && $recursive) {
} elseif ($folder && $recursive) {
// if a folder is specified and we're listing recursively, add a common table expression to list it and its children so that we select from the entire subtree
// if a folder is specified and we're listing recursively, add a common table expression to list it and its children so that we select from the entire subtree
@ -1194,6 +1194,19 @@ class Database {
return $out;
return $out;
}
}
/** Retrieves the set of filters users have applied to a given feed
*
* Each record includes the following keys:
*
* - "owner": The user for whom to apply the filters
* - "sub": The subscription ID which ties the user to the feed
* - "keep": The "keep" rule; any articles which fail to match this rule are hidden
* - "block": The block rule; any article which matches this rule are hidden
*/
public function feedRulesGet(int $feedID): Db\Result {
return $this->db->prepare("SELECT owner, id as sub, keep_rule as keep, block_rule as block from arsse_subscriptions where feed = ? and (coalesce(keep_rule, '') || coalesce(block_rule, '')) <> ''", "int")->run($feedID);
}
/** Retrieves various identifiers for the latest $count articles in the given newsfeed. The identifiers are:
/** Retrieves various identifiers for the latest $count articles in the given newsfeed. The identifiers are:
*
*
* - "id": The database record key for the article
* - "id": The database record key for the article
@ -1652,6 +1665,7 @@ class Database {
*
*
* - "read": Whether the article should be marked as read (true) or unread (false)
* - "read": Whether the article should be marked as read (true) or unread (false)
* - "starred": Whether the article should (true) or should not (false) be marked as starred/favourite
* - "starred": Whether the article should (true) or should not (false) be marked as starred/favourite
* - "hidden": Whether the article should (true) or should not (false) be suppressed from normal listings; this is normally set by the system rather than the user directly
* - "note": A string containing a freeform plain-text note for the article
* - "note": A string containing a freeform plain-text note for the article
*
*
* @param string $user The user who owns the articles to be modified
* @param string $user The user who owns the articles to be modified
@ -1662,22 +1676,23 @@ class Database {
$data = [
$data = [
'read' => $data['read'] ?? null,
'read' => $data['read'] ?? null,
'starred' => $data['starred'] ?? null,
'starred' => $data['starred'] ?? null,
'hidden' => $data['hidden'] ?? null,
'note' => $data['note'] ?? null,
'note' => $data['note'] ?? null,
];
];
if (!isset($data['read']) && !isset($data['starred']) && !isset($data['note'])) {
if (!isset($data['read']) && !isset($data['starred']) && !isset($data['hidden']) && !isset($data['note'])) {
return 0;
return 0;
}
}
$context = $context ?? new Context;
$context = $context ?? new Context;
$tr = $this->begin();
$tr = $this->begin();
$out = 0;
$out = 0;
if ($data['read'] || $data['starred'] || strlen($data['note'] ?? "")) {
$q->setBody("UPDATE arsse_marks set touched = 1, $set where article in(select article from target_articles) and subscription in(select distinct subscription from target_articles)", $setTypes, $setValues);
$q->setBody("UPDATE arsse_marks set touched = 1, $set where article in(select article from target_articles) and subscription in(select distinct subscription from target_articles)", $setTypes, $setValues);
$q->setBody("UPDATE arsse_marks set $set, modified = CURRENT_TIMESTAMP where article in(select article from target_articles) and subscription in(select distinct subscription from target_articles)", $setTypes, $setValues);
$q->setBody("UPDATE arsse_marks set $set, modified = CURRENT_TIMESTAMP where article in(select article from target_articles) and subscription in(select distinct subscription from target_articles)", $setTypes, $setValues);