</script>";
if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
-
-/* if (ENABLE_UPDATE_DAEMON) {
-
- if ($cid == 0) {
-
- db_query($link, "INSERT INTO ttrss_scheduled_updates
- (owner_uid, feed_id, entered) VALUES
- (".$_SESSION["uid"].", '$feed', NOW())");
- }
-
- } else {
- // fixme update_rss_feed...
- } */
-
- if ($cat_view) {
-
- if ($feed > 0) {
- $cat_qpart = "cat_id = '$feed'";
- } else {
- $cat_qpart = "cat_id IS NULL";
- }
-
- $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
- WHERE $cat_qpart AND owner_uid = " . $_SESSION["uid"]);
-
- while ($tmp_line = db_fetch_assoc($tmp_result)) {
- $feed_url = $tmp_line["feed_url"];
- update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON);
- }
-
- } else {
- $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
- WHERE id = '$feed'");
- $feed_url = db_fetch_result($tmp_result, 0, "feed_url");
- update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON);
- }
+ update_generic_feed($link, $feed, $cat_view);
}
if ($subop == "MarkAllRead") {
-
- if (preg_match("/^[0-9][0-9]*$/", $feed) != false && $feed >= 0) {
-
- if ($cat_view) {
-
- if ($feed > 0) {
- $cat_qpart = "cat_id = '$feed'";
- } else {
- $cat_qpart = "cat_id IS NULL";
- }
-
- $tmp_result = db_query($link, "SELECT id
- FROM ttrss_feeds WHERE $cat_qpart AND owner_uid = " .
- $_SESSION["uid"]);
-
- while ($tmp_line = db_fetch_assoc($tmp_result)) {
-
- $tmp_feed = $tmp_line["id"];
-
- db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE feed_id = '$tmp_feed' AND owner_uid = " . $_SESSION["uid"]);
- }
-
- } else if ($feed > 0) {
-
- $tmp_result = db_query($link, "SELECT id
- FROM ttrss_feeds WHERE parent_feed = '$feed'
- ORDER BY cat_id,title");
-
- $parent_ids = array();
-
- if (db_num_rows($tmp_result) > 0) {
- while ($p = db_fetch_assoc($tmp_result)) {
- array_push($parent_ids, "feed_id = " . $p["id"]);
- }
-
- $children_qpart = implode(" OR ", $parent_ids);
-
- db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE (feed_id = '$feed' OR $children_qpart)
- AND owner_uid = " . $_SESSION["uid"]);
-
- } else {
- db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
- }
-
- } else if ($feed < 0 && $feed > -10) { // special, like starred
-
- if ($feed == -1) {
- db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE marked = true AND owner_uid = ".$_SESSION["uid"]);
- }
-
- } else if ($feed < -10) { // label
-
- // TODO make this more efficient
-
- $label_id = -$feed - 11;
-
- $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
- WHERE id = '$label_id'");
-
- if ($tmp_result) {
- $sql_exp = db_fetch_result($tmp_result, 0, "sql_exp");
-
- db_query($link, "BEGIN");
-
- $tmp2_result = db_query($link,
- "SELECT
- int_id
- FROM
- ttrss_user_entries,ttrss_entries
- WHERE
- ref_id = id AND
- $sql_exp AND
- owner_uid = " . $_SESSION["uid"]);
-
- while ($tmp_line = db_fetch_assoc($tmp2_result)) {
- db_query($link, "UPDATE
- ttrss_user_entries
- SET
- unread = false, last_read = NOW()
- WHERE
- int_id = " . $tmp_line["int_id"]);
- }
-
- db_query($link, "COMMIT");
-
-/* db_query($link, "UPDATE ttrss_user_entries,ttrss_entries
- SET unread = false,last_read = NOW()
- WHERE $sql_exp
- AND ref_id = id
- AND owner_uid = ".$_SESSION["uid"]); */
- }
- }
- } else { // tag
- db_query($link, "BEGIN");
-
- $tag_name = db_escape_string($feed);
-
- $result = db_query($link, "SELECT post_int_id FROM ttrss_tags
- WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]);
-
- while ($line = db_fetch_assoc($result)) {
- db_query($link, "UPDATE ttrss_user_entries SET
- unread = false, last_read = NOW()
- WHERE int_id = " . $line["post_int_id"]);
- }
- db_query($link, "COMMIT");
- }
-
+ catchup_feed($link, $feed, $cat_view);
}
$search = db_escape_string($_GET["search"]);
}
}
+ function catchup_feed($link, $feed, $cat_view) {
+ if (preg_match("/^[0-9][0-9]*$/", $feed) != false && $feed >= 0) {
+
+ if ($cat_view) {
+
+ if ($feed > 0) {
+ $cat_qpart = "cat_id = '$feed'";
+ } else {
+ $cat_qpart = "cat_id IS NULL";
+ }
+
+ $tmp_result = db_query($link, "SELECT id
+ FROM ttrss_feeds WHERE $cat_qpart AND owner_uid = " .
+ $_SESSION["uid"]);
+
+ while ($tmp_line = db_fetch_assoc($tmp_result)) {
+
+ $tmp_feed = $tmp_line["id"];
+
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false,last_read = NOW()
+ WHERE feed_id = '$tmp_feed' AND owner_uid = " . $_SESSION["uid"]);
+ }
+
+ } else if ($feed > 0) {
+
+ $tmp_result = db_query($link, "SELECT id
+ FROM ttrss_feeds WHERE parent_feed = '$feed'
+ ORDER BY cat_id,title");
+
+ $parent_ids = array();
+
+ if (db_num_rows($tmp_result) > 0) {
+ while ($p = db_fetch_assoc($tmp_result)) {
+ array_push($parent_ids, "feed_id = " . $p["id"]);
+ }
+
+ $children_qpart = implode(" OR ", $parent_ids);
+
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false,last_read = NOW()
+ WHERE (feed_id = '$feed' OR $children_qpart)
+ AND owner_uid = " . $_SESSION["uid"]);
+
+ } else {
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false,last_read = NOW()
+ WHERE feed_id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
+ }
+
+ } else if ($feed < 0 && $feed > -10) { // special, like starred
+
+ if ($feed == -1) {
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false,last_read = NOW()
+ WHERE marked = true AND owner_uid = ".$_SESSION["uid"]);
+ }
+
+ } else if ($feed < -10) { // label
+
+ // TODO make this more efficient
+
+ $label_id = -$feed - 11;
+
+ $tmp_result = db_query($link, "SELECT sql_exp FROM ttrss_labels
+ WHERE id = '$label_id'");
+
+ if ($tmp_result) {
+ $sql_exp = db_fetch_result($tmp_result, 0, "sql_exp");
+
+ db_query($link, "BEGIN");
+
+ $tmp2_result = db_query($link,
+ "SELECT
+ int_id
+ FROM
+ ttrss_user_entries,ttrss_entries
+ WHERE
+ ref_id = id AND
+ $sql_exp AND
+ owner_uid = " . $_SESSION["uid"]);
+
+ while ($tmp_line = db_fetch_assoc($tmp2_result)) {
+ db_query($link, "UPDATE
+ ttrss_user_entries
+ SET
+ unread = false, last_read = NOW()
+ WHERE
+ int_id = " . $tmp_line["int_id"]);
+ }
+
+ db_query($link, "COMMIT");
+
+/* db_query($link, "UPDATE ttrss_user_entries,ttrss_entries
+ SET unread = false,last_read = NOW()
+ WHERE $sql_exp
+ AND ref_id = id
+ AND owner_uid = ".$_SESSION["uid"]); */
+ }
+ }
+ } else { // tag
+ db_query($link, "BEGIN");
+
+ $tag_name = db_escape_string($feed);
+
+ $result = db_query($link, "SELECT post_int_id FROM ttrss_tags
+ WHERE tag_name = '$tag_name' AND owner_uid = " . $_SESSION["uid"]);
+
+ while ($line = db_fetch_assoc($result)) {
+ db_query($link, "UPDATE ttrss_user_entries SET
+ unread = false, last_read = NOW()
+ WHERE int_id = " . $line["post_int_id"]);
+ }
+ db_query($link, "COMMIT");
+ }
+ }
+
+ function update_generic_feed($link, $feed, $cat_view) {
+ if ($cat_view) {
+
+ if ($feed > 0) {
+ $cat_qpart = "cat_id = '$feed'";
+ } else {
+ $cat_qpart = "cat_id IS NULL";
+ }
+
+ $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
+ WHERE $cat_qpart AND owner_uid = " . $_SESSION["uid"]);
+
+ while ($tmp_line = db_fetch_assoc($tmp_result)) {
+ $feed_url = $tmp_line["feed_url"];
+ update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON);
+ }
+
+ } else {
+ $tmp_result = db_query($link, "SELECT feed_url FROM ttrss_feeds
+ WHERE id = '$feed'");
+ $feed_url = db_fetch_result($tmp_result, 0, "feed_url");
+ update_rss_feed($link, $feed_url, $feed, ENABLE_UPDATE_DAEMON);
+ }
+ }
+
?>