From 61e1fedfc7a2224b69477a4797567a2ac5cfaa70 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Tue, 30 Apr 2024 03:42:10 -0700 Subject: [PATCH] Move checking user's subscription array to a function in overboard.php. --- Rocksolid_Light/rocksolid/overboard.php | 55 ++++++++++++++++--------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/Rocksolid_Light/rocksolid/overboard.php b/Rocksolid_Light/rocksolid/overboard.php index b8437a0..2fb1389 100644 --- a/Rocksolid_Light/rocksolid/overboard.php +++ b/Rocksolid_Light/rocksolid/overboard.php @@ -313,11 +313,8 @@ function display_threads($threads, $oldest) } // Skip if not in registered users sub list - $checkgroup = $target_head['newsgroup']; - if (! isset($userdata[$checkgroup])) { - if (isset($user_config['hide_unsub']) && $user_config['hide_unsub'] == 'hide') { - continue; - } + if (! check_group_for_user($target_head['newsgroup'], $userdata, $user_config)) { + continue; } // Check if only displaying new posts in section @@ -344,11 +341,8 @@ function display_threads($threads, $oldest) continue; } // Skip if not in registered users sub list - $checkgroup = $target['newsgroup']; - if (! isset($userdata[$checkgroup])) { - if (isset($user_config['hide_unsub']) && $user_config['hide_unsub'] == 'hide') { - continue; - } + if (! check_group_for_user($target['newsgroup'], $userdata, $user_config)) { + continue; } // Check if only displaying new posts in section if ($newonly) { @@ -377,10 +371,10 @@ function display_threads($threads, $oldest) $display .= '' . $target_head['newsgroup'] . ''; // Do better than !isset($value[$target_head['msgid']]) $timetest = $oldest; - if($newonly) { + if ($newonly) { $timetest = $userdata[$target_head['newsgroup']]; } - if((($target_head['date'] < $timetest) || $result_count > 10) && isset($target_head['date'])) { + if ((($target_head['date'] < $timetest) || $result_count > 10) && isset($target_head['date'])) { $poster = get_poster_name(mb_decode_mimeheader($target_head['name'])); $block = false; foreach ($blocked_user_config as $bkey => $bvalue) { @@ -493,14 +487,11 @@ function display_flat($threads, $oldest) $results = 0; foreach ($threads as $key => $value) { $target = $this_overboard['msgids'][$value]; - $checkgroup = $target['newsgroup']; if (! isset($target['msgid'])) { $target = get_data_from_msgid($value); } - if (! isset($userdata[$checkgroup])) { - if (isset($user_config['hide_unsub']) && $user_config['hide_unsub'] == 'hide') { - continue; - } + if (! check_group_for_user($target['newsgroup'], $userdata, $user_config)) { + continue; } if ($target['date'] < $oldest) { continue; @@ -631,15 +622,41 @@ function show_overboard_header($grouplist) } echo ''; echo ''; - + echo '
'; - + show_overboard_style_toggle(); echo '
'; echo ''; echo ''; } +// Return TRUE unless group is not subscribed by user +// It is assumed $newsgroups to check are verified to be in SECTION +function check_group_for_user($newsgroups, $userdata, $user_config) +{ + if(!is_array($userdata)) { + // No logged in user + return true; + } + $testgroup = preg_split("/\ |\,/", $newsgroups); + $ok = true; + foreach ($testgroup as $checkgroup) { + if (! isset($userdata[$checkgroup])) { + if (isset($user_config['hide_unsub']) && $user_config['hide_unsub'] == 'hide') { + $ok = false; + } else { + $ok = true; + break; + } + } else { + $ok = true; + break; + } + } + return $ok; +} + function show_overboard_style_toggle() { echo '
';