. require_once("../inc/boinc_db.inc"); require_once("../inc/email.inc"); require_once("../inc/pm.inc"); require_once("../inc/forum.inc"); require_once("../inc/akismet.inc"); check_get_args(array("replyto", "deleted", "userid", "action", "sent", "id", "tnow", "ttok")); $replyto = get_int("replyto", true); $userid = get_int("userid", true); function show_block_link($userid) { echo " "; show_image(REPORT_POST_IMAGE, tra("Block messages from this user"), tra("Block user"), REPORT_POST_IMAGE_HEIGHT); echo ""; } $action = sanitize_tags(get_str("action", true)); if (!$action) { $action = sanitize_tags(post_str("action", true)); } if (!$action) { $action = "inbox"; } $logged_in_user = get_logged_in_user(); BoincForumPrefs::lookup($logged_in_user); function make_script() { echo " "; } // show all private messages, // and delete notifications of new messages // function do_inbox($logged_in_user) { page_head(tra("Private messages").": ".tra("Inbox")); make_script(); if (get_int("sent", true) == 1) { echo "
".tra("Your message has been sent.")."
\n"; } $options = get_output_options($logged_in_user); BoincNotify::delete_aux("userid=$logged_in_user->id and type=".NOTIFY_PM); $msgs = BoincPrivateMessage::enum( "userid=$logged_in_user->id ORDER BY date DESC" ); if (count($msgs) == 0) { echo tra("You have no private messages."); } else { echo "
"; echo form_tokens($logged_in_user->authenticator); start_table(); echo "".tra("Subject")."".tra("Sender and date")."".tra("Message")."\n"; $i = 0; foreach($msgs as $msg) { $i++; $class = ($i%2)? "row0": "row1"; echo "\n"; $checkbox = "id>"; if (!$msg->opened) { $msg->update("opened=1"); } echo " $checkbox $msg->subject \n"; echo "".user_links(get_user_from_id($msg->senderid)); show_block_link($msg->senderid); echo "
".time_str($msg->date)."\n"; echo "".output_transform($msg->content, $options)."

"; $tokens = url_tokens($logged_in_user->authenticator); show_button("pm.php?action=new&replyto=$msg->id", tra("Reply"), tra("Reply to this message")); show_button("pm.php?action=delete&id=$msg->id&$tokens", tra("Delete"), tra("Delete this message")); echo "\n"; } echo " ".tra("Select all")." | ".tra("Unselect all")." "; end_table(); echo "

