1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-18 14:48:28 +01:00

Initial Lastread support. Mind the schema and config changes\!

git-svn-id: file:///svn/phpbb/trunk@3102 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Bart van Bragt 2002-11-27 13:24:46 +00:00
parent 16e8fb800f
commit 831c9b5a61
11 changed files with 295 additions and 38 deletions

View File

@ -86,6 +86,10 @@ define('POST_NORMAL', 0);
define('POST_STICKY', 1);
define('POST_ANNOUNCE', 2);
// Lastread types
define('LASTREAD_NORMAL', 0); // not used at the moment
define('LASTREAD_POSTED', 1);
// Error codes
define('MESSAGE', 200);
define('ERROR', 201);
@ -109,6 +113,7 @@ define('FORUMS_TABLE', $table_prefix.'forums');
define('FORUMS_WATCH_TABLE', $table_prefix.'forums_watch');
define('GROUPS_TABLE', $table_prefix.'groups');
define('ICONS_TABLE', $table_prefix.'icons');
define('LASTREAD_TABLE', $table_prefix.'lastread');
define('LOG_ADMIN_TABLE', $table_prefix.'log_admin');
define('LOG_MOD_TABLE', $table_prefix.'log_moderator');
define('MODERATOR_TABLE', $table_prefix.'moderator_cache');
@ -196,4 +201,4 @@ function slash_input_data(&$data)
return $data;
}
?>
?>

View File

@ -0,0 +1,14 @@
<?php
$dbms = "mysql";
$dbhost = "localhost";
$dbname = "phpbb";
$dbuser = "phpbb";
$dbpasswd = "phpbb0wn$";
define("PHPBB_INSTALLED", true);
$table_prefix = "phpbb_";
define('DEBUG', 1);
?>

View File

@ -2,8 +2,171 @@
// phpBB cache file - DO NOT change anything in here by hand!
$config = array();
$config = array(
'board_disable' => 0,
'board_disable_msg' => "",
'sitename' => "2.2 @ 51",
'site_desc' => "The phpBB 2.2 test board",
'cookie_name' => "phpbb22",
'cookie_path' => "/",
'cookie_domain' => "",
'cookie_secure' => 0,
'session_length' => 3600,
'allow_html' => 0,
'allow_html_tags' => "b,i,u,pre",
'allow_bbcode' => 1,
'allow_smilies' => 1,
'allow_sig' => 1,
'allow_namechange' => 0,
'allow_topic_notify' => 1,
'allow_forum_notify' => 1,
'allow_avatar_local' => 0,
'allow_avatar_remote' => 0,
'allow_avatar_upload' => 0,
'default_lang' => "en",
'default_style' => 1,
'default_dateformat' => "D M d, Y g:i a",
'board_timezone' => 0,
'override_user_style' => 0,
'posts_per_page' => 15,
'topics_per_page' => 30,
'hot_threshold' => 25,
'max_post_chars' => 9999,
'max_post_smilies' => 15,
'max_sig_chars' => 255,
'max_poll_options' => 5,
'min_search_chars' => 3,
'max_search_chars' => 10,
'pm_max_boxes' => 4,
'pm_max_msgs' => 50,
'board_email_sig' => "Thanks, The Management",
'board_email' => "youraddress@yourdomain.com",
'smtp_delivery' => 0,
'smtp_host' => "",
'smtp_username' => "",
'smtp_password' => "",
'auth_method' => "db",
'require_activation' => 3,
'flood_interval' => 15,
'search_interval' => 0,
'board_email_form' => 0,
'avatar_filesize' => 6144,
'avatar_max_width' => 90,
'avatar_max_height' => 90,
'avatar_path' => "images/avatars/upload",
'avatar_gallery_path' => "images/avatars/gallery",
'smilies_path' => "images/smiles",
'icons_path' => "images/icons",
'prune_enable' => 0,
'email_enable' => 1,
'privmsg_disable' => 1,
'gzip_compress' => 1,
'coppa_enable' => 1,
'coppa_fax' => "",
'coppa_mail' => "",
'server_name' => "area51.phpbb.com",
'server_port' => 80,
'script_path' => "phpBB22",
'limit_load' => 2.0,
'active_sessions' => 0,
'session_gc' => 3600,
'ldap_server' => "",
'ldap_base_dn' => "",
'ldap_uid' => "",
'version' => "2.1.1 [20021119]",
'ip_check' => 2,
'search_gc' => 7200,
'edit_time' => 15,
'lastread' => 432000,
);
$acl_options = array();
$acl_options = array(
'local' => array(
'f_' => 0,
'f_announce' => 1,
'f_attach' => 2,
'f_bbcode' => 3,
'f_delete' => 4,
'f_download' => 5,
'f_edit' => 6,
'f_email' => 7,
'f_flash' => 8,
'f_html' => 9,
'f_ignoreflood' => 10,
'f_ignorequeue' => 11,
'f_img' => 12,
'f_list' => 13,
'f_poll' => 14,
'f_post' => 15,
'f_print' => 16,
'f_quote' => 17,
'f_rate' => 18,
'f_read' => 19,
'f_reply' => 20,
'f_search' => 21,
'f_sigs' => 22,
'f_smilies' => 23,
'f_sticky' => 24,
'f_vote' => 25,
'm_' => 26,
'm_approve' => 27,
'm_auth' => 28,
'm_delete' => 29,
'm_edit' => 30,
'm_lock' => 31,
'm_merge' => 32,
'm_move' => 33,
'm_split' => 34,
'm_unrate' => 35,
),
'global' => array(
'a_' => 0,
'a_attach' => 1,
'a_auth' => 2,
'a_authadmins' => 3,
'a_authmods' => 4,
'a_backup' => 5,
'a_ban' => 6,
'a_bbcode' => 7,
'a_board' => 8,
'a_clearlogs' => 9,
'a_cookies' => 10,
'a_defaults' => 11,
'a_email' => 12,
'a_events' => 13,
'a_forum' => 14,
'a_forumadd' => 15,
'a_forumdel' => 16,
'a_group' => 17,
'a_groupadd' => 18,
'a_groupdel' => 19,
'a_icons' => 20,
'a_names' => 21,
'a_prune' => 22,
'a_ranks' => 23,
'a_restore' => 24,
'a_search' => 25,
'a_server' => 26,
'a_styles' => 27,
'a_user' => 28,
'a_useradd' => 29,
'a_userdel' => 30,
'a_words' => 31,
'u_' => 32,
'u_avatar' => 33,
'u_email' => 34,
'u_pm' => 35,
'm_' => 36,
'm_approve' => 37,
'm_auth' => 38,
'm_delete' => 39,
'm_edit' => 40,
'm_lock' => 41,
'm_merge' => 42,
'm_move' => 43,
'm_split' => 44,
'm_unrate' => 45,
),
);
?>
?>

