diff --git a/phpBB/language/lang_english.php b/phpBB/language/lang_english.php index 6857703a79..85c3146456 100755 --- a/phpBB/language/lang_english.php +++ b/phpBB/language/lang_english.php @@ -200,6 +200,8 @@ $lang['To'] = "To"; $lang['Date'] = "Date"; $lang['Mark'] = "Mark"; +$lang['Cannot_send_privmsg'] = "Sorry but you are not currently allowed to send private messages."; + $lang['No_to_user'] = "You must specify a username to send this message"; $lang['No_such_user'] = "Sorry but no such user exists"; @@ -214,7 +216,12 @@ $lang['Send_a_new_message'] = "Send a new private message"; $lang['Send_a_reply'] = "Reply to a private message"; $lang['Edit_message'] = "Edit private message"; -$lang['Notification_email'] = "Hello " . $username . "\n\n, You have received a new private message on your account at " . $forum_title . ". To view it immediately click the following link " . $pm_url . ", you may of course visit the site later your message will be stored in your Inbox.\n\n" . $board_config['email_from'] . "\n\n-------------------\n" . $board_config['email_sig']; +$lang['Notification_subject'] = "New Private Message has arrived"; +$lang['Notification_email'] = "Hello " . $to_userdata['username'] . "\n\n, You have received a new private message on your account at " . $board_config['sitename'] . ". To view it immediately click the following link " . $pm_url . ", you may of course visit the site later your message will be stored in your Inbox.\n"; + +$lang['Find_username'] = "Find a username"; +$lang['Find'] = "Find"; +$lang['No_match'] = "No matches found"; // // Profiles/Registration diff --git a/phpBB/privmsg.php b/phpBB/privmsg.php index 0d9789b79f..f12fe14d50 100644 --- a/phpBB/privmsg.php +++ b/phpBB/privmsg.php @@ -38,6 +38,7 @@ init_userprefs($userdata); // End session management // + $folder = (!empty($HTTP_POST_VARS['folder'])) ? $HTTP_POST_VARS['folder'] : ( (!empty($HTTP_GET_VARS['folder'])) ? $HTTP_GET_VARS['folder'] : "inbox" ); if(empty($HTTP_POST_VARS['cancel'])) { @@ -306,12 +307,36 @@ if($mode == "read") } else if($mode == "post" || $mode == "reply" || $mode == "edit") { + // ----------------------------- + // Posting capabilities are here + // ----------------------------- if(!$userdata['session_logged_in']) { header("Location: " . append_sid("login.$phpEx?forward_page=privmsg.$phpEx&folder=$folder&mode=$mode")); } + if(!$userdata['user_allow_pm']) + { + // + // Admin has prevented user + // from sending PM's + // + include('includes/page_header.'.$phpEx); + + $msg = $lang['Cannot_send_privmsg']; + + $template->set_filenames(array( + "reg_header" => "error_body.tpl") + ); + $template->assign_vars(array( + "ERROR_MESSAGE" => $msg) + ); + $template->pparse("reg_header"); + + include('includes/page_tail.'.$phpEx); + } + // // When we get to the point of a code review // we really really really need to look at @@ -347,11 +372,14 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") } } - if(!empty($HTTP_GET_VARS[POST_USERS_URL]) && !$preview && empty($HTTP_POST_VARS['submit'])) + if(empty($HTTP_GET_VARS[POST_USERS_URL]) && !$preview && empty($HTTP_POST_VARS['submit'])) { + $user_id = $HTTP_GET_VARS[POST_USERS_URL]; + $sql = "SELECT username FROM " . USERS_TABLE . " - WHERE user_id = " . $HTTP_GET_VARS[POST_USERS_URL]; + WHERE user_id = $user_id + AND user_id <> " . ANONYMOUS; if(!$result = $db->sql_query($sql)) { $error = TRUE; @@ -367,11 +395,91 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") { $to_username = stripslashes($HTTP_POST_VARS['to_username']); } + else if( !empty($HTTP_POST_VARS['to_username_list']) && empty($HTTP_POST_VARS['usersubmit']) ) + { + $to_username = stripslashes($HTTP_POST_VARS['to_username_list']); + } else { $to_username = ""; } + // + // + // + if( !empty($HTTP_POST_VARS['usersubmit']) || $preview) + { + if(!empty($HTTP_POST_VARS['to_username']) && !$preview) + { + $to_username_partial = stripslashes(str_replace("*", "%", $HTTP_POST_VARS['to_username'])); + $to_username = ""; + $first_letter = 65; + + $sql = "SELECT username + FROM " . USERS_TABLE . " + WHERE ( username LIKE '%$to_username_partial' + OR username LIKE '$to_username_partial%' + OR username LIKE '%$to_username_partial%' + OR username LIKE '$to_username_partial' ) + AND user_id <> " . ANONYMOUS; + + } + else + { + $first_letter = ($preview) ? 65 : $HTTP_POST_VARS['user_alpha']; + + $sql = "SELECT username + FROM " . USERS_TABLE . " + WHERE ( username LIKE '" . chr($first_letter) . "%' + OR username LIKE '$first_letter' ) + AND user_id <> " . ANONYMOUS; + + } + + } + else + { + $first_letter = 65; + + $sql = "SELECT username + FROM " . USERS_TABLE . " + WHERE ( username LIKE '" . chr($first_letter) . "%' + OR username LIKE '$first_letter' ) + AND user_id <> " . ANONYMOUS; + } + + $result = $db->sql_query($sql); + $name_set = $db->sql_fetchrowset($result); + + $user_names_select = ""; + + $user_alpha_select = ""; + if($mode == "edit" && !$preview && !$submit) { @@ -516,9 +624,10 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") if(!empty($to_username)) { - $sql = "SELECT user_id + $sql = "SELECT user_id, username, user_notify_pm, user_email FROM " . USERS_TABLE . " - WHERE username = '" . addslashes($to_username) . "'"; + WHERE username = '" . addslashes($to_username) . "' + AND user_id <> " . ANONYMOUS; if(!$result = $db->sql_query($sql)) { $error = TRUE; @@ -526,7 +635,7 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") } else { - list($to_userid) = $db->sql_fetchrow($result); + $to_userdata = $db->sql_fetchrow($result); } } else @@ -546,12 +655,12 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") if($mode != "edit") { $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_bbcode_uid) - VALUES (" . PRIVMSGS_NEW_MAIL . ", '$subject', " . $userdata['user_id'] . ", $to_userid, $msg_time, '$user_ip', '" . $bbcode_uid . "')"; + VALUES (" . PRIVMSGS_NEW_MAIL . ", '$subject', " . $userdata['user_id'] . ", " . $to_userdata['user_id'] . ", $msg_time, '$user_ip', '" . $bbcode_uid . "')"; } else { $sql_info = "UPDATE " . PRIVMSGS_TABLE . " - SET privmsgs_type = " . PRIVMSGS_NEW_MAIL . ", privmsgs_subject = '$subject', privmsgs_from_userid = " . $userdata['user_id'] . ", privmsgs_to_userid = $to_userid, privmsgs_date = $msg_time, privmsgs_ip = '$user_ip', privmsgs_bbcode_uid = '$bbcode_uid' + SET privmsgs_type = " . PRIVMSGS_NEW_MAIL . ", privmsgs_subject = '$subject', privmsgs_from_userid = " . $userdata['user_id'] . ", privmsgs_to_userid = " . $to_userdata['user_id'] . ", privmsgs_date = $msg_time, privmsgs_ip = '$user_ip', privmsgs_bbcode_uid = '$bbcode_uid' WHERE privmsgs_id = $privmsgs_id"; } @@ -579,6 +688,13 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") { error_die(SQL_QUERY, "Could not insert/update private message sent text.", __LINE__, __FILE__); } + else if($mode != "edit") + { + if($to_userdata['user_notify_pm'] && !empty($to_userdata['user_email'])) + { + //mail($to_userdata['user_email'], $lang['Notification_subject'], $email_msg, "From: ".$board_config['board_email_from']."\r\n"); + } + } include('includes/page_header.'.$phpEx); @@ -606,7 +722,7 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") { unset($mod_group_list); $sql = "SELECT g.group_id, g.group_name, g.group_moderator, g.group_single_user, u.username - FROM phpbb_groups g, phpbb_user_group ug, phpbb_users u + FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u WHERE g.group_moderator = " . $userdata['user_id'] ." AND ug.group_id = g.group_id AND u.user_id = ug.user_id"; @@ -735,6 +851,7 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") $post_a = $lang['Edit_message']; } + $username_input = ''; $subject_input = ''; $message_input = ''; @@ -746,7 +863,7 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") } $template->assign_vars(array( - "S_USERNAME_INPUT" => "", + "S_USERNAME_INPUT" => $username_input, "SUBJECT_INPUT" => $subject_input, "MESSAGE_INPUT" => $message_input, "HTML_STATUS" => $html_status, @@ -764,7 +881,11 @@ else if($mode == "post" || $mode == "reply" || $mode == "edit") "L_SUBMIT" => $lang['Submit_post'], "L_CANCEL" => $lang['Cancel_post'], "L_POST_A" => $post_a, + "L_FIND_USERNAME" => $lang['Find_username'], + "L_FIND" => $lang['Find'], + "S_ALPHA_SELECT" => $user_alpha_select, + "S_NAMES_SELECT" => $user_names_select, "S_POST_ACTION" => append_sid("privmsg.$phpEx"), "S_HIDDEN_FORM_FIELDS" => $s_hidden_fields) ); @@ -989,7 +1110,7 @@ $template->assign_vars(array( "S_POST_NEW_MSG" => $post_new_mesg_url) ); -$sql_tot = "SELECT COUNT(privmsgs_id)_total FROM " . PRIVMSGS_TABLE . " "; +$sql_tot = "SELECT COUNT(privmsgs_id) AS total FROM " . PRIVMSGS_TABLE . " "; $sql = "SELECT pm.privmsgs_type, pm.privmsgs_id, pm.privmsgs_date, pm.privmsgs_subject, u.user_id, u.username FROM " . PRIVMSGS_TABLE . " pm, " . USERS_TABLE . " u "; switch($folder) diff --git a/phpBB/templates/PSO/privmsgs_posting_body.tpl b/phpBB/templates/PSO/privmsgs_posting_body.tpl index ece5490bc5..e809418c65 100644 --- a/phpBB/templates/PSO/privmsgs_posting_body.tpl +++ b/phpBB/templates/PSO/privmsgs_posting_body.tpl @@ -18,12 +18,12 @@ function insertCode(formObj, selectObj){
{L_POST_A} | -|
{L_USERNAME} | -{S_USERNAME_INPUT} |
{L_USERNAME} | +{S_USERNAME_INPUT} {L_FIND_USERNAME} {S_ALPHA_SELECT} {S_NAMES_SELECT} | +
{L_SUBJECT} | {SUBJECT_INPUT} |