" .
truncate_string(strip_tags($line['title']), 15) . "
";
@@ -3396,14 +3216,14 @@
$rv['content'] .= "" . $line["title"] . "$entry_author
";
+ $rv['content'] .= "" . $line["title"] . "$entry_author
";
}
$tag_cache = $line["tag_cache"];
@@ -3438,15 +3258,10 @@
onclick=\"postOpenInNewTab(event, $id)\"
alt='Zoom' title='".__('Open article in new tab')."'>";
- $button_plugins = explode(",", ARTICLE_BUTTON_PLUGINS);
-
- foreach ($button_plugins as $p) {
- $pclass = trim("button_${p}");
+ global $pluginhost;
- if (class_exists($pclass)) {
- $plugin = new $pclass($link);
- $rv['content'] .= $plugin->render($id, $line);
- }
+ foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) {
+ $rv['content'] .= $p->hook_article_button($line);
}
$rv['content'] .= "".
"
" . __('Attachments')."";
$rv .= "
";
@@ -5063,72 +4943,79 @@
return $html;
}
- function filter_to_sql($filter) {
- $query = "";
+ function filter_to_sql($link, $filter, $owner_uid) {
+ $query = array();
- $regexp_valid = preg_match('/' . $filter['reg_exp'] . '/',
- $filter['reg_exp']) !== FALSE;
+ if (DB_TYPE == "pgsql")
+ $reg_qpart = "~";
+ else
+ $reg_qpart = "REGEXP";
- if ($regexp_valid) {
+ foreach ($filter["rules"] AS $rule) {
+ $regexp_valid = preg_match('/' . $rule['reg_exp'] . '/',
+ $rule['reg_exp']) !== FALSE;
- if (DB_TYPE == "pgsql")
- $reg_qpart = "~";
- else
- $reg_qpart = "REGEXP";
+ if ($regexp_valid) {
- switch ($filter["type"]) {
- case "title":
- $query = "LOWER(ttrss_entries.title) $reg_qpart LOWER('".
- $filter['reg_exp'] . "')";
- break;
- case "content":
- $query = "LOWER(ttrss_entries.content) $reg_qpart LOWER('".
- $filter['reg_exp'] . "')";
- break;
- case "both":
- $query = "LOWER(ttrss_entries.title) $reg_qpart LOWER('".
- $filter['reg_exp'] . "') OR LOWER(" .
- "ttrss_entries.content) $reg_qpart LOWER('" . $filter['reg_exp'] . "')";
- break;
- case "tag":
- $query = "LOWER(ttrss_user_entries.tag_cache) $reg_qpart LOWER('".
- $filter['reg_exp'] . "')";
- break;
- case "link":
- $query = "LOWER(ttrss_entries.link) $reg_qpart LOWER('".
- $filter['reg_exp'] . "')";
- break;
- case "date":
+ $rule['reg_exp'] = db_escape_string($rule['reg_exp']);
- if ($filter["filter_param"] == "before")
- $cmp_qpart = "<";
- else
- $cmp_qpart = ">=";
+ switch ($rule["type"]) {
+ case "title":
+ $qpart = "LOWER(ttrss_entries.title) $reg_qpart LOWER('".
+ $rule['reg_exp'] . "')";
+ break;
+ case "content":
+ $qpart = "LOWER(ttrss_entries.content) $reg_qpart LOWER('".
+ $rule['reg_exp'] . "')";
+ break;
+ case "both":
+ $qpart = "LOWER(ttrss_entries.title) $reg_qpart LOWER('".
+ $rule['reg_exp'] . "') OR LOWER(" .
+ "ttrss_entries.content) $reg_qpart LOWER('" . $rule['reg_exp'] . "')";
+ break;
+ case "tag":
+ $qpart = "LOWER(ttrss_user_entries.tag_cache) $reg_qpart LOWER('".
+ $rule['reg_exp'] . "')";
+ break;
+ case "link":
+ $qpart = "LOWER(ttrss_entries.link) $reg_qpart LOWER('".
+ $rule['reg_exp'] . "')";
+ break;
+ case "author":
+ $qpart = "LOWER(ttrss_entries.author) $reg_qpart LOWER('".
+ $rule['reg_exp'] . "')";
+ break;
+ }
- $timestamp = date("Y-m-d H:N:s", strtotime($filter["reg_exp"]));
- $query = "ttrss_entries.date_entered $cmp_qpart '$timestamp'";
- break;
- case "author":
- $query = "LOWER(ttrss_entries.author) $reg_qpart LOWER('".
- $filter['reg_exp'] . "')";
- break;
- }
+ if (isset($rule["feed_id"]) && $rule["feed_id"] > 0) {
+ $qpart .= " AND feed_id = " . db_escape_string($rule["feed_id"]);
+ }
- if ($filter["inverse"])
- $query = "NOT ($query)";
+ if (isset($rule["cat_id"])) {
- if ($query) {
- if (DB_TYPE == "pgsql") {
- $query = " ($query) AND ttrss_entries.date_entered > NOW() - INTERVAL '14 days'";
- } else {
- $query = " ($query) AND ttrss_entries.date_entered > DATE_SUB(NOW(), INTERVAL 14 DAY)";
+ if ($rule["cat_id"] > 0) {
+ $children = getChildCategories($link, $rule["cat_id"], $owner_uid);
+ array_push($children, $rule["cat_id"]);
+
+ $children = join(",", $children);
+
+ $cat_qpart = "cat_id IN ($children)";
+ } else {
+ $cat_qpart = "cat_id IS NULL";
+ }
+
+ $qpart .= " AND $cat_qpart";
}
- $query .= " AND ";
+
+ array_push($query, "($qpart)");
+
}
+ }
- return $query;
+ if (count($query) > 0) {
+ return "(" . join($filter["match_any_rule"] ? "OR" : "AND", $query) . ")";
} else {
- return false;
+ return "(false)";
}
}
@@ -5176,6 +5063,12 @@
if ($feeds) {
if ($feeds['error']) {
$status = $feeds['error']['code'] + 10;
+
+ // access denied
+ if ($status == 16) {
+ db_query($link, "DELETE FROM ttrss_linked_feeds
+ WHERE instance_id = '$id'");
+ }
} else {
$status = 1;
@@ -5585,4 +5478,106 @@
return $tempname;
}
+ function getFeedCategory($link, $feed) {
+ $result = db_query($link, "SELECT cat_id FROM ttrss_feeds
+ WHERE id = '$feed'");
+
+ if (db_num_rows($result) > 0) {
+ return db_fetch_result($result, 0, "cat_id");
+ } else {
+ return false;
+ }
+
+ }
+
+ 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
+ $content_hash = sha1($content);
+
+ if ($labels_str != "") {
+ $labels = explode(",", $labels_str);
+ } else {
+ $labels = array();
+ }
+
+ $rc = false;
+
+ if (!$title) $title = $url;
+ if (!$title && !$url) return false;
+
+ if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false;
+
+ db_query($link, "BEGIN");
+
+ // only check for our user data here, others might have shared this with different content etc
+ $result = db_query($link, "SELECT id FROM ttrss_entries, ttrss_user_entries WHERE
+ link = '$url' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1");
+
+ if (db_num_rows($result) != 0) {
+ $ref_id = db_fetch_result($result, 0, "id");
+
+ $result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE
+ ref_id = '$ref_id' AND owner_uid = '$owner_uid' LIMIT 1");
+
+ if (db_num_rows($result) != 0) {
+ $int_id = db_fetch_result($result, 0, "int_id");
+
+ db_query($link, "UPDATE ttrss_entries SET
+ content = '$content', content_hash = '$content_hash' WHERE id = '$ref_id'");
+
+ db_query($link, "UPDATE ttrss_user_entries SET published = true WHERE
+ int_id = '$int_id' AND owner_uid = '$owner_uid'");
+ } else {
+
+ db_query($link, "INSERT INTO ttrss_user_entries
+ (ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache, last_read, note, unread)
+ VALUES
+ ('$ref_id', '', NULL, NULL, $owner_uid, true, '', '', NOW(), '', false)");
+ }
+
+ if (count($labels) != 0) {
+ foreach ($labels as $label) {
+ label_add_article($link, $ref_id, trim($label), $owner_uid);
+ }
+ }
+
+ $rc = true;
+
+ } else {
+ $result = db_query($link, "INSERT INTO ttrss_entries
+ (title, guid, link, updated, content, content_hash, date_entered, date_updated)
+ VALUES
+ ('$title', '$guid', '$url', NOW(), '$content', '$content_hash', NOW(), NOW())");
+
+ $result = db_query($link, "SELECT id FROM ttrss_entries WHERE guid = '$guid'");
+
+ if (db_num_rows($result) != 0) {
+ $ref_id = db_fetch_result($result, 0, "id");
+
+ db_query($link, "INSERT INTO ttrss_user_entries
+ (ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache, last_read, note, unread)
+ VALUES
+ ('$ref_id', '', NULL, NULL, $owner_uid, true, '', '', NOW(), '', false)");
+
+ if (count($labels) != 0) {
+ foreach ($labels as $label) {
+ label_add_article($link, $ref_id, trim($label), $owner_uid);
+ }
+ }
+
+ $rc = true;
+ }
+ }
+
+ db_query($link, "COMMIT");
+
+ return $rc;
+ }
+
+ function implements_interface($class, $interface) {
+ return in_array($interface, class_implements($class));
+ }
+
?>