. require_once("boinc_db.inc"); require_once("sanitize_html.inc"); require_once("bbcode_html.inc"); function pm_header() { echo "
\n"; echo " ".tra("Inbox")."\n"; echo " | ".tra("Write")."\n"; echo "
\n"; } function pm_form($error = null) { global $bbcode_html, $bbcode_js; global $g_logged_in_user; page_head(tra("Send private message"),'','','', $bbcode_js); if (post_str("preview", true) == tra("Preview")) { $options = new output_options; echo "
\n"; echo "
".tra("Preview")."
\n"; echo output_transform(post_str("content", true), $options); echo "
\n"; } $replyto = get_int("replyto", true); $userid = get_int("userid", true); $subject = null; $content = null; if ($replyto) { $message = BoincPrivateMessage::lookup_id($replyto); if (!$message || $message->userid != $g_logged_in_user->id) { error_page("no such message"); } $content = "[quote]".$message->content."[/quote]\n"; $userid = $message->senderid; $user = BoincUser::lookup_id($userid); if ($user != null) { $writeto = $userid." (".$user->name.")"; } $subject = $message->subject; if (substr($subject, 0, 3) != "re:") { $subject = "re: ".$subject; } } elseif ($userid) { $user = BoincUser::lookup_id($userid); if ($user) { $writeto = $userid." (".$user->name.")"; } } else { $writeto = sanitize_tags(post_str("to", true)); $subject = post_str("subject", true); $content = post_str("content", true); } $content = htmlspecialchars($content); $subject = htmlspecialchars($subject); if ($error != null) { echo "
".$error."
\n"; } echo "
\n"; echo "\n"; echo form_tokens($g_logged_in_user->authenticator); start_table(); row2(tra("To")."
".tra("User IDs or unique usernames, separated with commas")."", "" ); row2(tra("Subject"), ""); row2(tra("Message")."".html_info()."", $bbcode_html."" ); echo " \n"; end_table(); page_tail(); exit(); } function send_pm_notification_email( $logged_in_user, $to_user, $subject, $content ) { $message = " You have received a new private message at ".PROJECT.". From: $logged_in_user->name (ID $logged_in_user->id) Subject: $subject $content -------------------------- To delete or respond to this message, visit: ".URL_BASE."pm.php To change email preferences, visit: ".URL_BASE."edit_forum_preferences_form.php Do not reply to this message. " ; send_email($to_user, "[".PROJECT."] ".tra("- private message"), $message); } function pm_email_line($notify) { $pm = BoincPrivateMessage::lookup_id($notify->opaque); $from_user = BoincUser::lookup_id($pm->senderid); return "$from_user->name ".tra("sent you a private message; subject:")." '$pm->subject'"; } function pm_web_line($notify) { $pm = BoincPrivateMessage::lookup_id($notify->opaque); $from_user = BoincUser::lookup_id($pm->senderid); return "".tra("Private message%1 from %2, subject:" , "", $from_user->name )." $pm->subject"; } function pm_send($to_user, $subject, $content, $send_email) { global $g_logged_in_user; $sql_subject = boinc_real_escape_string(strip_tags($subject)); $sql_content = boinc_real_escape_string($content); $mid = BoincPrivateMessage::insert("(userid, senderid, date, subject, content) VALUES ($to_user->id, $g_logged_in_user->id, UNIX_TIMESTAMP(), '$sql_subject', '$sql_content')"); if (!$mid) { error_page(tra("Couldn't create message")); } // send email notification if needed // if ($send_email) { BoincForumPrefs::lookup($to_user); switch ($to_user->prefs->pm_notification) { case 0: case 2: break; case 1: send_pm_notification_email( $g_logged_in_user, $to_user, $subject, $content ); break; } } // create notification in any case // BoincNotify::insert("(userid, create_time, type, opaque) values ($to_user->id, ".time().", ".NOTIFY_PM.", $mid)"); } function pm_count($userid, $duration) { $time = time() - $duration; return BoincPrivateMessage::count("senderid=$userid AND date>$time"); } function check_pm_count($userid) { if ((pm_count($userid, 60) >= 2) || (pm_count($userid, 600) >= 5) || (pm_count($userid, 3600) >= 15) || (pm_count($userid, 86400) >= 50)) { error_page(tra("You are not allowed to send privates messages so often. Please wait some time before sending more messages.")); } } function pm_notification($user) { $output = ""; $unread = BoincPrivateMessage::count("userid=$user->id AND opened=0"); $output .= "".tra("Inbox").""; if ($unread) { $output .= " ($unread ".tra("unread").")\n"; } $output .= " | ".tra("Write")."\n"; return $output; } function pm_email_remind($user) { if (!$user->prefs->pm_notification) { return '
' . tra( "For email notification, %1edit community prefs%2", '', '' ) . '' ; } return ""; } function pm_rss($notify, &$title, &$msg, &$url) { $pm = BoincPrivateMessage::lookup_id($notify->opaque); $from_user = BoincUser::lookup_id($pm->senderid); $title = tra("Private message"); $msg = "You have received a private message."; $url = URL_BASE."pm.php"; } $cvs_version_tracker[]="\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $"; ?>