2006-07-01 20:03:48 +00:00
< ? php
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-12 20:57:15 +00:00
// If a post is hidden, this function emails the author
// to let them know what happened.
//
function send_moderation_email ( $post , $thread , $message , $action ) {
$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 );
2007-01-01 21:18:49 +00:00
$subject = PROJECT . " forum " . $action . " notice " ;
2006-07-01 20:03:48 +00:00
$body = PROJECT . " notification:
2007-11-12 20:57:15 +00:00
$ownerid = $user -> id ;
2006-07-01 20:03:48 +00:00
2006-08-09 19:12:54 +00:00
This email is to inform you that one of your posts in the forum has been affected by moderation in " .PROJECT. " :
2007-11-12 20:57:15 +00:00
Thread : " . $thread->title . "
Post : " . $post->id . " by " . $user->id . " ( " . $user->name . " )
Link : " .URL_BASE. " / forum_thread . php ? id = " . $thread->id . "
Moderator : " . $moderator->name . " ( " . $moderator->id . " )
2007-01-01 21:18:49 +00:00
Action : " . $action . "
2006-07-01 20:03:48 +00:00
The moderator gave this explanation to why your post was moderated :
" . $message ;
$body .= "
2006-08-09 19:12:54 +00:00
This was the content of your post :
2007-11-12 20:57:15 +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-01-01 21:18:49 +00:00
$emails = explode ( " | " , POST_REPORT_EMAILS );
$success = true ;
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
2007-11-12 20:57:15 +00:00
if ( ! send_email ( $admin , " POST " . $action . " REPORT: " . $thread -> title , $body )) {
2007-01-01 21:18:49 +00:00
$success = false ;
}
}
2007-11-12 20:57:15 +00:00
return send_email ( $user , $subject , $body );
2006-07-01 20:03:48 +00:00
}
2007-11-12 20:57:15 +00:00
// If an entire thread is hidden, this function emails the owner
// to let them know what happened.
//
2007-01-01 21:18:49 +00:00
function send_thread_moderation_email ( $thread , $message , $action ) {
2007-11-12 20:57:15 +00:00
$moderator = get_logged_in_user ();
$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 " ;
2006-07-01 20:03:48 +00:00
$body = PROJECT . " notification:
This email is sent to inform you that one of your threads in the forum has been affected by moderation in " .PROJECT. " :
2007-11-12 20:57:15 +00:00
Thread : " . $thread->title . "
Link : " .MASTER_URL. " forum_thread . php ? id = " . $thread->id . "
Moderator : " . $moderator->name . " ( " . $moderator->id . " )
2007-01-01 21:18:49 +00:00
Action : " . $action . "
2006-07-01 20:03:48 +00:00
The moderator gave this explanation to why your thread was moderated :
" . $message ;
$body .= "
2006-08-09 19:12:54 +00:00
For further information and assistance with " .PROJECT. " go to " .MASTER_URL;
2007-01-01 21:18:49 +00:00
$emails = explode ( " | " , POST_REPORT_EMAILS );
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
2007-11-12 20:57:15 +00:00
if ( ! send_email ( $admin , " THREAD " . $action . " REPORT: " . $thread -> title , $body )) {
2007-01-01 21:18:49 +00:00
$success = false ;
}
}
2007-11-12 20:57:15 +00:00
return send_email ( $user , $subject , $body );
2006-07-01 20:03:48 +00:00
}
2007-11-12 20:57:15 +00:00
// If a user is subscribed to a thread that is replied to, this
// function sends them an email notifying them of the reply.
//
2006-07-01 20:03:48 +00:00
function send_reply_notification_email ( $thread , $user ){
2007-11-12 20:57:15 +00:00
$title = PROJECT . " : A user has posted to ' " . stripslashes ( $thread -> title ) . " ' " ;
$link = URL_BASE . " /forum_thread.php?id= " . $thread -> id ;
$body = " Another " . PROJECT . " user has posted to the thread \" " . stripslashes ( $thread -> title ) . " \" . \n "
2006-07-01 20:03:48 +00:00
. " To view the updated thread, visit the following URL: \n \n $link " ;
2007-11-12 20:57:15 +00:00
return send_email ( $user , $title , $body );
2006-07-01 20:03:48 +00:00
}
2007-11-12 20:57:15 +00:00
// When a user clicks the red "x" to notify moderators about a post,
// this function generates the email to let the moderators know about it.
//
2006-07-01 20:03:48 +00:00
function send_report_post_email ( $user , $thread , $post , $message ) {
$body = " " ;
2007-11-12 20:57:15 +00:00
$owner = BoincUser :: lookup_id ( $post -> user );
2006-07-01 20:03:48 +00:00
2007-11-12 20:57:15 +00:00
$subject = PROJECT . " post in ' " . $thread -> title . " ' reported as offensive " ;
2006-07-01 20:03:48 +00:00
$body = PROJECT . " notification:
This email is sent to inform you that one of the posts in the forum was reported as offensive in " .PROJECT. " :
2007-11-12 20:57:15 +00:00
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
The reporting user gave this explanation to why the post was reported :
" . $message . "
This was the contents of the post :
2007-11-12 20:57:15 +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;
2006-11-04 19:21:05 +00:00
2006-07-01 20:03:48 +00:00
//Security check, do we have an admin?
2006-11-04 19:21:05 +00:00
if ( ! defined ( " POST_REPORT_EMAILS " )) error_page ( " This project has not yet defined an administrator to handle this kind of forum reports. Please contact the project and tell them to add this information in their html/project/project.inc file " );
$emails = explode ( " | " , POST_REPORT_EMAILS );
$success = true ;
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
if ( ! send_email ( $admin , $subject , $body )) {
$success = false ;
}
}
return success ;
2006-07-01 20:03:48 +00:00
}
2007-03-24 14:57:30 +00:00
function send_banish_email ( $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 \n The moderator gave the following explanation about your suspension: \n " ;
$body .= $reason ;
}
2007-01-01 21:18:49 +00:00
$emails = explode ( " | " , POST_REPORT_EMAILS );
$success = true ;
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
2007-11-12 20:57:15 +00:00
if ( ! send_email ( $admin , $user -> name . " has been banished. " , $body )) {
2007-01-01 21:18:49 +00:00
$success = false ;
}
}
2007-11-12 20:57:15 +00:00
return send_email ( $user , $subject , $body );
2006-08-08 20:32:37 +00:00
}
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 \n The moderator gave the following reason for your pending suspension: \n " ;
$body .= $reason ;
}
$success = send_email ( $user , $subject , $body );
$emails = explode ( " | " , POST_REPORT_EMAILS );
$success = true ;
$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> " ;
foreach ( $emails as $email ) {
$admin -> email_addr = $email ;
if ( ! send_email ( $admin , " A banishment vote for " . $user -> name . " has been started. " , $body )) {
$success = false ;
}
}
}
2006-07-01 20:03:48 +00:00
?>