From 53dd64926a73eab3d9d7bd1a0ccbddd16b9aaf83 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Wed, 26 Sep 2001 22:12:38 +0000 Subject: [PATCH] topic watch/forum/topic read now cause a message to be displayed, changed profile ICQ for subSilver, various other changes git-svn-id: file:///svn/phpbb/trunk@1093 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/index.php | 11 +--- phpBB/language/lang_english.php | 9 +++- phpBB/profile.php | 17 ++++++- phpBB/viewforum.php | 90 +++++++++++++++++++++++---------- phpBB/viewtopic.php | 73 +++++++++++++++++++++++--- 5 files changed, 153 insertions(+), 47 deletions(-) diff --git a/phpBB/index.php b/phpBB/index.php index 201f9ea821..fee68b2967 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -278,25 +278,16 @@ if($total_categories = $db->sql_numrows($q_categories)) if($forum_rows[$j]['username'] != "" && $forum_rows[$j]['post_time'] > 0) { - if($forum_rows[$j]['user_id'] == ANONYMOUS && $forum_rows[$j]['post_username'] != '') - { - $last_poster = $forum_rows[$j]['post_username']; - } - else - { - $last_poster = $forum_rows[$j]['username']; - } $last_post_time = create_date($board_config['default_dateformat'], $forum_rows[$j]['post_time'], $board_config['board_timezone']); $last_post = $last_post_time . "
" . $lang['by'] . " "; - $last_post .= "" . $last_poster . " "; + $last_post .= ( $forum_rows[$j]['user_id'] == ANONYMOUS ) ? $forum_rows[$j]['username'] . " " : "" . $forum_rows[$j]['username'] . " "; $last_post .= "\"""; } else { $last_post = $lang['No_Posts']; - $forum_rows[$j]['forum_name'] = $forum_rows[$j]['forum_name']; } $mod_count = 0; diff --git a/phpBB/language/lang_english.php b/phpBB/language/lang_english.php index 3f58f5aebb..75f2cb815e 100755 --- a/phpBB/language/lang_english.php +++ b/phpBB/language/lang_english.php @@ -162,6 +162,7 @@ $lang['theforums'] = "the forums"; $lang['No_new_posts'] = "No new posts"; $lang['New_posts'] = "New posts"; +$lang['New_post'] = "New post"; $lang['No_new_posts_hot'] = "No new posts [ Popular ]"; $lang['New_posts_hot'] = "New posts [ Popular ]"; $lang['Topic_is_locked'] = "Topic is locked"; @@ -188,6 +189,8 @@ $lang['No_forums'] = "This board has no forums"; $lang['Private_Messages'] = "Private Messages"; $lang['Who_is_Online'] = "Who is Online"; +$lang['Forums_marked_read'] = "All forums have been marked read"; + // // Viewforum // @@ -203,6 +206,9 @@ $lang['Topic_Sticky'] = "Sticky:"; $lang['Topic_Moved'] = "Moved:"; $lang['Topic_Poll'] = "[ Poll ]"; +$lang['View_newest_posts'] = "View posts since your last visit"; +$lang['Topics_marked_read'] = "The topics for this forum have now been marked read"; + // // Viewtopic // @@ -248,7 +254,8 @@ $lang['Split_topic'] = "Split this topic"; $lang['Stop_watching_topic'] = "Stop watching this topic"; $lang['Start_watching_topic'] = "Watch this topic for replies"; - +$lang['No_longer_watching'] = "You are no longer watching this topic"; +$lang['You_are_watching'] = "You are now watching this topic"; // // Posting/Replying (Not private messaging!) diff --git a/phpBB/profile.php b/phpBB/profile.php index 63d78d4dfb..cebec6366f 100644 --- a/phpBB/profile.php +++ b/phpBB/profile.php @@ -259,9 +259,22 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) if( !empty($profiledata['user_icq']) ) { - $icq_status_img = "\"\""; + $icq_status_img = "\"\""; - $icq_add_img = "\"""; + // + // This cannot stay like this, it needs a 'proper' solution, eg a separate + // template for overlaying the ICQ icon, or we just do away with the icq status + // display (which is after all somewhat a pain in the rear :D + // + if( $theme['template_name'] == "subSilver" ) + { + $icq_add_img = '
' . $icq_status_img . '' . $lang['ICQ'] . '
'; + $icq_status_img = ""; + } + else + { + $icq_add_img = "\"""; + } } else { diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index fd480d11cc..31a15b232c 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -65,7 +65,7 @@ init_userprefs($userdata); // if(isset($forum_id)) { - $sql = "SELECT forum_name, forum_status, forum_topics, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_pollcreate, auth_vote, prune_enable, prune_next + $sql = "SELECT * FROM " . FORUMS_TABLE . " WHERE forum_id = $forum_id"; if(!$result = $db->sql_query($sql)) @@ -88,8 +88,6 @@ if(!$total_rows = $db->sql_numrows($result)) } $forum_row = $db->sql_fetchrow($result); -$forum_name = $forum_row['forum_name']; - // // Start auth check // @@ -108,6 +106,57 @@ if(!$is_auth['auth_read'] || !$is_auth['auth_view']) // End of auth check // +// +// Handle marking posts +// +if( $mark_read == "topics" ) +{ + $sql = "SELECT t.topic_id, p.post_time + FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p + WHERE t.forum_id = $forum_id + AND p.post_id = t.topic_last_post_id + AND p.post_time > " . $userdata['session_last_visit'] . " + AND t.topic_moved_id = NULL + LIMIT $start, " . $board_config['topics_per_page']; + if(!$t_result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't obtain topic information", "", __LINE__, __FILE__, $sql); + } + + if( $mark_read_rows = $db->sql_numrows($t_result) ) + { + $mark_read_list = $db->sql_fetchrowset($t_result); + + for($i = 0; $i < $mark_read_rows; $i++ ) + { + $topic_id = $mark_read_list[$i]['topic_id']; + $post_time = $mark_read_list[$i]['post_time']; + + if( empty($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) ) + { + setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + } + else + { + if( isset($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) ) + { + setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + } + } + } + } + + $template->assign_vars(array( + "META" => '') + ); + + $message = $lang['Topics_marked_read'] . "

" . $lang['Click'] . " " . $lang['HERE'] . " " . $lang['to_return_forum']; + message_die(GENERAL_MESSAGE, $message); +} +// +// End handle marking posts +// + // // Do the forum Prune // @@ -330,7 +379,7 @@ $template->assign_var_from_handle("JUMPBOX", "jumpbox"); $template->assign_vars(array( "FORUM_ID" => $forum_id, - "FORUM_NAME" => $forum_name, + "FORUM_NAME" => $forum_row['forum_name'], "MODERATORS" => $forum_moderators, "IMG_POST" => ($forum_row['forum_status'] == FORUM_LOCKED) ? $images['post_locked'] : $images['post_new'], @@ -472,29 +521,13 @@ if($total_topics) if( empty($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) && $topic_rowset[$i]['post_time'] > $userdata['session_last_visit'] ) { - if($mark_read == "topics") - { - setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); - $folder_image = "\"""; - } - else - { - $folder_image = "\"""; - } + $folder_image = "\"""; } else { if( isset($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id]) ) { - if($mark_read == "topics") - { - setcookie('phpbb2_' . $forum_id . '_' . $topic_id, time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); - $folder_image = "\"""; - } - else - { - $folder_image = ($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id] < $topic_rowset[$i]['post_time'] ) ? "\""" : "\"""; - } + $folder_image = ($HTTP_COOKIE_VARS['phpbb2_' . $forum_id . '_' . $topic_id] < $topic_rowset[$i]['post_time'] ) ? "\""" : "\"""; } else { @@ -508,19 +541,19 @@ if($total_topics) $topic_poster = $topic_rowset[$i]['username']; $topic_poster_profile_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $topic_rowset[$i]['user_id']); - $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']); - - if($topic_rowset[$i]['id2'] == ANONYMOUS && $topic_rowset[$i]['post_username'] != '') + if($topic_rowset[$i]['post_time'] >= $userdata['session_last_visit']) { - $last_post_user = $topic_rowset[$i]['post_username']; + $newest_post_img = "\"" "; } else { - $last_post_user = $topic_rowset[$i]['user2']; + $newest_post_img = ""; } + $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']); + $last_post = $last_post_time . "
" . $lang['by'] . " "; - $last_post .= "" . $last_post_user . " "; + $last_post .= ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? $topic_rowset[$i]['user2'] . " " : "" . $topic_rowset[$i]['user2'] . " "; $last_post .= "\"""; $views = $topic_rowset[$i]['topic_views']; @@ -532,6 +565,7 @@ if($total_topics) "TOPIC_POSTER" => $topic_poster, "GOTO_PAGE" => $goto_page, "REPLIES" => $replies, + "NEWEST_POST_IMG" => $newest_post_img, "TOPIC_TITLE" => $topic_title, "TOPIC_TYPE" => $topic_type, "VIEWS" => $views, diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 7dffb86320..9d60156a07 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -53,7 +53,41 @@ if( !isset($topic_id) && !isset($post_id) ) // if( isset($HTTP_GET_VARS["view"]) && empty($HTTP_GET_VARS[POST_POST_URL]) ) { - if($HTTP_GET_VARS["view"] == "next") + if( $HTTP_GET_VARS["view"] == "newest" ) + { + if(isset($HTTP_COOKIE_VARS[$board_config['cookie_name']])) + { + $sessiondata = unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name']])); + + $newest_time = $sessiondata['lastvisit']; + + $sql = "SELECT post_id + FROM " . POSTS_TABLE . " + WHERE topic_id = $topic_id + AND post_time >= $newest_time + ORDER BY post_time ASC + LIMIT 1"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Couldn't obtain newer/older topic information", "", __LINE__, __FILE__, $sql); + } + + if( !($row = $db->sql_fetchrow($result)) ) + { + message_die(GENERAL_MESSAGE, 'No new posts since your last visit'); + } + else + { + $post_id = $row['post_id']; + header("Location: viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id"); + } + } + else + { + header("Location: viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"); + } + } + else if($HTTP_GET_VARS["view"] == "next") { $sql_condition = ">"; $sql_ordering = "ASC"; @@ -198,6 +232,13 @@ if($userdata['user_id'] != ANONYMOUS) message_die(GENERAL_ERROR, "Couldn't delete topic watch information", "", __LINE__, __FILE__, $sql); } } + + $template->assign_vars(array( + "META" => '') + ); + + $message = $lang['No_longer_watching']. "

" . $lang['Click'] . " " . $lang['HERE'] . " " . $lang['to_return_topic']; + message_die(GENERAL_MESSAGE, $message); } else { @@ -235,6 +276,13 @@ if($userdata['user_id'] != ANONYMOUS) message_die(GENERAL_ERROR, "Couldn't insert topic watch information", "", __LINE__, __FILE__, $sql); } } + + $template->assign_vars(array( + "META" => '') + ); + + $message = $lang['You_are_watching']. "

" . $lang['Click'] . " " . $lang['HERE'] . " " . $lang['to_return_topic']; + message_die(GENERAL_MESSAGE, $message); } else { @@ -623,6 +671,18 @@ for($i = 0; $i < $total_posts; $i++) $poster_avatar = ""; } + // + // Define the little post icon + // + if( $postrow[$i]['post_time'] > $userdata['session_last_visit'] ) + { + $mini_post_img = '' . $lang['New_post'] . ''; + } + else + { + $mini_post_img = '' . $lang['Post'] . ''; + } + // // Generate ranks // @@ -676,16 +736,16 @@ for($i = 0; $i < $total_posts; $i++) if( !empty($postrow[$i]['user_icq']) ) { - $icq_status_img = ""; + $icq_status_img = ""; // // This cannot stay like this, it needs a 'proper' solution, eg a separate - // template for overlaying the ICQ icon, or we just do away with the icq status - // display (which is after all somewhat a pain in the rear :D + // template for overlaying the ICQ icon, or we just do away with the icq status + // display (which is after all somewhat a pain in the rear :D // if( $theme['template_name'] == "subSilver" ) { - $icq_add_img = '
' . $icq_status_img . '' . $lang['ICQ'] . '
'; + $icq_add_img = '
' . $icq_status_img . '' . $lang['ICQ'] . '
'; $icq_status_img = ""; } else @@ -818,6 +878,7 @@ for($i = 0; $i < $total_posts; $i++) $template->assign_block_vars("postrow", array( "ROW_COLOR" => "#" . $row_color, "ROW_CLASS" => $row_class, + "MINI_POST_IMG" => $mini_post_img, "POSTER_NAME" => $poster, "POSTER_RANK" => $poster_rank, "RANK_IMAGE" => $rank_image, @@ -834,7 +895,7 @@ for($i = 0; $i < $total_posts; $i++) "EMAIL_IMG" => $email_img, "WWW_IMG" => $www_img, "ICQ_STATUS_IMG" => $icq_status_img, - "ICQ_ADD_IMG" => $icq_add_img, + "ICQ_ADD_IMG" => $icq_add_img, "AIM_IMG" => $aim_img, "MSN_IMG" => $msn_img, "YIM_IMG" => $yim_img,