diff --git a/html/inc/forum.inc b/html/inc/forum.inc index 8170d14afd..93a67074c0 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -7,6 +7,7 @@ require_once('../inc/time.inc'); require_once('../inc/forum_moderators.inc'); require_once('../inc/text_transform.inc'); require_once('../inc/util.inc'); +require_once('../inc/forum_pm.inc'); define('AVATAR_WIDTH', 100); define('AVATAR_HEIGHT',100); diff --git a/html/inc/forum_pm.inc b/html/inc/forum_pm.inc new file mode 100644 index 0000000000..8ac88d1283 --- /dev/null +++ b/html/inc/forum_pm.inc @@ -0,0 +1,88 @@ +\n"; + echo " Inbox\n"; + echo " | Write\n"; + echo " | Forum index\n"; + echo "\n"; +} + +function pm_create_new($error = null) { + page_head("Private messages : Create new"); + pm_header(); + + global $logged_in_user; + $replyto = get_int("replyto", true); + $userid = get_int("userid", true); + + if ($replyto) { + $message = mysql_query("SELECT * FROM private_messages WHERE userid=".$logged_in_user->id." AND id=$replyto"); + if ($message) { + $message = mysql_fetch_object($message); + $content = "[quote]".$message->content."[/quote]\n"; + $userid = $message->senderid; + $user = get_user_from_id($userid); + if ($user != null) { + $writeto = $userid." (".$user->name.")"; + } + $subject = $message->subject; + if (substr($subject, 0, 3) != "re:") { + $subject = "re: ".$subject; + } + } + } elseif ($userid) { + $user = get_user_from_id($userid); + if ($user != null) { + $writeto = $userid." (".$user->name.")"; + } + } else { + $writeto = post_str("to", true); + $subject = post_str("subject", true); + $content = post_str("content", true); + } + + $subject = htmlspecialchars($subject); + + if ($error != null) { + echo "
$error
\n"; + } + + echo "
\n"; + echo "\n"; + echo form_tokens($logged_in_user->authenticator); + start_table(); + echo "To
User IDs or unique usernames, separated with commas\n"; + echo "\n"; + echo "Subject\n"; + echo "Message
".html_info()."\n"; + echo "\n"; + echo "\n"; + end_table(); + + page_tail(); + exit(); +} + +function pm_send($to, $subject, $content) { + global $logged_in_user; + $userid = $to->id; + $senderid = $logged_in_user->id; + $sql_subject = mysql_real_escape_string($subject); + $sql_content = mysql_real_escape_string($content); + mysql_query("INSERT INTO private_messages (userid, senderid, date, subject, content) VALUES ($userid, $senderid, UNIX_TIMESTAMP(), '$sql_subject', '$sql_content')"); + if ($to->send_email == 1) { // Send email notification + $message = "Dear ".$to->name.",\n\n"; + $message .= "You have received a new private message at ".PROJECT." from ".$logged_in_user->name.", entitled \"".$subject."\".\n\n"; + $message .= "To read the original version, respond to, or delete this message, you must log in here:\n"; + $message .= URL_BASE."forum_pm.php\n\n"; + $message .= "Do not reply to this message. To disable email notification, go to\n"; + $message .= URL_BASE."prefs.php?subset=project\n"; + $message .= "and change email notification settings.\n"; + + send_email($to, "[".PROJECT."] Private message notification", $message); + } +} + +?> diff --git a/html/user/forum_pm.php b/html/user/forum_pm.php index d88d94e3eb..280543e27f 100644 --- a/html/user/forum_pm.php +++ b/html/user/forum_pm.php @@ -17,7 +17,11 @@ $logged_in_user = get_logged_in_user(); if ($action == "inbox") { page_head("Private messages : Inbox"); pm_header(); - + + if (get_int("sent", true) == 1) { + echo "
Your message has been sent.
\n"; + } + $query = mysql_query("SELECT * FROM private_messages WHERE userid=".$logged_in_user->id." ORDER BY date DESC"); if (mysql_num_rows($query) == 0) { echo "You have no private messages."; @@ -53,12 +57,13 @@ if ($action == "inbox") { start_table(); echo "Subject".$message->subject.""; - echo "Sender".user_links(get_user_from_id($message->senderid)).""; + echo "Sender".user_links(get_user_from_id($message->senderid))." + senderid."\">\"Block"; echo "Date".time_str($message->date).""; echo "Message".output_transform($message->content, $options).""; echo "\n"; - echo "Delete\n"; - echo " | Reply\n"; + echo "Delete\n"; + echo " | Reply\n"; echo " | Inbox\n"; end_table(); @@ -151,92 +156,39 @@ if ($action == "inbox") { Header("Location: forum_pm.php?action=inbox&sent=1"); } +} elseif ($action == "block") { + $id = get_int("id"); + $user = mysql_query("SELECT name FROM user WHERE id=$id"); + if ($user) { + $user = mysql_fetch_object($user); + page_head("Really block ".$user->name."?"); + echo "
Are you really sure you want to block user ".$user->name." from sending you private messages?
\n"; + echo "Please have in mind that you can only block a limited amount of users.
\n"; + echo "
Once the user has been blocked you can unblock it using forum preferences page.
\n"; + + echo "\n"; + echo form_tokens($logged_in_user->authenticator); + echo "\n"; + echo "\n"; + echo "\n"; + echo "No, cancel\n"; + echo "
\n"; + } else { + error_page("No such user"); + } +} elseif ($action == "confirmedblock") { + check_tokens($logged_in_user->authenticator); + $id = post_int("id"); + $user = new User($logged_in_user->id); + $blocked = new User($id); + $user->addIgnoredUser($blocked); + + page_head("User ".$blocked->getName()." blocked"); + + echo "
User ".$blocked->getName()." has been blocked from sending you private messages. To unblock, visit + message board preferences.
\n"; } page_tail(); - -function pm_header() { - echo "
\n"; - echo " Inbox\n"; - echo " | Write\n"; - echo "
\n"; -} - -function pm_create_new($error = null) { - page_head("Private messages : Create new"); - pm_header(); - - global $logged_in_user; - $replyto = get_int("replyto", true); - $userid = get_int("userid", true); - - if ($replyto) { - $message = mysql_query("SELECT * FROM private_messages WHERE userid=".$logged_in_user->id." AND id=$replyto"); - if ($message) { - $message = mysql_fetch_object($message); - $content = "[quote]".$message->content."[/quote]\n"; - $userid = $message->senderid; - $user = get_user_from_id($userid); - if ($user != null) { - $writeto = $userid." (".$user->name.")"; - } - $subject = $message->subject; - if (substr($subject, 0, 3) != "re:") { - $subject = "re: ".$subject; - } - } - } elseif ($userid) { - $user = get_user_from_id($userid); - if ($user != null) { - $writeto = $userid." (".$user->name.")"; - } - } else { - $writeto = post_str("to", true); - $subject = post_str("subject", true); - $content = post_str("content", true); - } - - $subject = htmlspecialchars($subject); - - if ($error != null) { - echo "
$error
\n"; - } - - echo "
\n"; - echo "\n"; - echo form_tokens($logged_in_user->authenticator); - start_table(); - echo "To
User IDs or unique usernames, separated with commas\n"; - echo "\n"; - echo "Subject\n"; - echo "Message
".html_info()."\n"; - echo "\n"; - echo "\n"; - end_table(); - - page_tail(); - exit(); -} - -function pm_send($to, $subject, $content) { - global $logged_in_user; - $userid = $to->id; - $senderid = $logged_in_user->id; - $sql_subject = mysql_real_escape_string($subject); - $sql_content = mysql_real_escape_string($content); - mysql_query("INSERT INTO private_messages (userid, senderid, date, subject, content) VALUES ($userid, $senderid, UNIX_TIMESTAMP(), '$sql_subject', '$sql_content')"); - if ($to->send_email == 1) { // Send email notification - $message = "Dear ".$to->name.",\n\n"; - $message .= "You have received a new private message at ".PROJECT." from ".$logged_in_user->name.", entitled \"".$subject."\".\n\n"; - $message .= "To read the original version, respond to, or delete this message, you must log in here:\n"; - $message .= URL_BASE."forum_pm.php\n\n"; - $message .= "Do not reply to this message. To disable email notification, go to\n"; - $message .= URL_BASE."prefs.php?subset=project\n"; - $message .= "and change email notification settings.\n"; - - send_email($to, "[".PROJECT."] Private message notification", $message); - } -} - ?> diff --git a/html/user/white.css b/html/user/white.css index 72315535fc..7f6b15eb16 100644 --- a/html/user/white.css +++ b/html/user/white.css @@ -287,4 +287,10 @@ span.news_date { color: #ff0000; font-weight: bold; font-size: 1.1em; +} + +.notice { + color: #009900; + font-weight: bold; + font-size: 1.1em; } \ No newline at end of file