-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforum_thread.php
More file actions
320 lines (288 loc) · 9.72 KB
/
forum_thread.php
File metadata and controls
320 lines (288 loc) · 9.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// display the contents of a thread.
require_once('../inc/util.inc');
require_once('../inc/forum.inc');
require_once('../inc/news.inc');
$threadid = get_int('id');
$sort_style = get_int('sort', true);
$temp_sort_style = get_int('temp_sort_style', true);
$start = get_int('start', true);
$postid = get_int('postid', true);
$filter = get_str('filter', true);
if ($filter != "false"){
$filter = true;
} else {
$filter = false;
}
$logged_in_user = get_logged_in_user(false);
update_visit_time($logged_in_user);
$tokens = "";
if ($logged_in_user) {
BoincForumPrefs::lookup($logged_in_user);
$tokens = url_tokens($logged_in_user->authenticator);
}
if (DISABLE_FORUMS && !is_admin($logged_in_user)) {
error_page("Forums are disabled");
}
if ($threadid < 1) {
error_page("Invalid thread ID!");
}
$thread = BoincThread::lookup_id($threadid);
if (!$thread) {
error_page("Bad thread ID");
}
$forum = BoincForum::lookup_id($thread->forum);
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
if ($logged_in_user){
$sort_style = $logged_in_user->prefs->thread_sorting;
} else {
list($forum_style, $sort_style) = parse_forum_cookie();
}
}
page_head("Thread: $title", 'onload="jumpToUnread();"');
$is_subscribed = $logged_in_user && BoincSubscription::lookup($logged_in_user->id, $thread->id);
echo "<p>";
switch ($forum->parent_type) {
case 0:
$category = BoincCategory::lookup_id($forum->category);
show_forum_title($category, $forum, $thread);
break;
case 1:
show_team_forum_title($forum, $thread);
break;
}
//echo "<br><small><a href=moderation.php>".tra("Message board moderation")."</a></small> ";
if (false) {
if ($forum->parent_type == 0) {
if ($category->is_helpdesk && !$thread->status){
if ($logged_in_user){
if ($thread->owner == $logged_in_user->id){
if ($thread->replies !=0) {
// Show a "this question has been answered" to the author
echo "<p>";
show_button(
"forum_thread_status.php?id=$thread->id&action=set",
tra("My question was answered"),
tra("Click here if your question has been adequately answered")
);
}
} else {
// and a "I also got this question" to everyone else
echo "<p>";
show_button(
"forum_thread_vote.php?id=$thread->id",
tra("I've also got this question")
);
}
}
}
}
}
echo '
<p>
<form class="form-inline" action="forum_thread.php">
<table width="100%" cellspacing=0 cellpadding=0>
<tr>
<td>
';
$reply_url = "";
if (!$logged_in_user) {
echo "To post messages, you must <a href=login_form.php>log in</a>.";
} else {
if (can_reply($thread, $forum, $logged_in_user)) {
$reply_url = "forum_reply.php?thread=".$thread->id."#input";
show_button_small(
$reply_url,
tra("Post to thread"),
tra("Add a new message to this thread")
);
}
if ($is_subscribed) {
$type = NOTIFY_SUBSCRIBED_POST;
BoincNotify::delete_aux(
"userid=$logged_in_user->id and type=$type and opaque=$thread->id"
);
$url = "forum_subscribe.php?action=unsubscribe&thread=".$thread->id."$tokens";
show_button_small(
$url,
tra("Unsubscribe"),
tra("You are subscribed to this thread. Click here to unsubscribe.")
);
} else {
$url = "forum_subscribe.php?action=subscribe&thread=".$thread->id."$tokens";
show_button_small(
$url,
tra("Subscribe"),
tra("Click to get email when there are new posts in this thread")
);
}
// If logged in user is moderator, enable some extra features
//
if (is_moderator($logged_in_user, $forum)) {
if ($thread->hidden){
show_button_small(
"forum_moderate_thread_action.php?action=unhide&thread=".$thread->id."$tokens",
tra("Unhide"),
tra("Unhide this thread")
);
} else {
show_button_small(
"forum_moderate_thread.php?action=hide&thread=".$thread->id,
tra("Hide"),
tra("Hide this thread")
);
}
if ($thread->sticky){
show_button_small(
"forum_moderate_thread_action.php?action=desticky&thread=".$thread->id."$tokens",
tra("Make unsticky"),
tra("Make this thread not sticky")
);
} else {
show_button_small(
"forum_moderate_thread_action.php?action=sticky&thread=".$thread->id."$tokens",
tra("Make sticky"),
tra("Make this thread always appear at top of forum")
);
}
if ($thread->locked) {
show_button_small(
"forum_moderate_thread_action.php?action=unlock&thread=".$thread->id."$tokens",
tra("Unlock"),
tra("Allow new posts in this thread")
);
} else {
show_button_small(
"forum_moderate_thread.php?action=lock&thread=".$thread->id."$tokens",
tra("Lock"),
tra("Don't allow new posts in this thread")
);
}
if ($forum->parent_type == 0) {
show_button_small(
"forum_moderate_thread.php?action=move&thread=".$thread->id."$tokens",
tra("Move"),
tra("Move this thread to a different forum")
);
}
show_button_small(
"forum_moderate_thread.php?action=title&thread=".$thread->id."$tokens",
tra("Edit title"),
tra("Edit thread title")
);
}
if (is_admin($logged_in_user)) {
show_button_small(
"forum_moderate_thread.php?action=delete&thread=".$thread->id."$tokens",
tra("Delete"),
tra("Delete thread permanently")
);
}
// let admins decide whether a news item should be exported as notice
//
if (is_news_forum($forum) && $logged_in_user && ($logged_in_user->id == $thread->owner)) {
if ($thread->status) {
show_button_small(
"forum_thread_status.php?action=clear&id=$thread->id",
tra("Export as Notice"),
"Show this message to all volunteers in the desktop GUI. Use this only for messages of interest or importance to all volunteers."
);
} else {
show_button_small(
"forum_thread_status.php?action=set&id=$thread->id",
tra("Don't export"),
tra("Don't export this news item as a Notice")
);
}
}
}
// Display a box that allows the user to select sorting of the posts
//
echo '</td><td align="right">
<input type="hidden" name="id" value="', $thread->id, '">
<div class="form-group">
';
echo select_from_array("sort", $thread_sort_styles, $sort_style);
echo ' <input class="btn btn-default btn-sm" type="submit" value="'.tra('Sort').'">
</div>
</td></tr></table>
</form><p>
';
// if it's news, show original post first
//
if (is_news_forum($forum) && !is_moderator($logged_in_user, null)) {
$sort_style = CREATE_TIME_OLD;
}
show_posts(
$thread, $forum, $start, $postid, $sort_style, $filter, $logged_in_user
);
if ($reply_url) {
//echo "<br>";
show_button(
$reply_url,
tra("Post to thread"),
tra("Add a new message to this thread")
);
}
echo "<p></p>";
show_forum_header($logged_in_user);
if (0) {
switch ($forum->parent_type) {
case 0:
show_forum_title($category, $forum, $thread);
break;
case 1:
show_team_forum_title($forum, $thread);
break;
}
}
$thread->update("views=views+1");
page_tail();
$cvs_version_tracker[]="\$Id$";
?>