View File

@ -25,7 +25,26 @@ function display_forums($root_data=array(), $display_moderators=TRUE)
$where_sql = ($root_data['forum_id']) ? ' WHERE left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'] : '';
$sql = 'SELECT * FROM ' . FORUMS_TABLE . $where_sql . ' ORDER BY left_id';
if($user->data['user_id'] != ANONYMOUS)
{
$lastread_select = ", lr.lastread_time";
$lastread_sql = "
LEFT JOIN " . LASTREAD_TABLE . " lr ON (
lr.user_id = " . $user->data['user_id'] . "
AND (f.forum_id = lr.forum_id OR f.forum_id = -lr.forum_id)
AND lr.lastread_time >= f.forum_last_post_time)";
}
else
{
$lastread_select = '';
$lastread_sql = '';
}
$sql = 'SELECT f.* ' . $lastread_select . '
FROM ' . FORUMS_TABLE . " f " .
$lastread_sql .
$where_sql . '
ORDER BY left_id';
$result = $db->sql_query($sql);
$branch_root_id = $root_data['forum_id'];
@ -120,7 +139,7 @@ function display_forums($root_data=array(), $display_moderators=TRUE)
$forum_id = $row['forum_id'];
$unread_topics = ($user->data['user_id'] && $row['forum_last_post_time'] > $user->data['user_lastvisit']) ? TRUE : FALSE;
$unread_topics = ($user->data['user_id'] && $row['lastread_time'] < $row['forum_last_post_time'] ) ? TRUE : FALSE;
$folder_image = ($unread_topics) ? 'forum_new' : 'forum';
$folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts';
@ -211,4 +230,4 @@ function display_forums($root_data=array(), $display_moderators=TRUE)
));
}
}
?>
?>

View File

