aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2002-08-22 13:58:35 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2002-08-22 13:58:35 +0000
commit69e89c90674ebcb530dd0f61a74d82cb3bf9f331 (patch)
tree1d4702555544385d1cf8fd901f98eaf075ba3b93
parent6cf59bc2e964c30ebc1af8feba9d18c6ed88ae88 (diff)
downloadforums-69e89c90674ebcb530dd0f61a74d82cb3bf9f331.tar
forums-69e89c90674ebcb530dd0f61a74d82cb3bf9f331.tar.gz
forums-69e89c90674ebcb530dd0f61a74d82cb3bf9f331.tar.bz2
forums-69e89c90674ebcb530dd0f61a74d82cb3bf9f331.tar.xz
forums-69e89c90674ebcb530dd0f61a74d82cb3bf9f331.zip
Forum/Topic marking updates
git-svn-id: file:///svn/phpbb/trunk@2879 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/index.php40
-rw-r--r--phpBB/viewforum.php154
-rw-r--r--phpBB/viewtopic.php28
3 files changed, 66 insertions, 156 deletions
diff --git a/phpBB/index.php b/phpBB/index.php
index 398596253a..aa1311fe1a 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -55,7 +55,7 @@ $session->configure($userdata);
//
if ( $mark_read == 'forums' )
{
- if ( $userdata['user_id'] != ANONYMOUS )
+ if ( $userdata['user_id'] )
{
setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
@@ -71,8 +71,8 @@ if ( $mark_read == 'forums' )
// End handle marking posts
//
-$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
-$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
+$mark_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t'])) : array();
+$mark_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f'])) : array();
//
// If you don't use these stats on your index you may want to consider
@@ -235,36 +235,22 @@ if ( ( $total_categories = count($category_rows) ) )
else
{
$unread_topics = false;
- if ( $userdata['user_id'] != ANONYMOUS )
+ if ( $userdata['user_id'] && $forum_data[$j]['forum_last_post_time'] > $userdata['user_lastvisit'] )
{
- if ( !empty($new_topic_data[$row_forum_id]) )
+ $unread_topics = true;
+ if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
- $forum_last_post_time = 0;
-
- foreach ( $new_topic_data[$row_forum_id] as $check_topic_id => $check_post_time )
+ if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_data[$j]['forum_last_post_time'] )
{
- if ( empty($tracking_topics[$check_topic_id]) || $tracking_topics[$check_topic_id] < $check_post_time)
- {
- $unread_topics = true;
- $forum_last_post_time = max($check_post_time, $forum_last_post_time);
-
- }
- }
-
- if ( !empty($tracking_forums[$row_forum_id]) )
- {
- if ( $tracking_forums[$row_forum_id] > $forum_last_post_time )
- {
- $unread_topics = false;
- }
+ $unread_topics = false;
}
+ }
- if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
+ if ( isset($mark_topics[$row_forum_id]) || isset($mark_forums[$row_forum_id]) )
+ {
+ if ( $mark_forums[$row_forum_id] > $userdata['user_lastvisit'] || !max($mark_topics[$row_forum_id]) )
{
- if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time )
- {
- $unread_topics = false;
- }
+ $unread_topics = false;
}
}
}
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 5f02634a0f..c48e008ceb 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -111,8 +111,8 @@ if ( !$acl->get_acl($forum_id, 'forum', 'read') )
//
// Topic read tracking cookie info
//
-$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : '';
-$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : '';
+$mark_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t'])) : array();
+$mark_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f'])) : array();
//
// Handle marking posts
@@ -121,26 +121,9 @@ if ( $mark_read == 'topics' )
{
if ( $userdata['user_id'] )
{
- $sql = "SELECT MAX(topic_last_post_time) AS last_post
- FROM " . TOPICS_TABLE . "
- WHERE forum_id = $forum_id";
- $result = $db->sql_query($sql);
+ $mark_forums[$forum_id] = time();
- if ( $row = $db->sql_fetchrow($result) )
- {
- if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
- {
- asort($tracking_forums);
- unset($tracking_forums[key($tracking_forums)]);
- }
-
- if ( $row['last_post'] > $userdata['user_lastvisit'] )
- {
- $tracking_forums[$forum_id] = time();
-
- setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
- }
- }
+ setcookie($board_config['cookie_name'] . '_f', serialize($mark_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . "viewforum.$phpEx$SID&amp;f=$forum_id" . '">')
@@ -337,6 +320,7 @@ if ( $start )
$topic_rowset[] = $row;
$total_topics++;
}
+ $db->sql_freeresult($result);
}
//
@@ -358,7 +342,6 @@ while( $row = $db->sql_fetchrow($result) )
$topic_rowset[] = $row;
$total_topics++;
}
-
$db->sql_freeresult($result);
//
@@ -366,16 +349,13 @@ $db->sql_freeresult($result);
//
if ( $total_topics )
{
- $row_count = 0;
-
for($i = 0; $i < $total_topics; $i++)
{
$topic_id = $topic_rowset[$i]['topic_id'];
- $topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
-
- $topic_type = $topic_rowset[$i]['topic_type'];
-
+ //
+ // Type and folder
+ //
$topic_type = '';
if ( $topic_rowset[$i]['topic_status'] == TOPIC_MOVED )
{
@@ -418,77 +398,36 @@ if ( $total_topics )
break;
}
- $newest_post_img = '';
- if ( $userdata['user_id'] != ANONYMOUS )
+ $unread_topic = false;
+ if ( $userdata['user_id'] && $topic_rowset[$i]['topic_last_post_time'] > $userdata['user_lastvisit'] )
{
- if ( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] )
+ $unread_topic = true;
+ if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
{
- if ( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
+ if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] > $topic_rowset[$i]['topic_last_post_time'] )
{
- $unread_topics = true;
-
- if ( !empty($tracking_topics[$topic_id]) )
- {
- if ( $tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time'] )
- {
- $unread_topics = false;
- }
- }
-
- if ( !empty($tracking_forums[$forum_id]) )
- {
- if ( $tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time'] )
- {
- $unread_topics = false;
- }
- }
-
- if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
- {
- if ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] >= $topic_rowset[$i]['post_time'] )
- {
- $unread_topics = false;
- }
- }
-
- if ( $unread_topics )
- {
- $folder_image = $folder_new;
- $folder_alt = $lang['New_posts'];
-
- $newest_post_img = '<a href="viewtopic.' . $phpEx . $SID . '&amp;t=' . $topic_id . '&amp;view=newest">' . create_img($theme['goto_post_newest'], $lang['View_newest_post']) . '</a> ';
- }
- else
- {
- $folder_image = $folder;
- $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
-
- $newest_post_img = '';
- }
+ $unread_topic = false;
}
- else
- {
- $folder_image = $folder_new;
- $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
+ }
- $newest_post_img = '<a href="viewtopic.' . $phpEx . $SID . '&amp;t=' . $topic_id . '&amp;view=newest">' . create_img($theme['goto_post_newest'], $lang['View_newest_post']) . '</a> ';
+ if ( isset($mark_topics[$forum_id]) || isset($mark_forums[$forum_id][$topic_id]) )
+ {
+ if ( $mark_forums[$forum_id] > $topic_rowset[$i]['topic_last_post_time'] || !$mark_topics[$forum_id][$topic_id] )
+ {
+ $unread_topic = false;
}
}
- else
- {
- $folder_image = $folder;
- $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
- $newest_post_img = '';
+ if ( !isset($mark_topics[$forum_id][$topic_id]) )
+ {
+ $mark_topics[$forum_id][$topic_id] = $topic_rowset[$i]['topic_last_post_time'];
}
}
- else
- {
- $folder_image = $folder;
- $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
- $newest_post_img = '';
- }
+ $newest_post_img = ( $unread_topic ) ? '<a href="viewtopic.' . $phpEx . $SID . '&amp;t=' . $topic_id . '&amp;view=newest">' . create_img($theme['goto_post_newest'], $lang['View_newest_post']) . '</a> ' : '';
+ $folder_img = ( $unread_topic ) ? $folder_new : $folder;
+ $folder_alt = ( $unread_topic ) ? $lang['New_posts'] : ( ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'] );
+
}
if ( $topic_rowset[$i]['topic_vote'] )
@@ -496,6 +435,9 @@ if ( $total_topics )
$topic_type .= $lang['Topic_Poll'] . ' ';
}
+ //
+ // Goto message
+ //
if ( ( $replies + 1 ) > $board_config['posts_per_page'] )
{
$total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
@@ -524,6 +466,9 @@ if ( $total_topics )
$goto_page = '';
}
+ //
+ // Generate all the URIs ...
+ //
$view_topic_url = 'viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;t=' . $topic_id;
$topic_author = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="profile.' . $phpEx . $SID . '&amp;mode=viewprofile&amp;u=' . $topic_rowset[$i]['user_id'] . '">' : '';
@@ -539,40 +484,39 @@ if ( $total_topics )
$last_post_url = '<a href="viewtopic.' . $phpEx . $SID . '&amp;p=' . $topic_rowset[$i]['topic_last_post_id'] . '#' . $topic_rowset[$i]['topic_last_post_id'] . '">' . create_img($theme['goto_post_latest'], $lang['View_latest_post']) . '</a>';
- $views = $topic_rowset[$i]['topic_views'];
- $replies = $topic_rowset[$i]['topic_replies'];
-
- $topic_icon = ( !empty($topic_rowset[$i]['icons_url']) ) ? '<img src="' . $board_config['icons_path'] . '/' . $topic_rowset[$i]['icons_url'] . '" width="' . $topic_rowset[$i]['icons_width'] . '" height="' . $topic_rowset[$i]['icons_height'] . '" alt="" title="" />' : '';
-
- $topic_rating = ( !empty($topic_rowset[$i]['topic_rating']) ) ? '<img src=' . str_replace('{RATE}', $topic_rowset[$i]['topic_rating'], $theme['rating']) . ' alt="' . $topic_rowset[$i]['topic_rating'] . '" title="' . $topic_rowset[$i]['topic_rating'] . '" />' : '';
-
+ //
+ // Send vars to template
+ //
$template->assign_block_vars('topicrow', array(
'FORUM_ID' => $forum_id,
'TOPIC_ID' => $topic_id,
- 'TOPIC_FOLDER_IMG' => create_img($folder_image, $folder_alt),
+ 'TOPIC_FOLDER_IMG' => create_img($folder_img, $folder_alt),
'TOPIC_AUTHOR' => $topic_author,
- 'GOTO_PAGE' => $goto_page,
- 'REPLIES' => $replies,
'NEWEST_POST_IMG' => $newest_post_img,
- 'TOPIC_TITLE' => $topic_title,
- 'TOPIC_TYPE' => $topic_type,
- 'TOPIC_ICON' => $topic_icon,
- 'TOPIC_RATING' => $topic_rating,
- 'VIEWS' => $views,
'FIRST_POST_TIME' => $first_post_time,
'LAST_POST_TIME' => $last_post_time,
'LAST_POST_AUTHOR' => $last_post_author,
'LAST_POST_IMG' => $last_post_url,
+ 'GOTO_PAGE' => $goto_page,
+ 'REPLIES' => $topic_rowset[$i]['topic_replies'],
+ 'VIEWS' => $topic_rowset[$i]['topic_views'],
+ 'TOPIC_TITLE' => ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'],
+ 'TOPIC_TYPE' => $topic_type,
+ 'TOPIC_ICON' => ( !empty($topic_rowset[$i]['icons_url']) ) ? '<img src="' . $board_config['icons_path'] . '/' . $topic_rowset[$i]['icons_url'] . '" width="' . $topic_rowset[$i]['icons_width'] . '" height="' . $topic_rowset[$i]['icons_height'] . '" alt="" title="" />' : '',
+ 'TOPIC_RATING' => ( !empty($topic_rowset[$i]['topic_rating']) ) ? '<img src=' . str_replace('{RATE}', $topic_rowset[$i]['topic_rating'], $theme['rating']) . ' alt="' . $topic_rowset[$i]['topic_rating'] . '" title="' . $topic_rowset[$i]['topic_rating'] . '" />' : '',
'S_ROW_COUNT' => $i,
'U_VIEW_TOPIC' => $view_topic_url)
);
-
- $row_count++;
}
}
+if ( $userdata['user_id'] )
+{
+ setcookie($board_config['cookie_name'] . '_t', serialize($mark_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
+}
+
//
// Dump out the page header and load viewforum template
//
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index ee7fd0413f..fdd337e760 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -370,33 +370,13 @@ $post_img = ( $forum_status == FORUM_LOCKED ) ? create_img($theme['post_locked']
//
// Set a cookie for this topic
//
-if ( $userdata['user_id'] != ANONYMOUS )
+if ( $userdata['user_id'] )
{
- $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
- $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
-
- if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) )
- {
- $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
- }
- else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) )
- {
- $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
- }
- else
- {
- $topic_last_read = $userdata['user_lastvisit'];
- }
-
- if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
- {
- asort($tracking_topics);
- unset($tracking_topics[key($tracking_topics)]);
- }
+ $mark_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t'])) : array();
- $tracking_topics[$topic_id] = time();
+ $mark_topics[$forum_id][$topic_id] = 0;
+ setcookie($board_config['cookie_name'] . '_t', serialize($mark_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
- setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}
//