From 874b7bf24a851c286b3dfdb99f55ba10248b1698 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 16 Dec 2014 00:36:41 +0300 Subject: [PATCH] Fix some more notices --- fof-db.php | 4 ++-- fof-main.php | 13 ++++++++----- prefs.php | 11 +++++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/fof-db.php b/fof-db.php index 4d97de4..7f568f4 100644 --- a/fof-db.php +++ b/fof-db.php @@ -531,7 +531,7 @@ function fof_db_set_feedprop($user_id, $feed_id, $prop, $value) { $chg = false; $prefs = fof_db_get_subscription_prefs($user_id, $feed_id); - if ($prefs[$prop] != $value) + if (empty($prefs[$prop]) ? $value : ($prefs[$prop] != $value)) { $prefs[$prop] = $value; $chg = true; @@ -550,7 +550,7 @@ function fof_db_untag_feed($user_id, $feed_id, $tag_id) fof_db_set_subscription_prefs($user_id, $feed_id, $prefs); fof_safe_query( "delete from it using $FOF_ITEM_TAG_TABLE it, $FOF_ITEM_TABLE i". - " where it.item_id=i.item_id and it.user_id=%d and it.tag_id=%d and i.feed_id=%d". + " where it.item_id=i.item_id and it.user_id=%d and it.tag_id=%d and i.feed_id=%d", $user_id, $tag_id, $feed_id ); } diff --git a/fof-main.php b/fof-main.php index 5fc55f8..0cb149a 100644 --- a/fof-main.php +++ b/fof-main.php @@ -669,14 +669,17 @@ function fof_apply_tags($item) { global $fof_subscription_to_tags; - if(!isset($fof_subscription_to_tags)) + if (!isset($fof_subscription_to_tags)) $fof_subscription_to_tags = fof_db_get_subscription_to_tags(); // add subscription tags - foreach((array)$fof_subscription_to_tags[$item['feed_id']] as $user_id => $tags) - if(is_array($tags)) - foreach($tags as $tag) - fof_db_tag_items($user_id, $tag, $item['item_id']); + if (!empty($fof_subscription_to_tags[$item['feed_id']])) + { + foreach ($fof_subscription_to_tags[$item['feed_id']] as $user_id => $tags) + if (is_array($tags)) + foreach($tags as $tag) + fof_db_tag_items($user_id, $tag, $item['item_id']); + } $filtered = array(); diff --git a/prefs.php b/prefs.php index e6488d2..6d9b5db 100644 --- a/prefs.php +++ b/prefs.php @@ -41,8 +41,11 @@ if (isset($_REQUEST['tagfeeds'])) $allow_prop = array('untag' => 1, 'tag' => 1, 'filter' => 1, 'title' => 1, 'hide' => 1, 'orighide' => 1); foreach ($_REQUEST as $k => $v) { - list($prop, $feed_id) = explode('_', $k); - if (!$allow_prop[$prop]) + $prop = explode('_', $k); + if (count($prop) < 2) + continue; + list($prop, $feed_id) = $prop; + if (empty($allow_prop[$prop])) continue; if (!($feed = fof_db_get_feed_by_id($feed_id))) continue; @@ -87,13 +90,13 @@ if (isset($_REQUEST['tagfeeds'])) } } // show item content by default - else if ($prop == 'hide' && $v && !$_POST['orighide_'.$feed_id]) + else if ($prop == 'hide' && $v && empty($_POST['orighide_'.$feed_id])) { if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'hide_content', true)) $message[] = 'Items of feed \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\' will be shown collapsed by default'; } // hide item content by default - else if ($prop == 'orighide' && $v && !$_POST['hide_'.$feed_id]) + else if ($prop == 'orighide' && $v && empty($_POST['hide_'.$feed_id])) { if (fof_db_set_feedprop(fof_current_user(), $feed_id, 'hide_content', false)) $message[] = 'Items of feed \''.htmlspecialchars($_REQUEST["title_$feed_id"]).'\' will be shown expanded by default';