*** empty log message ***

svn path=/trunk/boinc/; revision=10559
This commit is contained in:
David Anderson 2006-07-01 20:03:48 +00:00
parent b938a00b86
commit aeac868c11
10 changed files with 213 additions and 183 deletions

View File

@ -7156,3 +7156,25 @@ Charlie 1 July 2006 (branch boinc_core_release_5_6)
- Tag for 5.5.5 release, Macinitosh with sandbox only - Tag for 5.5.5 release, Macinitosh with sandbox only
boinc_core_release_5_5_5 boinc_core_release_5_5_5
David 1 July 2006
- user web: moved forum-related email functions to a new file;
small bug fixes in forum moderation code
- changed db/schema.sql to match new forum code
- user web: html/project/project.inc must now have
define("FORUM_MODERATION_EMAIL_USER_ID", "N")
to specify who reports get sent to
(the ID of an existing account)
db/
schema.sql
html/
inc/
email.inc
forum_email.inc (new)
user/
edit_forum_preferences_form.php
forum_moderate_post_action.php
forum_moderate_thread_action.php
forum_post.php
forum_reply.php
forum_report_post.php

View File

@ -349,6 +349,7 @@ create table thread (
id integer not null auto_increment, id integer not null auto_increment,
forum integer not null, forum integer not null,
owner integer not null, owner integer not null,
status integer not null,
title varchar(254) not null, title varchar(254) not null,
timestamp integer not null, timestamp integer not null,
-- time of last new or modified post -- time of last new or modified post
@ -361,6 +362,8 @@ create table thread (
-- (set periodically by update_forum_activity.php) -- (set periodically by update_forum_activity.php)
sufferers integer not null, sufferers integer not null,
-- in help desk: # people who indicated they had same problem -- in help desk: # people who indicated they had same problem
score double not null,
votes integer not null,
create_time integer not null, create_time integer not null,
-- when this record was created -- when this record was created
hidden integer not null, hidden integer not null,
@ -395,7 +398,8 @@ create table post (
-- --
create table subscriptions ( create table subscriptions (
userid integer not null, userid integer not null,
threadid integer not null threadid integer not null,
notified_time integer not null default 0
) type=InnoDB; ) type=InnoDB;
create table forum_preferences ( create table forum_preferences (
@ -404,19 +408,21 @@ create table forum_preferences (
posts integer not null default 0, posts integer not null default 0,
last_post integer not null, last_post integer not null,
avatar varchar(254) not null default '', avatar varchar(254) not null default '',
avatar_type tinyint(4) not null default 0,
hide_avatars tinyint(1) unsigned not null default 0, hide_avatars tinyint(1) unsigned not null default 0,
sorting varchar(100) not null default '', forum_sorting integer not null,
no_signature_by_default tinyint(1) unsigned not null default 0, thread_sorting integer not null,
no_signature_by_default tinyint(1) unsigned not null default 1,
images_as_links tinyint(1) unsigned not null default 0, images_as_links tinyint(1) unsigned not null default 0,
link_popup tinyint(1) unsigned not null default 0, link_popup tinyint(1) unsigned not null default 0,
mark_as_read_timestamp integer not null default 0, mark_as_read_timestamp integer not null default 0,
special_user integer not null default 0, special_user integer not null default 0,
jump_to_unread tinyint(1) unsigned not null default 0, jump_to_unread tinyint(1) unsigned not null default 1,
hide_signatures tinyint(1) unsigned not null default 0, hide_signatures tinyint(1) unsigned not null default 0,
rated_posts varchar(254) not null, rated_posts varchar(254) not null,
low_rating_threshold integer not null, low_rating_threshold integer not null default -25,
high_rating_threshold integer not null, high_rating_threshold integer not null default 5,
minimum_wrap_postcount INT DEFAULT 100 NOT NULL,
display_wrap_postcount INT DEFAULT 75 NOT NULL,
ignorelist varchar(254) not null, ignorelist varchar(254) not null,
ignore_sticky_posts tinyint(1) unsigned not null, ignore_sticky_posts tinyint(1) unsigned not null,
primary key (userid) primary key (userid)
@ -428,3 +434,10 @@ create table forum_logging (
timestamp integer not null default 0, timestamp integer not null default 0,
primary key (userid,threadid) primary key (userid,threadid)
) TYPE=MyISAM; ) TYPE=MyISAM;
create table post_ratings (
post integer not null,
user integer not null,
rating tinyint not null,
primary key(post, user)
) TYPE=MyISAM;

View File

@ -15,9 +15,8 @@ if (isset($USE_PHPMAILER)) {
$USE_PHPMAILER = false; $USE_PHPMAILER = false;
} }
/** // Function sends an email, either using PHPMailer or not.
* Function sends an email, either using PHPMailer or not. //
**/
function send_email($user, $subject, $body) { function send_email($user, $subject, $body) {
global $USE_PHPMAILER; global $USE_PHPMAILER;
global $PHPMAILER_HOST; global $PHPMAILER_HOST;
@ -43,35 +42,6 @@ function send_email($user, $subject, $body) {
} }
} }
/**
* Send mail using the new User object style
**/
function re_send_email($user, $subject, $body) {
global $USE_PHPMAILER;
global $PHPMAILER_HOST;
global $PHPMAILER_MAILER;
if ($USE_PHPMAILER) {
$mail = new PHPMailer();
$mail->AddAddress($user->getEmail(), $user->getName());
$mail->Subject = $subject;
$mail->Body = $body;
$mail->From = EMAIL_FROM;
$mail->FromName = EMAIL_FROM;
$mail->Host = $PHPMAILER_HOST;
$mail->Mailer = $PHPMAILER_MAILER;
return $mail->Send();
} else {
if (defined('EMAIL_FROM')) {
$headers = "From: ". EMAIL_FROM;
} else {
$headers ="";
}
return mail($user->getEmail(), $subject, $body, $headers);
}
}
function send_verify_email($old, $new, $user) { function send_verify_email($old, $new, $user) {
$x = md5($new.$user->authenticator); $x = md5($new.$user->authenticator);
mail( mail(
@ -84,35 +54,16 @@ To validate the new address, visit the URL:
); );
} }
/** // Send an email describing an account to the user.
* Send a link to a user that makes it possible for the user to validate the email address // There are a few scenarios:
* This function uses the new User object style //
**/ // 1) the account was created by user via web.
function send_verifier($user) { // In this case they're currently looking at the "validate account" page
$x = md5($user->getEmail().$user->getAuthenticator()); // (account_created.php), although they might have strayed
re_send_email( // so we need to give them a link.
$user, // 2) the account was created administratively
PROJECT." email verification", // 3) the user requested account key for existing account
"You have requested to validate the email address you have registered with " . PROJECT . //
".
To validate the address, please visit the URL:
".URL_BASE."validate_email.php?u=".$user->getID()."&x=$x
"
);
}
/**
* Send an email describing an account to the user.
* There are a few scenarios:
*
* 1) the account was created by user via web.
* In this case they're currently looking at the "validate account" page
* (account_created.php), although they might have strayed
* so we need to give them a link.
* 2) the account was created administratively
* 3) the user requested account key for existing account
**/
function send_auth_email($user, $is_new) { function send_auth_email($user, $is_new) {
global $master_url; global $master_url;
$body = ""; $body = "";
@ -146,10 +97,9 @@ For further information and assistance with ".PROJECT." go to $master_url
return send_email($user, $subject, $body); return send_email($user, $subject, $body);
} }
/** // Function simply outputs some text letting the user know
* Function simply outputs some text letting the user know // their authenticator was emailed to them.
* their authenticator was emailed to them. //
**/
function email_sent_message($email_addr) { function email_sent_message($email_addr) {
if (defined('EMAIL_FROM')) { if (defined('EMAIL_FROM')) {
$email_from = EMAIL_FROM; $email_from = EMAIL_FROM;
@ -167,12 +117,12 @@ function email_sent_message($email_addr) {
"; ";
} }
/** a valid email address is of the form A@B.C // a valid email address is of the form A@B.C
* where A, B, C are nonempty, // where A, B, C are nonempty,
* A and B don't contain @ or ., // A and B don't contain @ or .,
* and C doesn't contain @ (but can contain .) // and C doesn't contain @ (but can contain .)
**/ // TODO: Replace this with some regex. Please.
// TODO: Replace this with some regex. Please. //
function is_valid_email_addr($addr) { function is_valid_email_addr($addr) {
$x = strstr($addr, "@"); $x = strstr($addr, "@");
if (!$x) return false; if (!$x) return false;
@ -187,74 +137,9 @@ function is_valid_email_addr($addr) {
} }
/** // If a user's host is identified as causing problems, this email is sent
* If a post is hidden, this function emails the author // to the owner to let them know.
* to let them know what happened. //
**/
function send_moderation_email($post, $message) {
global $master_url;
$body = "";
$thread = $post->getThread();
$subject = PROJECT." forum moderation notice for $user->name";
$body = PROJECT." notification:
This email is sent to inform you that one of your posts in the forum has been affected by moderation in ".PROJECT.":
Thread: ".$thread->getTitle()."
Link: ".$master_url."/forum_thread.php?id=".$thread->getID()."
The moderator gave this explanation to why your post was moderated:
".$message;
$body .= "
This was the contents of your post:
".$post->getContent()."
For further information and assistance with ".PROJECT." go to ".$master_url;
return send_email($post->getOwner(), $subject, $body);
}
/**
* If an entire thread is hidden, this function emails the owner
* to let them know what happened.
*/
function send_thread_moderation_email($thread, $message) {
global $master_url;
$user = $thread->getOwner();
$body = "";
$subject = PROJECT." forum moderation notice for $user->name";
$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.":
Thread: ".$thread->getTitle()."
Link: ".$master_url."/forum_thread.php?id=".$thread->getID()."
The moderator gave this explanation to why your thread was moderated:
".$message;
$body .= "
For further information and assistance with ".PROJECT." go to ".$master_url;
return send_email($user, $subject, $body);
}
/**
* If a user is subscribed to a thread that is replied to, this
* function sends them an email notifying them of the reply.
**/
function send_reply_notification_email($thread, $user){
$title = PROJECT . ": A user has posted to '". stripslashes($thread->getTitle()) ."'";
$link = URL_BASE . "forum_thread.php?id=" . $thread->getID();
$body = "Another " . PROJECT . " user has posted to the thread \"" . stripslashes($thread->getTitle()) . "\".\n"
."To view the updated thread, visit the following URL:\n\n$link";
return re_send_email($user, $title, $body);
}
/**
* If a user's host is identified as causing problems, this email is sent
* to the owner to let them know.
**/
function send_problem_email($user, $host) { function send_problem_email($user, $host) {
global $master_url; global $master_url;
$body = ""; $body = "";
@ -330,36 +215,4 @@ For further information and assistance with ".PROJECT." go to $master_url";
} }
/**
* 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.
**/
function send_report_post_email($user, $thread, $post, $message) {
global $master_url;
global $forum_post_reporting_admin;
$body = "";
$subject = PROJECT." post in '".$thread->getTitle()."' reported as offensive";
$body = PROJECT." notification:
This email is sent to inform you that one of the posts in the forum was reported as offensive in ".PROJECT.":
Thread: ".$thread->getTitle()."
Post: ".$post->getID()."
Link: $master_url/forum_thread.php?id=".$thread->getID()."#".$post->getID()."
The reporting user gave this explanation to why the post was reported:
".$message."
This was the contents of the post:
".$post->getContent()."
For further information and assistance with ".PROJECT." go to $master_url";
//Security check, do we have an admin?
if (!$forum_post_reporting_admin) 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");
return send_email($forum_post_reporting_admin, $subject, $body);
}
?> ?>

141
html/inc/forum_email.inc Normal file
View File

@ -0,0 +1,141 @@
<?php
require_once("../inc/util.inc");
require_once("../project/project.inc");
// Determine if phpmailer is installed and to be used (defined in project.inc)
if (isset($USE_PHPMAILER)) {
if ($USE_PHPMAILER) {
require_once("../inc/phpmailer/class.phpmailer.php");
}
} else {
$USE_PHPMAILER = false;
}
if (FORUM_MODERATION_EMAIL) {
}
/**
* Send mail using the new User object style
**/
function re_send_email($user, $subject, $body) {
global $USE_PHPMAILER;
global $PHPMAILER_HOST;
global $PHPMAILER_MAILER;
if ($USE_PHPMAILER) {
$mail = new PHPMailer();
$mail->AddAddress($user->getEmail(), $user->getName());
$mail->Subject = $subject;
$mail->Body = $body;
$mail->From = EMAIL_FROM;
$mail->FromName = EMAIL_FROM;
$mail->Host = $PHPMAILER_HOST;
$mail->Mailer = $PHPMAILER_MAILER;
return $mail->Send();
} else {
if (defined('EMAIL_FROM')) {
$headers = "From: ". EMAIL_FROM;
} else {
$headers ="";
}
return mail($user->getEmail(), $subject, $body, $headers);
}
}
/**
* If a post is hidden, this function emails the author
* to let them know what happened.
**/
function send_moderation_email($post, $message) {
global $master_url;
$body = "";
$thread = $post->getThread();
$subject = PROJECT." forum moderation notice for $user->name";
$body = PROJECT." notification:
This email is sent to inform you that one of your posts in the forum has been affected by moderation in ".PROJECT.":
Thread: ".$thread->getTitle()."
Link: ".$master_url."/forum_thread.php?id=".$thread->getID()."
The moderator gave this explanation to why your post was moderated:
".$message;
$body .= "
This was the contents of your post:
".$post->getContent()."
For further information and assistance with ".PROJECT." go to ".$master_url;
return re_send_email($post->getOwner(), $subject, $body);
}
/**
* If an entire thread is hidden, this function emails the owner
* to let them know what happened.
*/
function send_thread_moderation_email($thread, $message) {
global $master_url;
$user = $thread->getOwner();
$body = "";
$subject = PROJECT." forum moderation notice for $user->name";
$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.":
Thread: ".$thread->getTitle()."
Link: ".$master_url."/forum_thread.php?id=".$thread->getID()."
The moderator gave this explanation to why your thread was moderated:
".$message;
$body .= "
For further information and assistance with ".PROJECT." go to ".$master_url;
return re_send_email($user, $subject, $body);
}
/**
* If a user is subscribed to a thread that is replied to, this
* function sends them an email notifying them of the reply.
**/
function send_reply_notification_email($thread, $user){
$title = PROJECT . ": A user has posted to '". stripslashes($thread->getTitle()) ."'";
$link = URL_BASE . "forum_thread.php?id=" . $thread->getID();
$body = "Another " . PROJECT . " user has posted to the thread \"" . stripslashes($thread->getTitle()) . "\".\n"
."To view the updated thread, visit the following URL:\n\n$link";
return re_send_email($user, $title, $body);
}
/**
* 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.
**/
function send_report_post_email($user, $thread, $post, $message) {
global $master_url;
$forum_post_reporting_admin = newUser(FORUM_MODERATION_EMAIL_USER_ID);
$body = "";
$subject = PROJECT." post in '".$thread->getTitle()."' reported as offensive";
$body = PROJECT." notification:
This email is sent to inform you that one of the posts in the forum was reported as offensive in ".PROJECT.":
Thread: ".$thread->getTitle()."
Post: ".$post->getID()."
Link: $master_url/forum_thread.php?id=".$thread->getID()."#".$post->getID()."
The reporting user gave this explanation to why the post was reported:
".$message."
This was the contents of the post:
".$post->getContent()."
For further information and assistance with ".PROJECT." go to $master_url";
//Security check, do we have an admin?
if (!$forum_post_reporting_admin) 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");
return re_send_email($forum_post_reporting_admin, $subject, $body);
}
?>

View File

@ -2,6 +2,7 @@
require_once("../inc/db.inc"); require_once("../inc/db.inc");
require_once("../inc/forum.inc"); require_once("../inc/forum.inc");
require_once("../inc/forum_std.inc");
require_once("../inc/util.inc"); require_once("../inc/util.inc");
db_init(); db_init();

View File

@ -5,7 +5,7 @@
**/ **/
require_once("../inc/forum.inc"); require_once("../inc/forum.inc");
require_once("../inc/email.inc"); require_once("../inc/forum_email.inc");
require_once("../inc/forum_std.inc"); require_once("../inc/forum_std.inc");
db_init(); db_init();

View File

@ -5,7 +5,7 @@
**/ **/
require_once("../inc/forum.inc"); require_once("../inc/forum.inc");
require_once("../inc/email.inc"); require_once("../inc/forum_email.inc");
require_once("../inc/forum_std.inc"); require_once("../inc/forum_std.inc");

View File

@ -5,7 +5,7 @@
* it will apply the changes by calling methods on the forum * it will apply the changes by calling methods on the forum
**/ **/
require_once('../inc/email.inc'); require_once('../inc/forum_email.inc');
require_once('../inc/forum.inc'); require_once('../inc/forum.inc');
require_once('../inc/forum_std.inc'); require_once('../inc/forum_std.inc');

View File

@ -4,7 +4,7 @@
* action take place here. * action take place here.
**/ **/
require_once('../inc/email.inc'); require_once('../inc/forum_email.inc');
require_once('../inc/forum.inc'); require_once('../inc/forum.inc');
require_once('../inc/forum_std.inc'); require_once('../inc/forum_std.inc');

View File

@ -7,7 +7,7 @@
**/ **/
require_once('../inc/forum.inc'); require_once('../inc/forum.inc');
require_once('../inc/email.inc'); require_once('../inc/forum_email.inc');
require_once('../inc/forum_std.inc'); require_once('../inc/forum_std.inc');
db_init(); db_init();