\n"; } } // the following isn't currently used - we never show single messages // function do_read($logged_in_user) { $id = get_int("id"); $message = BoincPrivateMessage::lookup_id($id); if (!$message || $message->userid != $logged_in_user->id) { error_page(tra("no such message")); } page_head(tra("Private messages")." : ".$message->subject); pm_header(); $sender = BoincUser::lookup_id($message->senderid); start_table(); echo "".tra("Subject")."".$message->subject.""; echo "".tra("Sender")."".user_links($sender); show_block_link($message->senderid); echo ""; echo "".tra("Date")."".time_str($message->date).""; echo "".tra("Message")."".output_transform($message->content, $options).""; echo "\n"; echo "".tra("Reply")."\n"; echo " | ".tra("Delete")."\n"; echo " | ".tra("Inbox")."\n"; end_table(); if ($message->opened == 0) { $message->update("opened=1"); } } function do_new($logged_in_user) { global $replyto, $userid; check_banished($logged_in_user); pm_form($replyto, $userid); } function do_delete($logged_in_user) { $id = get_int("id", true); if ($id == null) { $id = post_int("id"); } check_tokens($logged_in_user->authenticator); BoincPrivateMessage::delete_aux("userid=".$logged_in_user->id." AND id=$id"); header("Location: pm.php"); } function do_send($logged_in_user) { global $replyto, $userid; check_banished($logged_in_user); check_tokens($logged_in_user->authenticator); $to = sanitize_tags(post_str("to", true)); $subject = post_str("subject", true); $content = post_str("content", true); if (post_str("preview", true) == tra("Preview")) { pm_form($replyto, $userid); } if (($to == null) || ($subject == null) || ($content == null)) { pm_form($replyto, $userid, tra("You need to fill all fields to send a private message")); } else { if (!akismet_check($logged_in_user, $content)) { pm_form($replyto, $userid, tra("Your message was flagged as spam by the Akismet anti-spam system. Please modify your text and try again.") ); } $to = str_replace(", ", ",", $to); // Filter out spaces after separator $users = explode(",", $to); $userlist = array(); $userids = array(); // To prevent from spamming a single user by adding it multiple times foreach ($users as $username) { $user = explode(" ", $username); if (is_numeric($user[0])) { // user ID is gived $userid = $user[0]; $user = lookup_user_id($userid); if ($user == null) { pm_form($replyto, $userid, tra("Could not find user with id %1", $userid)); } } else { $user = lookup_user_name($username); if ($user == null) { pm_form($replyto, $userid, tra("Could not find user with username %1", $username)); } elseif ($user == -1) { // Non-unique username pm_form($replyto, $userid, tra("%1 is not a unique username; you will have to use user ID", $username)); } } BoincForumPrefs::lookup($user); if (is_ignoring($user, $logged_in_user)) { pm_form($replyto, $userid, tra("User %1 (ID: %2) is not accepting private messages from you.", $user->name, $user->id)); } if ($userids[$user->id] == null) { $userlist[] = $user; $userids[$user->id] = true; } } foreach ($userlist as $user) { if (!is_moderator($logged_in_user, null)) { check_pm_count($logged_in_user->id); } pm_send($logged_in_user, $user, $subject, $content, true); } Header("Location: pm.php?action=inbox&sent=1"); } } function do_block($logged_in_user) { $id = get_int("id"); $user = BoincUser::lookup_id($id); if (!$user) { error_page(tra("No such user")); } page_head(tra("Really block %1?", $user->name)); echo "
".tra("Are you really sure you want to block user %1 from sending you private messages?", $user->name)."
\n"; echo tra("Please note that you can only block a limited amount of users.")."
\n"; echo "
".tra("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 "".tra("No, cancel")."\n"; echo "
\n"; } function do_confirmedblock($logged_in_user) { check_tokens($logged_in_user->authenticator); $id = post_int("id"); $blocked_user = BoincUser::lookup_id($id); if (!$blocked_user) error_page(tra("no such user")); add_ignored_user($logged_in_user, $blocked_user); page_head(tra("User %1 blocked", $blocked_user->name)); echo "
".tra("User %1 has been blocked from sending you private messages.", $blocked_user->name)."\n"; echo tra("To unblock, visit %1message board preferences%2", "", "")."
\n"; } function do_delete_selected($logged_in_user) { check_tokens($logged_in_user->authenticator); $msgs = BoincPrivateMessage::enum( "userid=$logged_in_user->id" ); foreach($msgs as $msg) { $x = "pm_select_$msg->id"; if ($_POST[$x]) { $msg = BoincPrivateMessage::lookup_id($msg->id); $msg->delete(); } } Header("Location: pm.php?action=inbox&deleted=1"); } if ($action == "inbox") { do_inbox($logged_in_user); } elseif ($action == "read") { do_read($logged_in_user); } elseif ($action == "new") { do_new($logged_in_user); } elseif ($action == "delete") { do_delete($logged_in_user); } elseif ($action == "send") { do_send($logged_in_user); } elseif ($action == "block") { do_block($logged_in_user); } elseif ($action == "confirmedblock") { do_confirmedblock($logged_in_user); } elseif ($action == "delete_selected") { do_delete_selected($logged_in_user); } else { error_page(tra("Unknown action")); } page_tail(); $cvs_version_tracker[]="\$Id: pm.php 14077 2007-11-03 04:26:47Z davea $"; ?>