示例#1
0
function unsubscribe($forum, $thread, $user)
{
    BoincSubscription::delete($user->id, $thread->id);
    if (!BoincSubscription::lookup($user->id, $thread->id)) {
        page_head(tra("Unsubscription successful"));
        show_forum_header($user);
        show_title($forum, $thread);
        echo "<p>" . tra("You are no longer subscribed to %1. You will no longer receive notifications for this thread.", "<b>" . cleanup_title($thread->title) . "</b>");
    } else {
        page_head(tra("Unsubscription failed"));
        echo "<p>" . tra("We are currently unable to unsubscribe you from %1. Please try again later..", "<b>" . cleanup_title($thread->title) . "</b>");
    }
    echo "</p><p><br /><a href=\"forum_thread.php?id=" . $thread->id . "\">" . tra("Return to thread") . "</a></p>";
    page_tail();
}
示例#2
0
}
if (!is_forum_visible_to_user($forum, $logged_in_user)) {
    if ($logged_in_user) {
        remove_subscriptions_forum($logged_in_user->id, $forum->id);
    }
    error_page(tra("This forum is not visible to you."));
}
if ($thread->hidden) {
    if (!is_moderator($logged_in_user, $forum)) {
        if ($logged_in_user) {
            remove_subscriptions_forum($logged_in_user->id, $thread->id);
        }
        error_page(tra("This thread has been hidden by moderators."));
    }
}
$title = cleanup_title($thread->title);
if ($temp_sort_style) {
    $sort_style = $temp_sort_style;
} else {
    if ($sort_style) {
        $forum_style = 0;
        // this is deprecated
        if ($logged_in_user) {
            $logged_in_user->prefs->thread_sorting = $sort_style;
            $logged_in_user->prefs->update("thread_sorting={$sort_style}");
        } else {
            list($forum_style, $old_style) = parse_forum_cookie();
        }
        send_cookie('sorting', implode("|", array($forum_style, $sort_style)), true);
    } else {
        // get the sorting style from the user or a cookie
示例#3
0
function show_forum($forum, $start, $sort_style, $user)
{
    $gotoStr = "";
    $nav = show_page_nav($forum, $start);
    if ($nav) {
        $gotoStr = "<div align=\"right\">{$nav}</div><br />";
    }
    echo $gotoStr;
    // Display the navbar
    start_forum_table(array("", tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "<nobr>" . tra("Last post") . "</nobr>"));
    $sticky_first = !$user || !$user->prefs->ignore_sticky_posts;
    // Show hidden threads if logged in user is a moderator
    //
    $show_hidden = is_moderator($user, $forum);
    $threads = get_forum_threads($forum->id, $start, THREADS_PER_PAGE, $sort_style, $show_hidden, $sticky_first);
    if ($user) {
        $subs = BoincSubscription::enum("userid={$user->id}");
    }
    // Run through the list of threads, displaying each of them
    $n = 0;
    $i = 0;
    foreach ($threads as $thread) {
        $owner = BoincUser::lookup_id($thread->owner);
        $unread = thread_is_unread($user, $thread);
        //if ($thread->status==1){
        // This is an answered helpdesk thread
        if ($user && is_subscribed($thread, $subs)) {
            echo '<tr class="row_hd' . $n . '">';
        } else {
            echo '<tr class="row' . $n . '">';
        }
        echo '<td width="1%"><nobr>';
        if ($user && $thread->rating() > $user->prefs->high_rating_threshold) {
            show_image(EMPHASIZE_IMAGE, "This message has a high average rating", "Highly rated");
        }
        if ($user && $thread->rating() < $user->prefs->low_rating_threshold) {
            show_image(FILTER_IMAGE, "This message has a low average rating", "Low rated");
        }
        if ($thread->hidden) {
            echo "[hidden]";
        }
        if ($unread) {
            if ($thread->sticky) {
                if ($thread->locked) {
                    show_image(NEW_IMAGE_STICKY_LOCKED, "This thread is sticky and locked, and you haven't read it yet", "sticky/locked/unread");
                } else {
                    show_image(NEW_IMAGE_STICKY, "This thread is sticky and you haven't read it yet", "sticky/unread");
                }
            } else {
                if ($thread->locked) {
                    show_image(NEW_IMAGE_LOCKED, "You haven't read this thread yet, and it's locked", "unread/locked");
                } else {
                    show_image(NEW_IMAGE, "You haven't read this thread yet", "unread");
                }
            }
        } else {
            if ($thread->sticky) {
                if ($thread->locked) {
                    show_image(IMAGE_STICKY_LOCKED, "This thread is sticky and locked", "sticky/locked");
                } else {
                    show_image(IMAGE_STICKY, "This thread is sticky", "sticky");
                }
            } else {
                if ($thread->locked) {
                    show_image(IMAGE_LOCKED, "This thread is locked", "locked");
                }
            }
        }
        echo "</nobr></td>";
        $titlelength = 48;
        $title = $thread->title;
        if (strlen($title) > $titlelength) {
            $title = substr($title, 0, $titlelength) . "...";
        }
        $title = cleanup_title($title);
        echo '<td class="threadline">
			<a href="forum_thread.php?id=' . $thread->id . '"><strong>' . $title . '</strong></a>
			<br /></td>';
        $n = ($n + 1) % 2;
        echo '<td class="numbers leftborder">' . ($thread->replies + 1) . '</td>
			<td class="author leftborder">' . user_links($owner) . '</td>
			<td class="numbers leftborder">' . $thread->views . '</td>
			<td class="lastpost leftborder">' . time_diff_str($thread->timestamp, time()) . '</td>
			</tr>';
        flush();
    }
    end_table();
    echo "<br />{$gotoStr}";
    // show page links
}
示例#4
0
function show_forum($forum, $start, $sort_style, $user)
{
    $page_nav = page_links("forum_forum.php?id={$forum->id}&amp;sort={$sort_style}", $forum->threads, THREADS_PER_PAGE, $start);
    echo $page_nav;
    start_forum_table(array("", tra("Threads"), tra("Posts"), tra("Author"), tra("Views"), "<nobr>" . tra("Last post") . "</nobr>"));
    $sticky_first = !$user || !$user->prefs->ignore_sticky_posts;
    // Show hidden threads if logged in user is a moderator
    //
    $show_hidden = is_moderator($user, $forum);
    $threads = get_forum_threads($forum->id, $start, THREADS_PER_PAGE, $sort_style, $show_hidden, $sticky_first);
    if ($user) {
        $subs = BoincSubscription::enum("userid={$user->id}");
    }
    // Run through the list of threads, displaying each of them
    //
    $n = 0;
    $i = 0;
    foreach ($threads as $thread) {
        $owner = BoincUser::lookup_id($thread->owner);
        if (!$owner) {
            continue;
        }
        $unread = thread_is_unread($user, $thread);
        //if ($thread->status==1){
        // This is an answered helpdesk thread
        if ($user && is_subscribed($thread, $subs)) {
            echo '<tr class="row_hd' . $n . '">';
        } else {
            // Just a standard thread.
            echo '<tr class="row' . $n . '">';
        }
        echo "<td width=\"1%\" class=\"threadicon\"><nobr>";
        if ($thread->hidden) {
            show_image(IMAGE_HIDDEN, tra("This thread is hidden"), tra("hidden"));
        } else {
            if ($unread) {
                if ($thread->sticky) {
                    if ($thread->locked) {
                        show_image(NEW_IMAGE_STICKY_LOCKED, tra("This thread is sticky and locked, and you haven't read it yet"), tra("sticky/locked/unread"));
                    } else {
                        show_image(NEW_IMAGE_STICKY, tra("This thread is sticky and you haven't read it yet"), tra("sticky/unread"));
                    }
                } else {
                    if ($thread->locked) {
                        show_image(NEW_IMAGE_LOCKED, tra("You haven't read this thread yet, and it's locked"), tra("unread/locked"));
                    } else {
                        show_image(NEW_IMAGE, tra("You haven't read this thread yet"), tra("unread"));
                    }
                }
            } else {
                if ($thread->sticky) {
                    if ($thread->locked) {
                        show_image(IMAGE_STICKY_LOCKED, tra("This thread is sticky and locked"), tra("sticky/locked"));
                    } else {
                        show_image(IMAGE_STICKY, tra("This thread is sticky"), tra("sticky"));
                    }
                } else {
                    if ($thread->locked) {
                        show_image(IMAGE_LOCKED, tra("This thread is locked"), tra("locked"));
                    } else {
                        show_image(IMAGE_POST, tra("You read this thread"), tra("read"));
                    }
                }
            }
        }
        echo "</nobr></td>";
        $title = cleanup_title($thread->title);
        //$titlelength = 9999;
        //if (strlen($title) > $titlelength) {
        //    $title = substr($title, 0, $titlelength)."...";
        //}
        echo "<td class=\"threadline\"><a href=\"forum_thread.php?id={$thread->id}\"><b>{$title}</b></a><br></td>";
        $n = ($n + 1) % 2;
        echo '
            <td class="numbers">' . ($thread->replies + 1) . '</td>
            <td>' . user_links($owner, BADGE_HEIGHT_SMALL) . '</td>
            <td class="numbers">' . $thread->views . '</td>
            <td class="lastpost">' . time_diff_str($thread->timestamp, time()) . '</td>
            </tr>
        ';
        flush();
    }
    end_table();
    echo "<br>{$page_nav}";
    // show page links
}