From b67e31022cd316508ea0e42202f6e7673dab09d3 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 27 Feb 2015 22:17:16 +0300 Subject: [PATCH] fix one notice and fof_db_mark_feed_unread --- add-single.php | 10 ++++++---- fof-db.php | 10 ++++++++-- prefs.php | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/add-single.php b/add-single.php index ce98e1d..4ddc7de 100644 --- a/add-single.php +++ b/add-single.php @@ -14,15 +14,15 @@ include_once("fof-main.php"); -$url = $_REQUEST['url']; -$tags = $_REQUEST['tags']; -$unread = $_REQUEST['unread']; +$url = isset($_REQUEST['url']) ? $_REQUEST['url'] : ''; +$tags = isset($_REQUEST['tags']) ? $_REQUEST['tags'] : ''; +$unread = isset($_REQUEST['unread']) ? $_REQUEST['unread'] : ''; list($error, $feed) = fof_subscribe(fof_current_user(), $url, $unread); $error .= '
'; foreach (preg_split("/[\s,]*,[\s,]*/", $tags) as $tag) { - if ($tag) + if ($tag !== '') { fof_tag_feed(fof_current_user(), $feed['feed_id'], $tag); $error .= 'Tagged \''.htmlspecialchars($feed['feed_title']).'\' as '.htmlspecialchars($tag).'
'; @@ -30,9 +30,11 @@ foreach (preg_split("/[\s,]*,[\s,]*/", $tags) as $tag) } if (preg_match('/HTTP 401/', $error)) +{ print ""; +} print $error; diff --git a/fof-db.php b/fof-db.php index 93008a5..ff9cbf0 100644 --- a/fof-db.php +++ b/fof-db.php @@ -514,14 +514,20 @@ function fof_db_set_subscription_prefs($user_id, $feed_id, $prefs) // tag feed and all its items function fof_db_tag_feed($user_id, $feed_id, $tag_id) { - global $FOF_ITEM_TAG_TABLE, $FOF_ITEM_TABLE; $prefs = fof_db_get_subscription_prefs($user_id, $feed_id); if(!is_array($prefs['tags']) || !in_array($tag_id, $prefs['tags'])) $prefs['tags'][] = $tag_id; fof_db_set_subscription_prefs($user_id, $feed_id, $prefs); + fof_db_tag_feed_items($user_id, $feed_id, $tag_id); +} + +function fof_db_tag_feed_items($user_id, $feed_id, $tag_id, $since = 0) +{ + global $FOF_ITEM_TAG_TABLE, $FOF_ITEM_TABLE; fof_safe_query( "insert into $FOF_ITEM_TAG_TABLE (tag_id, user_id, item_id, item_published, feed_id)". " select %d, %d, item_id, item_published, feed_id from $FOF_ITEM_TABLE where feed_id=%d". + ($since ? " and item_published >= ".$since : ''). " on duplicate key update item_published=values(item_published)", $tag_id, $user_id, $feed_id ); @@ -713,7 +719,7 @@ function fof_db_mark_feed_read($user_id, $feed_id) function fof_db_mark_feed_unread($user_id, $feed_id, $what) { - fof_db_tag_feed($user_id, $feed_id, 1); + fof_db_tag_feed_items($user_id, $feed_id, 1, $what == 'today' ? mktime(0, 0, 0, date('n'), date('j'), date('Y')) : 0); } function fof_db_mark_item_unread($id, $except_users = array()) diff --git a/prefs.php b/prefs.php index 6d9b5db..b8c84d3 100644 --- a/prefs.php +++ b/prefs.php @@ -322,7 +322,7 @@ foreach($feeds as $row) - + /> | Filter