|
1
|
|
|
<?php |
|
2
|
|
|
// This file is part of BOINC. |
|
3
|
|
|
// http://boinc.berkeley.edu |
|
4
|
|
|
// Copyright (C) 2008 University of California |
|
5
|
|
|
// |
|
6
|
|
|
// BOINC is free software; you can redistribute it and/or modify it |
|
7
|
|
|
// under the terms of the GNU Lesser General Public License |
|
8
|
|
|
// as published by the Free Software Foundation, |
|
9
|
|
|
// either version 3 of the License, or (at your option) any later version. |
|
10
|
|
|
// |
|
11
|
|
|
// BOINC is distributed in the hope that it will be useful, |
|
12
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
// See the GNU Lesser General Public License for more details. |
|
15
|
|
|
// |
|
16
|
|
|
// You should have received a copy of the GNU Lesser General Public License |
|
17
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
|
|
19
|
|
|
require_once("../inc/util.inc"); |
|
20
|
|
|
require_once("../inc/email.inc"); |
|
21
|
|
|
require_once("../project/project.inc"); |
|
22
|
|
|
|
|
23
|
|
|
// send an email to admins: |
|
24
|
|
|
// - project forums: everyone in POST_REPORT_EMAILS |
|
25
|
|
|
// - team message board: team founder and admins |
|
26
|
|
|
// |
|
27
|
|
|
function mail_report_list($forum, $subject, $body, $must_send=false) { |
|
28
|
|
|
$success = true; |
|
29
|
|
|
switch ($forum->parent_type) { |
|
30
|
|
|
case 0: |
|
31
|
|
|
if ($must_send && !defined("POST_REPORT_EMAILS")) { |
|
32
|
|
|
echo "This project has not yet defined an administrator to |
|
33
|
|
|
handle this kind of forum report. |
|
34
|
|
|
Please contact the project and tell them to add this information |
|
35
|
|
|
in their html/project/project.inc file |
|
36
|
|
|
"; |
|
37
|
|
|
} |
|
38
|
|
|
$emails = explode("|", POST_REPORT_EMAILS); |
|
39
|
|
|
foreach ($emails as $email) { |
|
40
|
|
|
$admin = new StdClass; |
|
41
|
|
|
$admin->email_addr = $email; |
|
42
|
|
|
$admin->name = "Admin"; |
|
43
|
|
|
if (!send_email($admin, $subject, $body)) { |
|
44
|
|
|
$success = false; |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
break; |
|
48
|
|
|
case 1: |
|
49
|
|
|
$team = BoincTeam::lookup_id($forum->category); |
|
50
|
|
|
$founder = BoincUser::lookup_id($team->userid); |
|
51
|
|
|
$success = send_email($founder, $subject, $body); |
|
52
|
|
|
$admins = BoincTeamAdmin::enum("teamid=$team->id"); |
|
53
|
|
|
foreach ($admins as $admin) { |
|
54
|
|
|
$u = BoincUser::lookup_id($admin->userid); |
|
55
|
|
|
if (!$u) continue; |
|
56
|
|
|
$success &= send_email($u, $subject, $body); |
|
57
|
|
|
} |
|
58
|
|
|
break; |
|
59
|
|
|
} |
|
60
|
|
|
return $success; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
//////////////////// post hidden/unhidden /////////// |
|
64
|
|
|
// |
|
65
|
|
|
function send_moderation_email($forum, $post, $thread, $explanation, $action) { |
|
66
|
|
|
global $master_url; |
|
67
|
|
|
|
|
68
|
|
|
$moderator=get_logged_in_user(); |
|
|
|
|
|
|
69
|
|
|
$body = ""; |
|
70
|
|
|
$user = BoincUser::lookup_id($post->user); |
|
71
|
|
|
|
|
72
|
|
|
$subject = PROJECT." moderation notice"; |
|
73
|
|
|
|
|
74
|
|
|
$body = "Your post [ID $post->id] in thread '$thread->title' |
|
75
|
|
|
".secure_url_base()."forum_thread.php?id=$thread->id#$post->id |
|
76
|
|
|
has been $action by moderator $moderator->name (ID $moderator->id). |
|
77
|
|
|
$explanation |
|
78
|
|
|
|
|
79
|
|
|
The content of your post: |
|
80
|
|
|
$post->content |
|
81
|
|
|
|
|
82
|
|
|
For assistance with ".PROJECT." go to ".$master_url; |
|
83
|
|
|
|
|
84
|
|
|
$success = send_email($user, $subject, $body); |
|
85
|
|
|
pm_send_msg($user, $user, $subject, $body, false); |
|
86
|
|
|
|
|
87
|
|
|
$body = "Because of moderation by $moderator->name (ID $moderator->id), |
|
88
|
|
|
The following email was sent to $user->name (ID $user->id) |
|
89
|
|
|
".secure_url_base()."forum_user_posts.php?userid=$user->id |
|
90
|
|
|
------------------------------ |
|
91
|
|
|
Subject: $subject |
|
92
|
|
|
|
|
93
|
|
|
$body |
|
94
|
|
|
"; |
|
95
|
|
|
$subject = PROJECT.": post $action in '$thread->title'"; |
|
96
|
|
|
$success &= mail_report_list($forum, $subject, $body); |
|
97
|
|
|
return $success; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
//////////////////// thread hidden/unhidden /////////// |
|
101
|
|
|
// |
|
102
|
|
|
function send_thread_moderation_email( |
|
103
|
|
|
$forum, $thread, $message, $action_name, $explanation |
|
|
|
|
|
|
104
|
|
|
) { |
|
105
|
|
|
global $master_url; |
|
106
|
|
|
|
|
107
|
|
|
$moderator = get_logged_in_user(); |
|
|
|
|
|
|
108
|
|
|
$user = BoincUser::lookup_id($thread->owner); |
|
109
|
|
|
$body = ""; |
|
110
|
|
|
|
|
111
|
|
|
$subject = PROJECT." forum moderation notice"; |
|
112
|
|
|
$body = "Your thread '$thread->title' |
|
113
|
|
|
".secure_url_base()."forum_thread.php?id=$thread->id |
|
114
|
|
|
has been $action_name by moderator $moderator->name (ID $moderator->id). |
|
115
|
|
|
$explanation |
|
116
|
|
|
|
|
117
|
|
|
For assistance with ".PROJECT." go to ".$master_url; |
|
118
|
|
|
|
|
119
|
|
|
$subject = "THREAD $action REPORT: $thread->title"; |
|
|
|
|
|
|
120
|
|
|
$success = mail_report_list($forum, $subject, $body); |
|
121
|
|
|
$success &= send_email($user, $subject, $body); |
|
122
|
|
|
pm_send_msg($user, $user, $subject, $body, false); |
|
123
|
|
|
return $success; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
// There's a new post in the thread, which the user is subscribed to. |
|
127
|
|
|
// send them an email notifying them. |
|
128
|
|
|
// |
|
129
|
|
|
function send_thread_notification_email($thread, $user){ |
|
130
|
|
|
$title = PROJECT . ": there is a new post in '". $thread->title ."'"; |
|
131
|
|
|
$link = secure_url_base() . "forum_thread.php?id=" . $thread->id; |
|
132
|
|
|
$body = "A " . PROJECT . " user has posted to the thread |
|
133
|
|
|
\"" . $thread->title . "\".\n" |
|
134
|
|
|
."To view the updated thread, visit:\n$link |
|
135
|
|
|
|
|
136
|
|
|
-------------------------- |
|
137
|
|
|
To change email preferences, visit: |
|
138
|
|
|
".secure_url_base()."edit_forum_preferences_form.php |
|
139
|
|
|
Do not reply to this message. |
|
140
|
|
|
"; |
|
141
|
|
|
return send_email($user, $title, $body); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
// There's a new thread in the forum, which the user is subscribed to. |
|
145
|
|
|
// send them an email notifying them. |
|
146
|
|
|
// |
|
147
|
|
|
function send_forum_notification_email($forum, $user){ |
|
148
|
|
|
$title = PROJECT . ": there is a new thread in '". $forum->title ."'"; |
|
149
|
|
|
$link = secure_url_base() . "forum_forum.php?id=" . $forum->id; |
|
150
|
|
|
$body = "A " . PROJECT . " user has added a thread to the forum |
|
151
|
|
|
\"" . $thread->title . "\".\n" |
|
|
|
|
|
|
152
|
|
|
."To view the updated forum, visit:\n$link |
|
153
|
|
|
|
|
154
|
|
|
-------------------------- |
|
155
|
|
|
To change email preferences, visit: |
|
156
|
|
|
".secure_url_base()."edit_forum_preferences_form.php |
|
157
|
|
|
Do not reply to this message. |
|
158
|
|
|
"; |
|
159
|
|
|
return send_email($user, $title, $body); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
//////////////////// a user clicks the red "x" to report a post /////////// |
|
163
|
|
|
// |
|
164
|
|
|
function send_report_post_email($user, $forum, $thread, $post, $message) { |
|
165
|
|
|
global $master_url; |
|
166
|
|
|
|
|
167
|
|
|
$body = ""; |
|
168
|
|
|
$owner = BoincUser::lookup_id($post->user); |
|
169
|
|
|
|
|
170
|
|
|
$subject = PROJECT." post in '$thread->title' reported as offensive"; |
|
171
|
|
|
$body = PROJECT." notification: |
|
172
|
|
|
|
|
173
|
|
|
A post in the ".PROJECT." forums was reported as offensive. |
|
174
|
|
|
Thread: $thread->title |
|
175
|
|
|
Post: $post->id by $owner->id ($owner->name) |
|
176
|
|
|
Reporting User: $user->id ($user->name) |
|
177
|
|
|
Link: ".secure_url_base()."forum_thread.php?id=$thread->id#$post->id |
|
178
|
|
|
|
|
179
|
|
|
Comments from reporting user: |
|
180
|
|
|
$message |
|
181
|
|
|
|
|
182
|
|
|
Contents of the post: |
|
183
|
|
|
$post->content |
|
184
|
|
|
|
|
185
|
|
|
For assistance with ".PROJECT." go to ".$master_url; |
|
186
|
|
|
|
|
187
|
|
|
$success = mail_report_list($forum, $subject, $body, true); |
|
188
|
|
|
|
|
189
|
|
|
// if it's a forum board, send to project admins too |
|
190
|
|
|
// |
|
191
|
|
|
if ($forum->parent_type != 0) { |
|
192
|
|
|
$forum = new BoincForum; |
|
193
|
|
|
$forum->parent_type = 0; |
|
194
|
|
|
$success &= mail_report_list($forum, $subject, $body, true); |
|
195
|
|
|
} |
|
196
|
|
|
return $success; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
//////////////////// a user has been banished /////////// |
|
200
|
|
|
// |
|
201
|
|
|
function send_banish_email($forum, $user, $duration, $reason) { |
|
202
|
|
|
$subject = PROJECT." posting privileges suspended"; |
|
203
|
|
|
$body = " |
|
204
|
|
|
You will not be able to post to the ".PROJECT." message boards |
|
205
|
|
|
until ".date('M j, Y G:i', $duration).", |
|
206
|
|
|
because your postings have not followed our guidelines. |
|
207
|
|
|
"; |
|
208
|
|
|
if ($reason) { |
|
209
|
|
|
$body .= "\n\nThe moderator gave the following explanation about your suspension:\n"; |
|
210
|
|
|
$body .= $reason; |
|
211
|
|
|
} |
|
212
|
|
|
$success = mail_report_list($forum, "$user->name (ID $user->id) has been banished.", $body); |
|
213
|
|
|
$success &= send_email($user, $subject, $body); |
|
214
|
|
|
pm_send_msg($user, $user, $subject, $body, false); |
|
215
|
|
|
return $success; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
//////////////////// a banishment vote has been started /////////// |
|
219
|
|
|
// |
|
220
|
|
|
function send_banish_vote_email($user, $duration, $reason, $end_time) { |
|
221
|
|
|
global $master_url; |
|
222
|
|
|
$now=time(); |
|
223
|
|
|
$subject = PROJECT." banishment vote underway"; |
|
224
|
|
|
$vote_url = $master_url."forum_banishment_vote.php"; |
|
225
|
|
|
$body = " |
|
226
|
|
|
A vote has been started to banish you |
|
227
|
|
|
from the ".PROJECT." message boards until ".date('M j, |
|
228
|
|
|
Y G:i', $duration+$now).", |
|
229
|
|
|
because your postings have not followed our guidelines. |
|
230
|
|
|
|
|
231
|
|
|
This vote will last until ".date('M j, Y G:i',$end_time)." or until a majority |
|
232
|
|
|
decision has been reached. If the vote does not result in banishment, you will be |
|
233
|
|
|
able to resume posting at that time. |
|
234
|
|
|
"; |
|
235
|
|
|
if ($reason) { |
|
236
|
|
|
$body .= "\n\nThe moderator gave the following reason for your pending suspension:\n"; |
|
237
|
|
|
$body .= $reason; |
|
238
|
|
|
} |
|
239
|
|
|
$success = send_email($user, $subject, $body); |
|
240
|
|
|
pm_send_msg($user, $user, $subject, $body, false); |
|
241
|
|
|
|
|
242
|
|
|
$body .= "\n\n<a href=".$vote_url."?action=yes&userid=" |
|
243
|
|
|
.$user->id |
|
244
|
|
|
.">[vote to banish author]</a>\n\n" |
|
245
|
|
|
."<a href=".$vote_url."?action=no&userid=" |
|
246
|
|
|
.$user->id |
|
247
|
|
|
.">[vote not to banish author]</a>"; |
|
248
|
|
|
|
|
249
|
|
|
$forum = new BoincForum; |
|
250
|
|
|
$forum->parent_type = 0; |
|
251
|
|
|
$success &= mail_report_list($forum, "A banishment vote for ".$user->name." has been started.", $body); |
|
252
|
|
|
return $success; |
|
253
|
|
|
} |
|
254
|
|
|
?> |
|
255
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.