@ -47,7 +47,7 @@ if ($mark_read == 'forums')
{
if ($userdata['user_id'])
{
setcookie($config['cookie_name'] . '_f_all', time(), 0, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
markread('markall');
}
$template->assign_vars(array(
@ -57,11 +57,6 @@ if ($mark_read == 'forums')
$message = $user->lang['Forums_marked_read'] . '<br /><br />' . sprintf($user->lang['Click_return_index'], '<a href="' . "index.$phpEx$SID" . '">', '</a> ');
message_die(MESSAGE, $message);
}
// End handle marking posts
// Topic/forum marked read info
$mark_topics = (isset($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array();
$mark_forums = (isset($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_f'])) : array();
// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
$total_posts = $config['num_posts'];
@ -142,4 +137,4 @@ $template->set_filenames(array(
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
?>

View File

@ -78,6 +78,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_method','db')
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_server', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_base_dn', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('ldap_uid', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('lastread', '432000');
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_users', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_date', '0', 1);
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('newest_user_id', '2', 1);

View File

@ -191,6 +191,18 @@ CREATE TABLE phpbb_icons (
PRIMARY KEY (icons_id)
);
# --------------------------------------------------------
#
# Table structure for table 'phpbb_lastread'
#
CREATE TABLE phpbb_lastread (
user_id mediumint(9) NOT NULL default '0',
lastread_type tinyint(4) NOT NULL default '0',
forum_id smallint(6) NOT NULL default '0',
topic_id mediumint(9) NOT NULL default '0',
lastread_time int(4) NOT NULL default '0',
PRIMARY KEY (user_id,topic_id)
);
# --------------------------------------------------------
#

View File

@ -415,7 +415,6 @@ CREATE TABLE phpbb_topics_watch (
);
CREATE INDEX phpbb_topics_watch_index ON phpbb_topics_watch (topic_id, user_id);
/* --------------------------------------------------------
Table structure for table phpbb_user_group
-------------------------------------------------------- */

View File

@ -495,6 +495,10 @@ if (isset($post))
$db->sql_query($sql);
}
// Mark this topic as read and posted to.
$mark_mode = ($mode == 'reply' || $mode == 'newtopic') ? 'post' : 'topic';
markread($mark_mode, $forum_id, $topic_id, $post_id);
$db->sql_transaction('commit');
$template->assign_vars(array(
@ -503,7 +507,7 @@ if (isset($post))
$message = (!empty($enable_moderate)) ? 'POST_STORED_MOD' : 'POST_STORED';
trigger_error($user->lang[$message]);
}
} // Store message, sync counters
// Houston, we have an error ...
$post_text = &stripslashes($message);
@ -514,7 +518,7 @@ if (isset($post))
$template->assign_vars(array(
'ERROR_MESSAGE' => $err_msg)
);
}
} // isset($post)
// PROCESS SUBMIT
// --------------
@ -885,4 +889,4 @@ function topic_review($topic_id, $is_inline_review = false)
}
}
?>
?>

View File

@ -63,9 +63,14 @@ else
LEFT JOIN " . FORUMS_WATCH_TABLE . ' fw ON fw.user_id = ' . $user->data['user_id'] . ' AND f.forum_id = fw.forum_id
WHERE f.forum_id = ' . $forum_id;
*/
$sql = 'SELECT f.*, fw.notify_status
$sql = 'SELECT f.*, fw.notify_status, lr.lastread_time, lr.lastread_type
FROM ' . FORUMS_TABLE . ' f
LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON fw.user_id = ' . $user->data['user_id'] . ' AND f.forum_id = fw.forum_id
LEFT JOIN '.LASTREAD_TABLE.' lr ON (
lr.user_id = '.$user->data['user_id'].'
AND lr.forum_id = '.-$forum_id.')
LEFT JOIN ' . FORUMS_WATCH_TABLE . ' fw ON (
fw.user_id = ' . $user->data['user_id'] . '
AND f.forum_id = fw.forum_id)
WHERE f.forum_id = ' . $forum_id;
}
}
@ -161,18 +166,12 @@ else
// Output forum listing if it is postable
if ($forum_data['forum_postable'])
{
// Topic read tracking cookie info
$mark_topics = (isset($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array();
$mark_forums = (isset($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_f'])) : array();
// Handle marking posts
if ($mark_read == 'topics')
{
if ($user->data['user_id'] != ANONYMOUS)
{
$mark_forums[$forum_id] = time();
setcookie($config['cookie_name'] . '_f', serialize($mark_forums), 0, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']);
markread('mark', $forum_id);
$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . "viewforum.$phpEx$SID&amp;f=$forum_id" . '">')
@ -185,7 +184,7 @@ if ($forum_data['forum_postable'])
// End handle marking posts
// Do the forum Prune
if ($auth->acl_gets('m_prune', 'a_', $forum_id) && $config['prune_enable'])
if ($config['prune_enable'] && $auth->acl_gets('m_prune', 'a_', $forum_id))
{
if ($forum_data['prune_next'] < time() && $forum_data['prune_enable'])
{
@ -329,8 +328,22 @@ if ($forum_data['forum_postable'])
if (empty($forum_data['topics_list']))
{
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . USERS_TABLE . " u2
$sql = "
SELECT
t.*,
u.username,
u.user_id,
u2.username as user2,
u2.user_id as id2,
lr.lastread_time,
lr.lastread_type
FROM " .
TOPICS_TABLE . " t
LEFT JOIN " . LASTREAD_TABLE . " lr ON (
lr.user_id = " . $user->data['user_id'] . "
AND t.topic_id=lr.topic_id), " .
USERS_TABLE . " u, " .
USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_type = " . POST_ANNOUNCE . "
AND u.user_id = t.topic_poster
@ -347,8 +360,22 @@ if ($forum_data['forum_postable'])
}
$db->sql_freeresult($result);
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . USERS_TABLE . " u2
$sql = "
SELECT
t.*,
u.username,
u.user_id,
u2.username as user2,
u2.user_id as id2,
lr.lastread_time,
lr.lastread_type
FROM " .
TOPICS_TABLE . " t
LEFT JOIN " . LASTREAD_TABLE . " lr ON (
lr.user_id = " . $user->data['user_id'] . "
AND t.topic_id=lr.topic_id), " .
USERS_TABLE . " u, " .
USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_approved = 1
AND u.user_id = t.topic_poster
@ -398,6 +425,15 @@ if ($forum_data['forum_postable'])
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'];
// See if the user has posted in this topic.
if($topic_rowset[$i]['lastread_type'] == LASTREAD_POSTED)
{
// Making titles italic is only a hack. This should be done in the templates or in the folder images.
$topic_title = "<i>" . $topic_title . "</i>";
}
// Type and folder
$topic_type = '';
@ -442,10 +478,16 @@ if ($forum_data['forum_postable'])
break;
}
$unread_topic = false;
if ($user->data['user_id'] && $topic_rowset[$i]['topic_last_post_time'] > $user->data['session_last_visit'])
$unread_topic = true;
if ($user->data['user_id']
&&
( $topic_rowset[$i]['topic_last_post_time'] <= $topic_rowset[$i]['lastread_time']
|| $topic_rowset[$i]['topic_last_post_time'] < (time()-$config['lastread'])
|| $topic_rowset[$i]['topic_last_post_time'] < $forum_row['lastread_time']
)
)
{
$unread_topic = true;
$unread_topic = false;
}
$newest_post_img = ($unread_topic) ? '<a href="viewtopic.' . $phpEx . $SID . '&amp;t=' . $topic_id . '&amp;view=newest#newest">' . $user->img('goto_post_newest', 'View_newest_post') . '</a> ' : '';
@ -506,6 +548,7 @@ if ($forum_data['forum_postable'])
$last_post_url = '<a href="viewtopic.' . $phpEx . $SID . '&amp;f=' . $forum_id . '&amp;p=' . $topic_rowset[$i]['topic_last_post_id'] . '#' . $topic_rowset[$i]['topic_last_post_id'] . '">' . $user->img('goto_post_latest', 'View_latest_post') . '</a>';
// Send vars to template
$template->assign_block_vars('topicrow', array(
'FORUM_ID' => $forum_id,
@ -520,7 +563,7 @@ if ($forum_data['forum_postable'])
'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_TITLE' => $topic_title,
'TOPIC_TYPE' => $topic_type,
'TOPIC_ICON' => (!empty($topic_rowset[$i]['topic_icon']) ) ? '<img src="' . $config['icons_path'] . '/' . $topic_icons[$topic_rowset[$i]['topic_icon']]['img'] . '" width="' . $topic_icons[$topic_rowset[$i]['topic_icon']]['width'] . '" height="' . $topic_icons[$topic_rowset[$i]['topic_icon']]['height'] . '" alt="" title="" />' : '',
@ -557,4 +600,4 @@ make_jumpbox('viewforum.'.$phpEx . $SID, $forum_id);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
?>

View File

@ -896,6 +896,8 @@ else
trigger_error($user->lang['No_posts_topic']);
}
markread('topic', $forum_id, $topic_id, $forum_topic_data['topic_last_post_id']);
// Output the page
$page_title = $user->lang['View_topic'] .' - ' . $topic_title;
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
@ -913,4 +915,4 @@ $db->sql_query($sql);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
?>