- user web: add a feature to mark all threads as read (forums). (fix #52)

svn path=/trunk/boinc/; revision=13182
This commit is contained in:
Rytis Slatkevičius 2007-07-18 15:48:07 +00:00
parent 4eb40183f2
commit b24c43f06f
5 changed files with 41 additions and 18 deletions

View File

@ -7356,3 +7356,13 @@ David 18 July 2007
html/user/
team_founder_transfer_form.php
Rytis 18 July 2007
- user web: add a feature to mark all threads as read (forums).
html/inc/
forum.inc
forum_user.inc
html/user/
forum_forum.php
forum_index.php

View File

@ -401,7 +401,7 @@ function show_forum_title($forum=NULL, $thread=NULL, $extended=true) {
if ($extended) {
start_table_noborder();
echo "<tr>\n";
// Search
echo "<td><form action=\"forum_search_action.php\" method=\"POST\">
<input type=\"hidden\" name=\"search_max_time\" value=\"30\">
@ -413,12 +413,14 @@ function show_forum_title($forum=NULL, $thread=NULL, $extended=true) {
</form>
";
echo "</td>\n";
$logged_in_user = get_logged_in_user(false);
// Custom stuff for logged in user
if ($logged_in_user) {
echo "<td align=\"right\">\n";
echo "<a href=\"forum_index.php?read=1&amp;".url_tokens($logged_in_user->authenticator)."\">Mark all threads as read</a><br />\n";
// Private messages
echo pm_notification($logged_in_user);
@ -505,7 +507,7 @@ function show_post2($post, $n) {
$user = lookup_user_id($post->user);
$title = cleanup_title($thread->title);
$m = $n%2;
if($post->hidden) {
if ($post->hidden) {
$deleted = "<br><font color=red>[Deleted by a moderator]</font>";
} else {
$deleted = "";

View File

@ -186,6 +186,11 @@ class User {
$this->updatePrefs("avatar", $url);
}
function getReadTimestamp(){
$this->ensurePrefsLoaded();
return $this->fprefObj->mark_as_read_timestamp;
}
/**
* Gets user's display options and creates an output_options object
* based upon their options. (see text_transformations.php)

View File

@ -19,9 +19,9 @@ $user = re_get_logged_in_user(false);
if (!$sort_style) {
// get the sort style either from the logged in user or a cookie
if ($user){
$sort_style = $user->getForumSortStyle();
$sort_style = $user->getForumSortStyle();
} else {
list($sort_style,$thread_style)=explode("|",$_COOKIE['sorting']);
list($sort_style,$thread_style)=explode("|",$_COOKIE['sorting']);
}
} else {
// set the sort style
@ -43,7 +43,6 @@ if ($Category->getType()!=0){
// Allow users with a linktab-browser to get some usefull links
echo '<link href="forum_index.php" rel="up" title="Forum Index">';
show_forum_title($forum, NULL);
echo '
@ -74,26 +73,27 @@ function show_forum($forum, $start, $sort_style, $user) {
$gotoStr = "<div align=\"right\">".show_page_nav($forum,$start)."</div>";
echo $gotoStr; // Display the navbar
start_forum_table(array("", tr(FORUM_THREADS), tr(FORUM_POSTS), tr(FORUM_AUTHOR), tr(FORUM_VIEWS), "<nobr>".tr(FORUM_LAST_POST)."</nobr>"));
$sticky_first = !$user || !$user->hasIgnoreStickyPosts();
// Show hidden threads if logged in user is a moderator
$show_hidden = $user && $user->isSpecialUser(S_MODERATOR);
$threads = $forum->getThreads($start, THREADS_PER_PAGE, $sort_style, $show_hidden, $sticky_first);
// Run through the list of threads, displaying each of them
$n = 0; $i=0;
foreach ($threads as $key => $thread) {
$owner = $thread->getOwner();
$unread = $user && ($thread->getLastTimestamp()>$thread->getLastReadTimestamp($user));
$timestamp = $thread->getLastTimestamp();
$unread = $user && ($timestamp>$thread->getLastReadTimestamp($user)) && ($timestamp > $user->getReadTimestamp());
if ($thread->getStatus()==1){
// This is an answered helpdesk thread
echo '<tr class="row_hd'.$n.'">';
} else {
// Just a standard thread.
echo '<tr class="row'.$n.'">';
}
// This is an answered helpdesk thread
echo '<tr class="row_hd'.$n.'">';
} else {
// Just a standard thread.
echo '<tr class="row'.$n.'">';
}
echo "<td width=\"1%\" align=\"right\"><nobr>";
if ($user && ($thread->getRating()>$user->getHighRatingThreshold())) {
echo "<img src=\"".EMPHASIZE_IMAGE."\" alt=\"Emphasized thread\">";

View File

@ -9,7 +9,13 @@ require_once('../inc/forum.inc');
require_once('../inc/forum_std.inc');
db_init();
get_logged_in_user(false);
$logged_in_user = get_logged_in_user(false);
// Process request to mark all posts as read
if ((get_int("read", true) == 1) && ($logged_in_user)) {
check_tokens($logged_in_user->authenticator);
mysql_query("UPDATE forum_preferences SET mark_as_read_timestamp=".time()." WHERE userid=".$logged_in_user->id.";");
}
function forum_summary($forum) {
echo '