mirror of https://github.com/BOINC/boinc.git
- web: make "jump to first unread" for with pagination
svn path=/trunk/boinc/; revision=25868
This commit is contained in:
parent
17db492473
commit
99a077c642
|
@ -4893,3 +4893,12 @@ Charlie 12 July 2012
|
|||
project.pbxproj
|
||||
wrapper/
|
||||
BuildMacWrapper.sh
|
||||
|
||||
David 12 July 2012
|
||||
- web: make "jump to first unread" for with pagination
|
||||
|
||||
html/
|
||||
inc/
|
||||
forum.inc
|
||||
user/
|
||||
forum_thread.php
|
||||
|
|
|
@ -312,13 +312,13 @@ function can_reply($thread, $forum, $user) {
|
|||
}
|
||||
|
||||
// Show the posts in a thread for a user.
|
||||
// If $start is null, enforce jump-to-first-unread
|
||||
//
|
||||
function show_posts(
|
||||
$thread, $forum, $start, $sort_style, $filter, $logged_in_user,
|
||||
$show_controls=true
|
||||
) {
|
||||
$n = 1;
|
||||
$first_unread_post = null;
|
||||
|
||||
if ($show_controls) {
|
||||
$controls = FORUM_CONTROLS;
|
||||
|
@ -340,7 +340,6 @@ function show_posts(
|
|||
}
|
||||
|
||||
$posts = get_thread_posts($thread->id, $sort_style, $show_hidden);
|
||||
$postcount = (sizeof($posts)-1);
|
||||
|
||||
$latest_viewed = 0;
|
||||
$forum_log = null;
|
||||
|
@ -351,6 +350,32 @@ function show_posts(
|
|||
}
|
||||
}
|
||||
|
||||
// jump to first unread post if needed
|
||||
//
|
||||
$first_unread_post = null;
|
||||
if ($start === null) {
|
||||
if ($latest_viewed && $logged_in_user->prefs->jump_to_unread) {
|
||||
$i = 0;
|
||||
$ibest = 0;
|
||||
foreach ($posts as $post) {
|
||||
if ($post->timestamp > $latest_viewed) {
|
||||
if (!$first_unread_post || ($post->timestamp < $first_unread_post->timestamp)) {
|
||||
$first_unread_post = $post;
|
||||
$ibest = $i;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($first_unread_post) {
|
||||
$start = $ibest - ($ibest % $num_to_show);
|
||||
} else {
|
||||
$start = 0;
|
||||
}
|
||||
} else {
|
||||
$start = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$page_nav = page_links(
|
||||
"forum_thread.php?id=$thread->id&sort_style=$sort_style",
|
||||
sizeof($posts),
|
||||
|
@ -367,7 +392,7 @@ function show_posts(
|
|||
|
||||
$latest_post_shown = 0;
|
||||
$first_unread_post = null;
|
||||
foreach ($posts as $post){
|
||||
foreach ($posts as $post) {
|
||||
if ($num_skipped < $start) {
|
||||
$num_skipped++;
|
||||
continue;
|
||||
|
@ -381,11 +406,6 @@ function show_posts(
|
|||
);
|
||||
$n = ($n+1)%2;
|
||||
|
||||
if (($post->timestamp>$latest_viewed) &&
|
||||
((!$first_unread_post) || ($post->timestamp<$first_unread_post->timestamp))
|
||||
){
|
||||
$first_unread_post = $post;
|
||||
}
|
||||
if ($post->timestamp > $latest_post_shown) {
|
||||
$latest_post_shown = $post->timestamp;
|
||||
}
|
||||
|
@ -394,12 +414,10 @@ function show_posts(
|
|||
end_table();
|
||||
echo $page_nav;
|
||||
|
||||
if ($logged_in_user && $logged_in_user->prefs->jump_to_unread){
|
||||
if ($first_unread_post) {
|
||||
echo "<script>function jumpToUnread(){location.href='#".$first_unread_post->id."';}</script>";
|
||||
} else {
|
||||
echo "<script>function jumpToUnread(){};</script>";
|
||||
}
|
||||
if ($first_unread_post) {
|
||||
echo "<script>function jumpToUnread(){location.href='#".$first_unread_post->id."';}</script>";
|
||||
} else {
|
||||
echo "<script>function jumpToUnread(){};</script>";
|
||||
}
|
||||
|
||||
if (!$forum_log || $latest_post_shown > $forum_log->timestamp) {
|
||||
|
|
|
@ -26,7 +26,6 @@ require_once('../inc/news.inc');
|
|||
$threadid = get_int('id');
|
||||
$sort_style = get_int('sort', true);
|
||||
$start = get_int('start', true);
|
||||
if (!$start) $start = 0;
|
||||
$filter = get_str('filter', true);
|
||||
|
||||
if ($filter != "false"){
|
||||
|
@ -259,8 +258,7 @@ echo "<input type=\"submit\" value=\"".tra('Sort')."\">
|
|||
";
|
||||
|
||||
show_posts(
|
||||
$thread, $forum, $start, $sort_style, $filter,
|
||||
$logged_in_user, true
|
||||
$thread, $forum, $start, $sort_style, $filter, $logged_in_user, true
|
||||
);
|
||||
|
||||
if ($reply_url) {
|
||||
|
|
Loading…
Reference in New Issue