aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2001-06-05 21:15:19 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2001-06-05 21:15:19 +0000
commitba119166a1356601c9b8cc6520acb250be2c08a4 (patch)
tree5a78abbfde427d74c98e85b46773522a64b34427 /phpBB
parentc5ea123ae7dc5b6c1de2af850d152e98aa809f6b (diff)
downloadforums-ba119166a1356601c9b8cc6520acb250be2c08a4.tar
forums-ba119166a1356601c9b8cc6520acb250be2c08a4.tar.gz
forums-ba119166a1356601c9b8cc6520acb250be2c08a4.tar.bz2
forums-ba119166a1356601c9b8cc6520acb250be2c08a4.tar.xz
forums-ba119166a1356601c9b8cc6520acb250be2c08a4.zip
Demo topic tracking code ... commented out by default
git-svn-id: file:///svn/phpbb/trunk@431 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/index.php84
-rw-r--r--phpBB/viewforum.php65
-rw-r--r--phpBB/viewtopic.php95
3 files changed, 200 insertions, 44 deletions
diff --git a/phpBB/index.php b/phpBB/index.php
index e2db35a677..d94f167e01 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -48,6 +48,58 @@ if(empty($viewcat))
$viewcat = -1;
}
+
+/*
+//
+// This code allows for individual topic
+// read tracking, on small, low volume sites
+// it'll probably work very well. However, for
+// busy sites the use of a text field in the DB
+// combined with the additional UPDATE's required
+// in viewtopic may be unacceptable. So, by default
+// this code is off, however you may want to play
+// ... remember that the users table needs a
+// 'user_topics_unvisited' field of type TEXT ( or
+// equiv) and you need to remove the commented
+// out code above the folder_img code in the loop
+// below (this applies to viewforum too).
+//
+// psoTFX
+//
+if($userdata['user_id'] != ANONYMOUS)
+{
+ $unread_topic_list = unserialize($userdata['user_topics_unvisited']);
+
+ $last_update_time = (isset($unread_topic_list['lastupdate'])) ? $unread_topic_list['lastupdate'] : $userdata['session_last_visit'];
+
+ $sql = "SELECT forum_id, topic_id
+ FROM " . TOPICS_TABLE . "
+ WHERE topic_time > $last_update_time";
+ if(!$s_topic_times = $db->sql_query($sql))
+ {
+ error_die(SQL_QUERY, "Could not query topic times.", __LINE__, __FILE__);
+ }
+
+ if($db->sql_numrows($s_topic_times))
+ {
+ while($new_topics_ary = $db->sql_fetchrow($s_topic_times))
+ {
+ $unread_topic_list[$new_topics_ary['forum_id']][$new_topics_ary['topic_id']] = 1;
+ }
+
+ $unread_topic_list['lastupdate'] = time();
+
+ $sql = "UPDATE " . USERS_TABLE . "
+ SET user_topics_unvisited = '" . serialize($unread_topic_list) . "'
+ WHERE user_id = " . $userdata['user_id'];
+ if(!$s_topic_times = $db->sql_query($sql))
+ {
+ error_die(SQL_QUERY, "Could not update user topics list.", __LINE__, __FILE__);
+ }
+ }
+}
+*/
+
//
// Output page header and
// open the index body template
@@ -95,10 +147,11 @@ if($total_categories)
case 'postgresql':
$limit_forums = ($viewcat != -1) ? "AND f.cat_id = $viewcat " : "";
$sql = "SELECT f.*, t.topic_id, t.topic_replies, t.topic_last_post_id, u.username, u.user_id, p.post_time
- FROM ".FORUMS_TABLE." f, ".TOPICS_TABLE." t, ".POSTS_TABLE." p, ".USERS_TABLE." u
+ FROM ".FORUMS_TABLE." f, ".TOPICS_TABLE." t, ".POSTS_TABLE." p, ".USERS_TABLE." u, ".AUTH_FORUMS_TABLE." af
WHERE f.forum_last_post_id = p.post_id
AND p.post_id = t.topic_last_post_id
AND p.poster_id = u.user_id
+ AND af.forum_id = f.forum_id
$limit_forums
UNION (
SELECT f.*, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
@@ -116,10 +169,11 @@ if($total_categories)
case 'oracle':
$limit_forums = ($viewcat != -1) ? "AND f.cat_id = $viewcat " : "";
$sql = "SELECT f.*, t.topic_id, t.topic_replies, t.topic_last_post_id, u.username, u.user_id, p.post_time
- FROM ".FORUMS_TABLE." f, ".POSTS_TABLE." p, ".TOPICS_TABLE." t, ".USERS_TABLE." u
+ FROM ".FORUMS_TABLE." f, ".POSTS_TABLE." p, ".TOPICS_TABLE." t, ".USERS_TABLE." u, ".AUTH_FORUMS_TABLE." af
WHERE f.forum_last_post_id = p.post_id(+)
AND p.post_id = t.topic_last_post_id(+)
- AND p.poster_id = u.user_id(+)
+ AND p.poster_id = u.user_id(+)
+ AND af.forum_id = f.forum_id(+)
$limit_forums
ORDER BY f.cat_id, f.forum_order";
break;
@@ -209,15 +263,21 @@ if($total_categories)
if( ( ($forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $viewcat == -1) ||
($category_rows[$i]['cat_id'] == $viewcat) ) && $is_auth_ary[$forum_rows[$j]['forum_id']]['auth_view'])
{
-
- if($userdata['session_start'] == $userdata['session_time'])
- {
- $folder_image = ($forum_rows[$j]['post_time'] > $userdata['session_last_visit']) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
- }
- else
- {
- $folder_image = ($forum_rows[$j]['post_time'] > $userdata['session_time'] - 300) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
- }
+// if($userdata['user_id'] != ANONYMOUS)
+// {
+// $folder_image = (count($unread_topic_list[$forum_rows[$j]['forum_id']])) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
+// }
+// else
+// {
+ if($userdata['session_start'] == $userdata['session_time'])
+ {
+ $folder_image = ($forum_rows[$j]['post_time'] > $userdata['session_last_visit']) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
+ }
+ else
+ {
+ $folder_image = ($forum_rows[$j]['post_time'] > $userdata['session_time'] - 300) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
+ }
+// }
$posts = $forum_rows[$j]['forum_posts'];
$topics = $forum_rows[$j]['forum_topics'];
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index b07764614f..b2d3025422 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -249,10 +249,50 @@ $template->assign_vars(array(
if($total_topics)
{
$topic_rowset = $db->sql_fetchrowset($t_result);
+/*
+ //
+ // This code allows for individual topic
+ // read tracking, on small, low volume sites
+ // it'll probably work very well. However, for
+ // busy sites the use of a text field in the DB
+ // combined with the additional UPDATE's required
+ // in viewtopic may be unacceptable. So, by default
+ // this code is off, however you may want to play
+ // ...
+ //
+ // psoTFX
+ //
+ if($userdata['user_id'] != ANONYMOUS)
+ {
+ $unread_topic_list = unserialize($userdata['user_topics_unvisited']);
+
+ $last_update_time = (isset($unread_topic_list['lastupdate'])) ? $unread_topic_list['lastupdate'] : $userdata['session_last_visit'];
+
+ for($x = 0; $x < $total_topics; $x++)
+ {
+ if($topic_rowset[$x]['topic_time'] > $last_update_time)
+ {
+ $unread_topic_list[$forum_id][$topic_rowset[$x]['topic_id']] = 1;
+ }
+ }
+
+ $unread_topic_list['lastupdate'] = time();
+
+ $sql = "UPDATE " . USERS_TABLE . "
+ SET user_topics_unvisited = '" . serialize($unread_topic_list) . "'
+ WHERE user_id = " . $userdata['user_id'];
+ if(!$s_topic_times = $db->sql_query($sql))
+ {
+ error_die(SQL_QUERY, "Could not update user topics list.", __LINE__, __FILE__);
+ }
+ }
+*/
+
for($x = 0; $x < $total_topics; $x++)
{
$topic_title = stripslashes($topic_rowset[$x]['topic_title']);
$topic_id = $topic_rowset[$x]['topic_id'];
+
$replies = $topic_rowset[$x]['topic_replies'];
if($replies > $board_config['posts_per_page'])
{
@@ -284,15 +324,22 @@ if($total_topics)
$goto_page = "";
}
- if($userdata['session_start'] == $userdata['session_time'])
- {
- $folder_image = ($topic_rowset[$x]['post_time'] > $userdata['session_last_visit']) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
- }
- else
- {
- $folder_image = ($topic_rowset[$x]['post_time'] > $userdata['session_time'] - 300) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
- }
-
+// if($userdata['user_id'] != ANONYMOUS)
+// {
+// $folder_image = (isset($unread_topic_list[$forum_id][$topic_id])) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
+// }
+// else
+// {
+ if($userdata['session_start'] == $userdata['session_time'])
+ {
+ $folder_image = ($topic_rowset[$x]['post_time'] > $userdata['session_last_visit']) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
+ }
+ else
+ {
+ $folder_image = ($topic_rowset[$x]['post_time'] > $userdata['session_time'] - 300) ? "<img src=\"".$images['new_folder']."\">" : "<img src=\"".$images['folder']."\">";
+ }
+// }
+
$view_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&".$replies);
$topic_poster = stripslashes($topic_rowset[$x]['username']);
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index aa9f9ca9d8..a35dafb6e8 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -139,6 +139,15 @@ else
$join_sql_table = (!isset($post_id)) ? "" : "".POSTS_TABLE." p, ".POSTS_TABLE." p2,";
$join_sql = (!isset($post_id)) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
$count_sql = (!isset($post_id)) ? "" : ", COUNT(p2.post_id) AS prev_posts";
+/*
+ $order_sql = (!isset($post_id)) ? "" : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_votecreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
+
+ $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_votecreate, f.auth_vote, f.auth_attachments" . $count_sql . "
+ FROM $join_sql_table ".TOPICS_TABLE." t, ".FORUMS_TABLE." f
+ WHERE $join_sql
+ AND f.forum_id = t.forum_id
+ $order_sql";
+*/
$order_sql = (!isset($post_id)) ? "" : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, fa.auth_view, fa.auth_read, fa.auth_post, fa.auth_reply, fa.auth_edit, fa.auth_delete, fa.auth_votecreate, fa.auth_vote ORDER BY p.post_id ASC";
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, f.forum_name, f.forum_id, fa.auth_view, fa.auth_read, fa.auth_post, fa.auth_reply, fa.auth_edit, fa.auth_delete, fa.auth_votecreate, fa.auth_vote" . $count_sql . "
@@ -148,6 +157,7 @@ else
AND fa.forum_id = f.forum_id
$order_sql";
+
// This closes out the opening braces above
// Needed for the view/next query
//}
@@ -240,6 +250,37 @@ if(!$is_auth['auth_view'] || !$is_auth['auth_view'])
// End auth check
//
+/*
+//
+// This code allows for individual topic
+// read tracking, on small, low volume sites
+// it'll probably work very well. However, for
+// busy sites the use of a text field in the DB
+// combined with the additional UPDATE's required
+// in viewtopic may be unacceptable. So, by default
+// this code is off, however you may want to play
+// ...
+//
+// psoTFX
+//
+if($userdata['user_id'] != ANONYMOUS)
+{
+ $unread_topic_list = unserialize($userdata['user_topics_unvisited']);
+
+ if(isset($unread_topic_list[$forum_id][$topic_id]))
+ {
+ unset($unread_topic_list[$forum_id][$topic_id]);
+
+ $sql = "UPDATE " . USERS_TABLE . "
+ SET user_topics_unvisited = '" . serialize($unread_topic_list) . "'
+ WHERE user_id = " . $userdata['user_id'];
+ if(!$s_topic_times = $db->sql_query($sql))
+ {
+ error_die(SQL_QUERY, "Could not update user topics list.", __LINE__, __FILE__);
+ }
+ }
+}
+*/
for($x = 0; $x < $total_rows; $x++)
{
@@ -376,36 +417,29 @@ for($x = 0; $x < $total_posts; $x++)
$poster_posts = $postrow[$x]['user_posts'];
$poster_from = ($postrow[$x]['user_from']) ? "$l_from: ".$postrow[$x]['user_from'] : "";
$poster_joined = create_date($board_config['default_dateformat'], $postrow[$x]['user_regdate'], $board_config['default_timezone']);
- $poster_avatar = ($postrow[$x]['user_avatar'] != "") ? "<img src=\"".$board_config['avatar_path']."/".$postrow[$x]['user_avatar']."\">" : "";
- if($poster_id != ANONYMOUS && $poster_id != DELETED)
+ $poster_avatar = ($postrow[$x]['user_avatar'] != "" && $userdata['user_id'] != ANONYMOUS) ? "<img src=\"".$board_config['avatar_path']."/".$postrow[$x]['user_avatar']."\">" : "";
+ if(!$postrow[$x]['user_rank'])
{
- if(!$postrow[$x]['user_rank'])
+ for($i = 0; $i < count($ranksrow); $i++)
{
- for($i = 0; $i < count($ranksrow); $i++)
+ if($poster_posts > $ranksrow[$i]['rank_min'] && $poster_posts < $ranksrow[$i]['rank_max'])
{
- if($poster_posts > $ranksrow[$i]['rank_min'] && $poster_posts < $ranksrow[$i]['rank_max'])
- {
- $poster_rank = $ranksrow[$i]['rank_title'];
- $rank_image = ($ranksrow[$x]['rank_image']) ? "<img src=\"".$ranksrow[$x]['rank_image']."\">" : "";
- }
+ $poster_rank = $ranksrow[$i]['rank_title'];
+ $rank_image = ($ranksrow[$i]['rank_image']) ? "<img src=\"".$ranksrow[$i]['rank_image']."\">" : "";
}
}
- else
+ }
+ else
+ {
+ for($i = 0; $i < count($ranksrow); $i++)
{
- for($i = 0; $i < count($ranksrow); $i++)
+ if($postrow[$x]['user_rank'] == $ranksrow[$i]['rank_special'])
{
- if($postrow[$x]['user_rank'] == $ranksrow[$i]['rank_special'])
- {
- $poster_rank = $ranksrow[$i]['rank_title'];
- $rank_image = ($ranksrow[$x]['rank_image']) ? "<img src=\"".$ranksrow[$x]['rank_image']."\">" : "";
- }
+ $poster_rank = $ranksrow[$i]['rank_title'];
+ $rank_image = ($ranksrow[$i]['rank_image']) ? "<img src=\"".$ranksrow[$i]['rank_image']."\">" : "";
}
}
}
- else
- {
- $poster_rank = "";
- }
$profile_img = "<a href=\"".append_sid("profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=$poster_id")."\"><img src=\"".$images['profile']."\" alt=\"$l_profileof $poster\" border=\"0\"></a>";
$email_img = ($postrow[$x]['user_viewemail'] == 1) ? "<a href=\"mailto:".$postrow[$x]['user_email']."\"><img src=\"".$images['email']."\" alt=\"$l_email $poster\" border=\"0\"></a>" : "";
@@ -423,7 +457,7 @@ for($x = 0; $x < $total_posts; $x++)
}
$aim_img = ($postrow[$x]['user_aim']) ? "<a href=\"aim:goim?screenname=".$postrow[$x]['user_aim']."&message=Hello+Are+you+there?\"><img src=\"".$images['aim']."\" border=\"0\"></a>" : "";
- $msn_img = ($postrow[$x]['user_msnm']) ? "<a href=\"profile.$phpEx?mode=viewprofile&user_id=$poster_id\"><img src=\"".$images['msn']."\" border=\"0\"></a>" : "";
+ $msn_img = ($postrow[$x]['user_msnm']) ? "<a href=\"profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=$poster_id\"><img src=\"".$images['msn']."\" border=\"0\"></a>" : "";
$yim_img = ($postrow[$x]['user_yim']) ? "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=".$postrow[$x]['user_yim']."&.src=pg\"><img src=\"".$images['yim']."\" border=\"0\"></a>" : "";
$edit_img = "<a href=\"".append_sid("posting.$phpEx?mode=editpost&".POST_POST_URL."=".$postrow[$x]['post_id']."&".POST_TOPIC_URL."=$topic_id&".POST_FORUM_URL."=$forum_id")."\"><img src=\"".$images['edit']."\" alt=\"$l_editdelete\" border=\"0\"></a>";
@@ -432,7 +466,7 @@ for($x = 0; $x < $total_posts; $x++)
if($is_auth['auth_mod'])
{
- $ip_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=viewip&user_id=".$poster_id)."\"><img src=\"".$images['ip']."\" alt=\"$l_viewip\" border=\"0\"></a>";
+ $ip_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=viewip&".POST_USERS_URL."=".$poster_id)."\"><img src=\"".$images['ip']."\" alt=\"$l_viewip\" border=\"0\"></a>";
$delpost_img = "<a href=\"".append_sid("topicadmin.$phpEx?mode=delpost&".POST_POST_URL."=".$postrow[$x]['post_id'])."\"><img src=\"".$images['delpost']."\" alt=\"$l_delete\" border=\"0\"></a>";
}
@@ -525,12 +559,27 @@ $s_auth_can .= "You " . (($is_auth['auth_delete']) ? "<b>can</b>" : "<b>cannot</
$s_auth_can .= ($is_auth['auth_mod']) ? "You are a moderator of this forum<br>" : "";
$s_auth_can .= ($userdata['user_level'] == ADMIN) ? "You are a board admin<br>" : "";
+if($is_auth['auth_mod'])
+{
+ $topic_mod = "<a href=\"topicadmin.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=delete\"><img src=\"images/topic_delete.gif\" border=\"0\"></a>&nbsp;&nbsp;";
+ $topic_mod .= "<a href=\"topicadmin.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=move\"><img src=\"images/topic_move.gif\" border=\"0\"></a>&nbsp;&nbsp;";
+ if($forum_row[0]['topic_status'] == UNLOCKED)
+ {
+ $topic_mod .= "<a href=\"topicadmin.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=lock\"><img src=\"images/topic_lock.gif\" border=\"0\"></a>&nbsp;&nbsp;";
+ }
+ else
+ {
+ $topic_mod .= "<a href=\"topicadmin.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=unlock\"><img src=\"images/topic_unlock.gif\" border=\"0\"></a>&nbsp;&nbsp;";
+ }
+}
+
$template->assign_vars(array(
"PAGINATION" => generate_pagination("viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id", $total_replies, $board_config['posts_per_page'], $start),
"ON_PAGE" => (floor($start/$board_config['posts_per_page'])+1),
"TOTAL_PAGES" => ceil(($total_replies)/$board_config['posts_per_page']),
- "S_AUTH_LIST" => $s_auth_can,
+ "S_AUTH_LIST" => $s_auth_can,
+ "S_TOPIC_ADMIN" => $topic_mod,
"L_OF" => $lang['of'],
"L_PAGE" => $lang['Page'],