2006-07-01 20:03:48 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// 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/>.
|
2006-07-01 20:03:48 +00:00
|
|
|
|
|
|
|
require_once("../inc/util.inc");
|
2006-11-04 19:21:05 +00:00
|
|
|
require_once("../inc/email.inc");
|
2006-07-01 20:03:48 +00:00
|
|
|
require_once("../project/project.inc");
|
|
|
|
|
2007-11-12 20:57:15 +00:00
|
|
|
define('MASTER_URL', $master_url);
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2007-11-18 04:10:37 +00:00
|
|
|
// send an email to admins:
|
|
|
|
// - project forums: everyone in POST_REPORT_EMAILS
|
2007-11-22 02:36:51 +00:00
|
|
|
// - team message board: team founder and admins
|
2007-11-18 04:10:37 +00:00
|
|
|
//
|
|
|
|
function mail_report_list($forum, $subject, $body, $must_send=false) {
|
|
|
|
$success = true;
|
|
|
|
switch ($forum->parent_type) {
|
|
|
|
case 0:
|
|
|
|
if ($must_send && !defined("POST_REPORT_EMAILS")) {
|
|
|
|
echo "This project has not yet defined an administrator to
|
|
|
|
handle this kind of forum report.
|
|
|
|
Please contact the project and tell them to add this information
|
|
|
|
in their html/project/project.inc file
|
|
|
|
";
|
|
|
|
}
|
|
|
|
$emails = explode("|", POST_REPORT_EMAILS);
|
|
|
|
foreach ($emails as $email) {
|
|
|
|
$admin->email_addr = $email;
|
|
|
|
if (!send_email($admin, $subject, $body)) {
|
|
|
|
$success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
$team = BoincTeam::lookup_id($forum->category);
|
|
|
|
$founder = BoincUser::lookup_id($team->userid);
|
|
|
|
$success = send_email($founder, $subject, $body);
|
2007-11-22 02:36:51 +00:00
|
|
|
$admins = BoincTeamAdmin::enum("teamid=$team->id");
|
|
|
|
foreach ($admins as $admin) {
|
|
|
|
$u = BoincUser::lookup_id($admin->userid);
|
|
|
|
$success &= send_email($u, $subject, $body);
|
|
|
|
}
|
2007-11-18 04:10:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return $success;
|
|
|
|
}
|
|
|
|
|
2007-11-28 17:40:28 +00:00
|
|
|
//////////////////// post hidden/unhidden ///////////
|
2007-11-12 20:57:15 +00:00
|
|
|
//
|
2007-11-28 17:40:28 +00:00
|
|
|
function send_moderation_email($forum, $post, $thread, $explanation, $action) {
|
2007-11-12 20:57:15 +00:00
|
|
|
$moderator=get_logged_in_user();
|
2006-07-01 20:03:48 +00:00
|
|
|
$body = "";
|
2007-11-12 20:57:15 +00:00
|
|
|
$user = BoincUser::lookup_id($post->user);
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2007-11-28 17:40:28 +00:00
|
|
|
$subject = PROJECT." moderation notice";
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2008-07-06 22:30:10 +00:00
|
|
|
$body = "Your post [ID $post->id] in thread '$thread->title'
|
2007-11-28 17:40:28 +00:00
|
|
|
".URL_BASE."forum_thread.php?id=$thread->id#$post->id
|
|
|
|
has been $action by moderator $moderator->name (ID $moderator->id).
|
|
|
|
$explanation
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2007-11-28 17:40:28 +00:00
|
|
|
The content of your post:
|
2008-07-06 22:30:10 +00:00
|
|
|
$post->content
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2006-08-09 19:12:54 +00:00
|
|
|
For further information and assistance with ".PROJECT." go to ".MASTER_URL;
|
2007-11-18 04:10:37 +00:00
|
|
|
|
2007-11-28 17:40:28 +00:00
|
|
|
$success = send_email($user, $subject, $body);
|
|
|
|
|
|
|
|
$body = "Because of moderation by $moderator->name (ID $moderator->id),
|
|
|
|
The following email was sent to $user->name (ID $user->id)
|
|
|
|
".URL_BASE."forum_user_posts.php?userid=$user->id
|
|
|
|
------------------------------
|
|
|
|
Subject: $subject
|
|
|
|
|
|
|
|
$body
|
|
|
|
";
|
2008-07-06 22:30:10 +00:00
|
|
|
$subject = PROJECT.": post $action in '$thread->title'";
|
2007-11-28 17:40:28 +00:00
|
|
|
$success &= mail_report_list($forum, $subject, $body);
|
2007-11-18 04:10:37 +00:00
|
|
|
return $success;
|
2006-07-01 20:03:48 +00:00
|
|
|
}
|
|
|
|
|
2007-11-28 17:40:28 +00:00
|
|
|
//////////////////// thread hidden/unhidden ///////////
|
2007-11-12 20:57:15 +00:00
|
|
|
//
|
2008-07-06 22:30:10 +00:00
|
|
|
function send_thread_moderation_email(
|
|
|
|
$forum, $thread, $message, $action_name, $explanation
|
|
|
|
) {
|
|
|
|
$moderator = get_logged_in_user();
|
2007-11-12 20:57:15 +00:00
|
|
|
$user = BoincUser::lookup_id($thread->owner);
|
2006-07-01 20:03:48 +00:00
|
|
|
$body = "";
|
|
|
|
|
2006-08-09 19:12:54 +00:00
|
|
|
$subject = PROJECT." forum moderation notice";
|
2008-07-06 22:30:10 +00:00
|
|
|
$body = "Your thread '$thread->title'
|
|
|
|
".URL_BASE."forum_thread.php?id=$thread->id
|
|
|
|
has been $action_name
|
|
|
|
by moderator $moderator->name (ID $moderator->id).
|
|
|
|
$explanation
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2006-08-09 19:12:54 +00:00
|
|
|
For further information and assistance with ".PROJECT." go to ".MASTER_URL;
|
2007-11-18 04:10:37 +00:00
|
|
|
|
2008-07-06 22:30:10 +00:00
|
|
|
$subject = "THREAD $action REPORT: $thread->title";
|
|
|
|
$success = mail_report_list($forum, $subject, $body);
|
2007-11-18 04:10:37 +00:00
|
|
|
$success &= send_email($user, $subject, $body);
|
|
|
|
return $success;
|
2006-07-01 20:03:48 +00:00
|
|
|
}
|
|
|
|
|
2007-11-18 04:10:37 +00:00
|
|
|
// If a user is subscribed to a thread that is replied to,
|
|
|
|
// send them an email notifying them of the reply.
|
2007-11-12 20:57:15 +00:00
|
|
|
//
|
2006-07-01 20:03:48 +00:00
|
|
|
function send_reply_notification_email($thread, $user){
|
2008-06-05 20:32:21 +00:00
|
|
|
$title = PROJECT . ": A user has posted to '". $thread->title ."'";
|
2007-11-18 22:42:47 +00:00
|
|
|
$link = URL_BASE . "forum_thread.php?id=" . $thread->id;
|
2007-12-30 22:02:16 +00:00
|
|
|
$body = "Another " . PROJECT . " user has posted to the thread
|
2008-06-05 20:32:21 +00:00
|
|
|
\"" . $thread->title . "\".\n"
|
2007-12-30 22:02:16 +00:00
|
|
|
."To view the updated thread, visit:\n$link
|
|
|
|
|
|
|
|
--------------------------
|
|
|
|
To change email preferences, visit:
|
|
|
|
".URL_BASE."edit_forum_preferences_form.php
|
|
|
|
Do not reply to this message.
|
|
|
|
";
|
2007-11-12 20:57:15 +00:00
|
|
|
return send_email($user, $title, $body);
|
2006-07-01 20:03:48 +00:00
|
|
|
}
|
|
|
|
|
2007-11-28 17:40:28 +00:00
|
|
|
//////////////////// a user clicks the red "x" to report a post ///////////
|
2007-11-12 20:57:15 +00:00
|
|
|
//
|
2007-11-18 04:10:37 +00:00
|
|
|
function send_report_post_email($user, $forum, $thread, $post, $message) {
|
2006-07-01 20:03:48 +00:00
|
|
|
$body = "";
|
2007-11-12 20:57:15 +00:00
|
|
|
$owner = BoincUser::lookup_id($post->user);
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2008-07-06 22:30:10 +00:00
|
|
|
$subject = PROJECT." post in '$thread->title' reported as offensive";
|
2006-07-01 20:03:48 +00:00
|
|
|
$body = PROJECT." notification:
|
|
|
|
|
2008-07-06 22:30:10 +00:00
|
|
|
A post in the ".PROJECT." forums was reported as offensive.
|
|
|
|
Thread: $thread->title
|
|
|
|
Post: $post->id by $owner->id ($owner->name)
|
|
|
|
Reporting User: $user->id ($user->name)
|
|
|
|
Link: ".URL_BASE."forum_thread.php?id=$thread->id#$post->id
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2008-07-06 22:30:10 +00:00
|
|
|
Comments from reporting user:
|
|
|
|
$message
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2008-07-06 22:30:10 +00:00
|
|
|
Contents of the post:
|
|
|
|
$post->content
|
2006-07-01 20:03:48 +00:00
|
|
|
|
2006-08-09 19:12:54 +00:00
|
|
|
For further information and assistance with ".PROJECT." go to ".MASTER_URL;
|
2006-11-04 19:21:05 +00:00
|
|
|
|
2007-11-18 04:24:30 +00:00
|
|
|
$success = mail_report_list($forum, $subject, $body, true);
|
|
|
|
|
|
|
|
// if it's a forum board, send to project admins too
|
|
|
|
//
|
|
|
|
if ($forum->parent_type != 0) {
|
|
|
|
$forum = new BoincForum;
|
|
|
|
$forum->parent_type = 0;
|
|
|
|
$success &= mail_report_list($forum, $subject, $body, true);
|
|
|
|
}
|
|
|
|
return $success;
|
2006-07-01 20:03:48 +00:00
|
|
|
}
|
|
|
|
|
2007-11-28 17:40:28 +00:00
|
|
|
//////////////////// a user has been banished ///////////
|
|
|
|
//
|
2007-11-18 04:10:37 +00:00
|
|
|
function send_banish_email($forum, $user, $duration, $reason) {
|
2006-08-08 20:32:37 +00:00
|
|
|
$subject = PROJECT." posting privileges suspended";
|
|
|
|
$body = "
|
|
|
|
This email is to inform you that you will not be able to
|
2007-03-24 14:57:30 +00:00
|
|
|
post to the ".PROJECT." message boards until ".date('M j, Y G:i', $duration).",
|
2006-08-08 20:32:37 +00:00
|
|
|
because your postings have not followed our guidelines.
|
|
|
|
";
|
2007-03-24 14:57:30 +00:00
|
|
|
if ($reason) {
|
|
|
|
$body .= "\n\nThe moderator gave the following explanation about your suspension:\n";
|
|
|
|
$body .= $reason;
|
|
|
|
}
|
2007-11-19 17:07:35 +00:00
|
|
|
$success = mail_report_list($forum, $user->name." has been banished.", $body);
|
2007-11-18 04:10:37 +00:00
|
|
|
$success &= send_email($user, $subject, $body);
|
|
|
|
return $success;
|
2006-08-08 20:32:37 +00:00
|
|
|
}
|
|
|
|
|
2007-11-28 17:40:28 +00:00
|
|
|
//////////////////// a banishment vote has been started ///////////
|
|
|
|
//
|
2007-10-19 20:01:36 +00:00
|
|
|
function send_banish_vote_email($user, $duration, $reason, $end_time) {
|
|
|
|
$now=time();
|
|
|
|
$subject = PROJECT." banishment vote underway";
|
|
|
|
$vote_url=parse_config(get_config(), "<master_url>")."forum_banishment_vote.php";
|
|
|
|
$body = "
|
|
|
|
This email if to inform you that a vote has been started
|
|
|
|
regarding your banishment from the ".PROJECT." message boards until ".date('M j,
|
|
|
|
Y G:i', $duration+$now).",
|
|
|
|
because your postings have not followed our guidelines.
|
|
|
|
|
|
|
|
This vote will be underway until ".date('M j, Y G:i',$end_time)." or until a majority
|
|
|
|
decision has been reached. If the vote does not result in banishment, you will be
|
|
|
|
able to resume posting at that time.
|
|
|
|
";
|
|
|
|
if ($reason) {
|
|
|
|
$body .= "\n\nThe moderator gave the following reason for your pending suspension:\n";
|
|
|
|
$body .= $reason;
|
|
|
|
}
|
|
|
|
$success = send_email($user, $subject, $body);
|
2007-11-18 04:10:37 +00:00
|
|
|
|
2007-10-19 20:01:36 +00:00
|
|
|
$body .= "\n\n<a href=".$vote_url."?action=yes&userid="
|
|
|
|
.$user->id
|
|
|
|
.">[vote to banish author]</a>\n\n"
|
|
|
|
."<a href=".$vote_url."?action=no&userid="
|
|
|
|
.$user->id
|
|
|
|
.">[vote not to banish author]</a>";
|
|
|
|
|
2007-11-18 04:10:37 +00:00
|
|
|
$forum = new BoincForum;
|
|
|
|
$forum->parent_type = 0;
|
2007-11-19 17:07:35 +00:00
|
|
|
$success &= mail_report_list($forum, "A banishment vote for ".$user->name." has been started.", $body);
|
2007-11-18 04:10:37 +00:00
|
|
|
return $success;
|
2007-10-19 20:01:36 +00:00
|
|
|
}
|
2006-07-01 20:03:48 +00:00
|
|
|
?>
|