From: <ir...@us...> - 2012-10-22 07:38:29
|
Revision: 10230 http://sourceforge.net/p/xoops/svn/10230 Author: irmtfan Date: 2012-10-22 07:38:25 +0000 (Mon, 22 Oct 2012) Log Message: ----------- bug fix: viewpost.php?status=new AND viewforum.php?forum=FFF&status=unread and list.topic.php?status=unread when read_mode = 1 (cookie) improve: read_mode = 1 for anon Modified Paths: -------------- XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt XoopsModules/newbb/branches/irmtfan/newbb/class/forum.php XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php XoopsModules/newbb/branches/irmtfan/newbb/include/functions.ini.php XoopsModules/newbb/branches/irmtfan/newbb/include/plugin.php XoopsModules/newbb/branches/irmtfan/newbb/index.php XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_index.html XoopsModules/newbb/branches/irmtfan/newbb/templates_fulldiv_opacity/newbb_index.html XoopsModules/newbb/branches/irmtfan/newbb/viewpost.php Modified: XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt 2012-10-22 07:38:25 UTC (rev 10230) @@ -1,3 +1,14 @@ +date 2012-10-22 +=================================== +1- bug fix: viewpost.php?status=new AND viewforum.php?forum=FFF&status=unread and list.topic.php?status=unread when read_mode = 1 (cookie) +in newbb/viewpost.php, newbb/class/forum.php, newbb/class/topic.renderer.php + +2- improve: change the read_mode = 2 (db) to read_mode = 1 (cookie) for anonymous users +in newbb/include/functions.ini.php, newbb/include/plugin.php + +3- minor bug fix: <{$lastvisit}> smarty variable is added for all users (members and anons) it was wrongly only for members +in newbb/index.php, newbb/templates/newbb_index.html, newbb/templates_fulldiv_opacity/newbb_index.html + date 2012-10-20 =================================== 1- bug fix: wrongly do not count sub forum posts/topics when count_subforum = 1 Modified: XoopsModules/newbb/branches/irmtfan/newbb/class/forum.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/class/forum.php 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/class/forum.php 2012-10-22 07:38:25 UTC (rev 10230) @@ -221,22 +221,25 @@ } // END irmtfan use read_uid to find the unread posts when the user is logged in } elseif ($xoopsModuleConfig["read_mode"] == 1) { - $topics = array(); - $topic_lastread = newbb_getcookie('LT', true); - if (count($topic_lastread)>0) { - foreach ($topic_lastread as $id => $time) { - if ($time > $time_criterion) $topics[] = $id; - } - } - if (count($topics)>0) { - $criteria_extra = ' AND t.topic_id NOT IN (' . implode(",", $topics) . ')'; - } - if ($lastvisit = max($GLOBALS['last_visit'], $startdate)) { - $criteria_post = ' p.post_time > ' . max($GLOBALS['last_visit'], $startdate); - } + // START irmtfan fix read_mode = 1 bugs + if ( $time_criterion = max($GLOBALS['last_visit'], $startdate) ) { + $criteria_post = ' p.post_time > ' . $time_criterion; // for all users + if (is_object($GLOBALS["xoopsUser"])) { // only for members + $topics = array(); + $topic_lastread = newbb_getcookie('LT', true); + if (count($topic_lastread)>0) { + foreach ($topic_lastread as $id => $time) { + if ($time > $time_criterion) $topics[] = $id; + } + } + if (count($topics)>0) { + $criteria_extra = ' AND t.topic_id NOT IN (' . implode(",", $topics) . ')'; + } + } + } + // END irmtfan fix read_mode = 1 bugs } break; - case 'pending': $post_on = ' p.topic_id = t.topic_id'; $criteria_post .= ' AND p.pid = 0'; @@ -495,15 +498,23 @@ } // END irmtfan use read_uid to find the unread posts when the user is logged in } elseif ($xoopsModuleConfig["read_mode"] == 1) { - $criteria_post = ' p.post_time > ' . max($GLOBALS['last_visit'], $startdate); - $topics = array(); - $topic_lastread = newbb_getcookie('LT', true); - if (count($topic_lastread)>0) foreach ($topic_lastread as $id=>$time) { - if ($time > $time_criterion) $topics[] = $id; - } - if (count($topics)>0) { - $criteria_extra = ' AND t.topic_id NOT IN (' . implode(",", $topics) . ')'; - } + // START irmtfan fix read_mode = 1 bugs + if ( $time_criterion = max($GLOBALS['last_visit'], $startdate) ) { + $criteria_post = ' p.post_time > ' . $time_criterion; // for all users + if (is_object($GLOBALS["xoopsUser"])) { // only for members + $topics = array(); + $topic_lastread = newbb_getcookie('LT', true); + if (count($topic_lastread)>0) { + foreach ($topic_lastread as $id => $time) { + if ($time > $time_criterion) $topics[] = $id; + } + } + if (count($topics)>0) { + $criteria_extra = ' AND t.topic_id NOT IN (' . implode(",", $topics) . ')'; + } + } + } + // END irmtfan fix read_mode = 1 bugs } break; case 'pending': Modified: XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php 2012-10-22 07:38:25 UTC (rev 10230) @@ -171,9 +171,26 @@ // END irmtfan change criteria to get from uid p.uid = last post submit user id // User cookie } elseif ($this->config["read_mode"] == 1) { - if ($lastvisit =$GLOBALS['last_visit']) { - $this->query["where"][] = 'p.post_time > ' . $lastvisit; + // START irmtfan fix read_mode = 1 bugs + $startdate = !empty($this->vars["since"]) ? (time() - newbb_getSinceTime($this->vars["since"])) : 0; + if ( $lastvisit = max($GLOBALS['last_visit'], $startdate) ) { + if ( $lastvisit > $startdate ) { + $this->query["where"][] = 'p.post_time > ' . $lastvisit; + } + if (is_object($GLOBALS["xoopsUser"])) { // only for members + $topics = array(); + $topic_lastread = newbb_getcookie('LT', true); + if (count($topic_lastread)>0) { + foreach ($topic_lastread as $id => $time) { + if ($time > $lastvisit) $topics[] = $id; + } + } + if (count($topics)>0) { + $this->query["where"][] = ' t.topic_id NOT IN (' . implode(",", $topics) . ')'; + } + } } + // END irmtfan fix read_mode = 1 bugs } break; @@ -238,8 +255,13 @@ case "since": if (!empty($val)) { + // START irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query + $startdate = time() - newbb_getSinceTime($val); + if ( $this->vars["status"] == "unread" && $this->config["read_mode"] == 1 && $GLOBALS['last_visit'] > $startdate ) + break; // irmtfan - should be >= instead of = - $this->query["where"][] = "p.post_time >= ". (time() - newbb_getSinceTime($val)); + $this->query["where"][] = "p.post_time >= ". $startdate; + // START irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query } break; Modified: XoopsModules/newbb/branches/irmtfan/newbb/include/functions.ini.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/include/functions.ini.php 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/include/functions.ini.php 2012-10-22 07:38:25 UTC (rev 10230) @@ -50,6 +50,10 @@ load_functions("config"); $moduleConfig = mod_loadConfig("newbb"); + // irmtfan - change the read_mode = 2 (db) to read_mode = 1 (cookie) for anonymous users + if (!is_object($GLOBALS["xoopsUser"]) && $moduleConfig["read_mode_db_to_cookie_for_anon"] && 2 == $moduleConfig["read_mode"]) { + $moduleConfig["read_mode"] = 1; + } return $moduleConfig; } Modified: XoopsModules/newbb/branches/irmtfan/newbb/include/plugin.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/include/plugin.php 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/include/plugin.php 2012-10-22 07:38:25 UTC (rev 10230) @@ -98,6 +98,9 @@ $customConfig["jump_to_topic_last_post_read_enabled"] = true; // highlight keywords in search $customConfig["highlight_search_enable"] = true; +// change the read_mode = 2 (db) to read_mode = 1 (cookie) for anonymous users +// Note: if set to true only change read_mode for anonymous users if read_mode = 2 (db), set to false to no action. +$customConfig["read_mode_db_to_cookie_for_anon"] = true; // END hacked by irmtfan return $customConfig; Modified: XoopsModules/newbb/branches/irmtfan/newbb/index.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/index.php 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/index.php 2012-10-22 07:38:25 UTC (rev 10230) @@ -215,12 +215,14 @@ $userstats["topics"] = sprintf(_MD_USER_TOPICS, intval( @$userstats_row["user_topics"] )); $userstats["posts"] = sprintf(_MD_USER_POSTS, intval( @$userstats_row["user_posts"] )); $userstats["digests"] = sprintf(_MD_USER_DIGESTS, intval( @$userstats_row["user_digests"] )); - $userstats["currenttime"] = sprintf(_MD_TIMENOW, formatTimestamp(time(), "s")); - $userstats["lastvisit"] = sprintf(_MD_USER_LASTVISIT, formatTimestamp($last_visit, "s")); + $userstats["currenttime"] = sprintf(_MD_TIMENOW, formatTimestamp(time(), "s")); // irmtfan should be removed because it is for anon users too + $userstats["lastvisit"] = sprintf(_MD_USER_LASTVISIT, formatTimestamp($last_visit, "s")); // irmtfan should be removed because it is for anon users too $userstats["lastpost"] = empty($userstats_row["user_lastpost"]) ? _MD_USER_NOLASTPOST : sprintf(_MD_USER_LASTPOST, formatTimestamp($userstats_row["user_lastpost"], "s")); } $xoopsTpl->assign_by_ref("userstats", $userstats); - $xoopsTpl->assign('currenttime', sprintf(_MD_TIMENOW, formatTimestamp(time(), "m"))); + // irmtfan add lastvisit smarty variable for all users + $xoopsTpl->assign('lastvisit', sprintf(_MD_USER_LASTVISIT, formatTimestamp($last_visit, "l"))); + $xoopsTpl->assign('currenttime', sprintf(_MD_TIMENOW, formatTimestamp(time(), "m")) ); } Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_index.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_index.html 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_index.html 2012-10-22 07:38:25 UTC (rev 10230) @@ -336,6 +336,8 @@ <div class="forum_stats odd" style="padding: 5px; line-height: 150%;"> <div class="forum_stats_left odd"> <{$currenttime}><br /> + <!-- irmtfan add lastvisit smarty variable for all users --> + <{$lastvisit}><br /> <{$smarty.const._MD_TOTALTOPICSC}> <strong><a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/list.topic.php" title="<{$smarty.const._MD_ALL}>"><{$stats[0].topic.total}></a></strong> | <{$smarty.const._MD_TOTALPOSTSC}><strong><a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/viewpost.php" title="<{$smarty.const._MD_ALLPOSTS}>"><{$stats[0].post.total}></a></strong> @@ -344,7 +346,8 @@ <{/if}> <{if $userstats}> <br /><br /> - <{$userstats.lastvisit}><br /><{$userstats.lastpost}> + <!-- irmtfan userstats.lastvisit should be removed because it is for anon users too --> + <{*$userstats.lastvisit*}><br /><{$userstats.lastpost}> <{/if}> </div> <div class="forum_stats_right odd"> Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates_fulldiv_opacity/newbb_index.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates_fulldiv_opacity/newbb_index.html 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates_fulldiv_opacity/newbb_index.html 2012-10-22 07:38:25 UTC (rev 10230) @@ -216,6 +216,7 @@ <div class="index_stat_foot forum_stats odd"> <div class="forum_stats_col odd left floatleft"> <{$currenttime}><br /> + <{$lastvisit}><br /> <{$smarty.const._MD_TOTALTOPICSC}> <strong><a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/list.topic.php" title="<{$smarty.const._MD_ALL}>"><{$stats[0].topic.total}></a></strong> | <{$smarty.const._MD_TOTALPOSTSC}><strong><a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/viewpost.php" title="<{$smarty.const._MD_ALLPOSTS}>"><{$stats[0].post.total}></a></strong> @@ -224,7 +225,7 @@ <{/if}> <{if $userstats}> <br /><br /> - <{$userstats.lastvisit}><br /><{$userstats.lastpost}> + <{*$userstats.lastvisit*}><br /><{$userstats.lastpost}> <{/if}> </div> <div class="forum_stats_col odd right floatright"> Modified: XoopsModules/newbb/branches/irmtfan/newbb/viewpost.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/viewpost.php 2012-10-20 11:50:14 UTC (rev 10229) +++ XoopsModules/newbb/branches/irmtfan/newbb/viewpost.php 2012-10-22 07:38:25 UTC (rev 10230) @@ -116,6 +116,21 @@ } elseif ($xoopsModuleConfig["read_mode"] == 1) { $criteria_count->add(new Criteria("post_time", intval($last_visit), ">")); // irmtfan add new criteria $criteria_post->add(new Criteria("p.post_time", intval($last_visit), ">")); // irmtfan add new criteria + // START irmtfan fix read_mode = 1 bugs + if (is_object($GLOBALS["xoopsUser"])) { // only for members + $topics = array(); + $topic_lastread = newbb_getcookie('LT', true); + if (count($topic_lastread)>0) { + foreach ($topic_lastread as $id => $time) { + if ($time > intval($last_visit)) $topics[] = $id; + } + } + if (count($topics)>0) { + $criteria_count->add(new Criteria("topic_id", "(".implode(",",$topics).")", "NOT IN")); + $criteria_post->add(new Criteria("p.topic_id", "(".implode(",",$topics).")", "NOT IN")); + } + } + // END irmtfan fix read_mode = 1 bugs //$criteria_status_count->add(new Criteria("approved", 1));// irmtfan commented and removed //$criteria_status_post->add(new Criteria("p.approved", 1));// irmtfan commented and removed } |