mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Altered storage of private message info
git-svn-id: file:///svn/phpbb/trunk@1367 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
f51520553d
commit
4f387057ca
3 changed files with 83 additions and 15 deletions
|
@ -157,30 +157,50 @@ $l_online_users .= ( $guests_online == 1 ) ? sprintf($lang['Guest_user_total'],
|
||||||
//
|
//
|
||||||
if( $userdata['session_logged_in'] )
|
if( $userdata['session_logged_in'] )
|
||||||
{
|
{
|
||||||
$sql = "SELECT COUNT(privmsgs_type) AS new_messages
|
if( $userdata['user_new_privmsg'] )
|
||||||
FROM " . PRIVMSGS_TABLE . "
|
|
||||||
WHERE privmsgs_type = " . PRIVMSGS_NEW_MAIL . "
|
|
||||||
AND privmsgs_to_userid = " . $userdata['user_id'];
|
|
||||||
if( !$result_pm = $db->sql_query($sql) )
|
|
||||||
{
|
{
|
||||||
message_die(GENERAL_MESSAGE, "Couldn't obtain user/online information.", "", __LINE__, __FILE__, $sql);
|
$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
|
||||||
}
|
$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);
|
||||||
|
|
||||||
if( $pm_result = $db->sql_fetchrow($result_pm) )
|
if( $userdata['user_last_privmsg'] > $userdata['session_start'] )
|
||||||
{
|
{
|
||||||
$new_pm_messages = $pm_result['new_messages'];
|
$sql = "UPDATE " . USERS_TABLE . "
|
||||||
|
SET user_last_privmsg = " . $userdata['session_start'] . "
|
||||||
|
WHERE user_id = " . $userdata['user_id'];
|
||||||
|
if( !$status = $db->sql_query($sql) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, "Could not update private message new/read time for user.", "", __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
$l_message_new = ( $new_pm_messages == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
|
$s_privmsg_new = true;
|
||||||
$l_privmsgs_text = sprintf($l_message_new, $new_pm_messages);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$s_privmsg_new = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$l_privmsgs_text = $lang['No_new_pm'];
|
$l_privmsgs_text = $lang['No_new_pm'];
|
||||||
|
|
||||||
|
$s_privmsg_new = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $userdata['user_unread_privmsg'] )
|
||||||
|
{
|
||||||
|
$l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
|
||||||
|
$l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$l_privmsgs_text_unread = $lang['No_unread_pm'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$l_privmsgs_text = $lang['Login_check_pm'];
|
$l_privmsgs_text = $lang['Login_check_pm'];
|
||||||
|
$l_privmsgs_text_unread = "";
|
||||||
|
$s_privmsg_new = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -195,7 +215,8 @@ $template->assign_vars(array(
|
||||||
"TOTAL_USERS_ONLINE" => $l_online_users,
|
"TOTAL_USERS_ONLINE" => $l_online_users,
|
||||||
"LOGGED_IN_USER_LIST" => $online_userlist,
|
"LOGGED_IN_USER_LIST" => $online_userlist,
|
||||||
"PRIVATE_MESSAGE_INFO" => $l_privmsgs_text,
|
"PRIVATE_MESSAGE_INFO" => $l_privmsgs_text,
|
||||||
"PRIVATE_MESSAGE_COUNT" => $new_pm_messages_session,
|
"PRIVATE_MESSAGE_INFO_UNREAD" => $l_privmsgs_text_unread,
|
||||||
|
"PRIVATE_MESSAGE_NEW_FLAG" => $s_privmsg_new,
|
||||||
"LAST_VISIT_DATE" => sprintf($lang['You_last_visit'], $s_last_visit),
|
"LAST_VISIT_DATE" => sprintf($lang['You_last_visit'], $s_last_visit),
|
||||||
|
|
||||||
"L_USERNAME" => $lang['Username'],
|
"L_USERNAME" => $lang['Username'],
|
||||||
|
|
|
@ -357,6 +357,9 @@ $lang['Login_check_pm'] = "Login to check your private messages";
|
||||||
$lang['New_pms'] = "You have %d new messages"; // You have 2 new messages
|
$lang['New_pms'] = "You have %d new messages"; // You have 2 new messages
|
||||||
$lang['New_pm'] = "You have %d new message"; // You have 1 new message
|
$lang['New_pm'] = "You have %d new message"; // You have 1 new message
|
||||||
$lang['No_new_pm'] = "You have no new messages";
|
$lang['No_new_pm'] = "You have no new messages";
|
||||||
|
$lang['Unread_pms'] = "You have %d unread messages";
|
||||||
|
$lang['Unread_pm'] = "You have %d unread message";
|
||||||
|
$lang['No_unread_pm'] = "You have no unread messages";
|
||||||
|
|
||||||
$lang['Inbox'] = "Inbox";
|
$lang['Inbox'] = "Inbox";
|
||||||
$lang['Outbox'] = "Outbox";
|
$lang['Outbox'] = "Outbox";
|
||||||
|
|
|
@ -75,6 +75,9 @@ init_userprefs($userdata);
|
||||||
// End session management
|
// End session management
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Var definitions
|
||||||
|
//
|
||||||
if( !empty($HTTP_POST_VARS['mode']) || !empty($HTTP_GET_VARS['mode']) )
|
if( !empty($HTTP_POST_VARS['mode']) || !empty($HTTP_GET_VARS['mode']) )
|
||||||
{
|
{
|
||||||
$mode = ( !empty($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
|
$mode = ( !empty($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
|
||||||
|
@ -218,6 +221,14 @@ if( $mode == "read" )
|
||||||
message_die(GENERAL_ERROR, "Could not update private message read status.", "", __LINE__, __FILE__, $sql);
|
message_die(GENERAL_ERROR, "Could not update private message read status.", "", __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE " . USERS_TABLE . "
|
||||||
|
SET user_unread_privmsg = user_unread_privmsg - 1
|
||||||
|
WHERE user_id = " . $userdata['user_id'];
|
||||||
|
if( !$user_upd_status = $db->sql_query($sql) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, "Could not update private message read status for user.", "", __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check to see if the poster has a 'full' sent box
|
// Check to see if the poster has a 'full' sent box
|
||||||
//
|
//
|
||||||
|
@ -766,7 +777,8 @@ else if( $submit || $refresh || $mode != "" )
|
||||||
//
|
//
|
||||||
// This 'will' handle a simple user search
|
// This 'will' handle a simple user search
|
||||||
// performed from within the private message post
|
// performed from within the private message post
|
||||||
// form
|
// form ... for 2.2 now, too late for 2.0 ... if we
|
||||||
|
// decide to do it all, I'm sooo lazy!
|
||||||
//
|
//
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -985,6 +997,18 @@ else if( $submit || $refresh || $mode != "" )
|
||||||
}
|
}
|
||||||
else if( $mode != "edit" )
|
else if( $mode != "edit" )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add to the users new pm counter
|
||||||
|
//
|
||||||
|
$sql = "UPDATE " . USERS_TABLE . "
|
||||||
|
SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "
|
||||||
|
WHERE user_id = " . $to_userdata['user_id'];
|
||||||
|
if( !$status = $db->sql_query($sql) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, "Could not update private message new/read status for user.", "", __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
if( $to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) )
|
if( $to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) )
|
||||||
{
|
{
|
||||||
$path = (dirname($HTTP_SERVER_VARS['SCRIPT_NAME']) == "/") ? "" : dirname($HTTP_SERVER_VARS['SCRIPT_NAME']);
|
$path = (dirname($HTTP_SERVER_VARS['SCRIPT_NAME']) == "/") ? "" : dirname($HTTP_SERVER_VARS['SCRIPT_NAME']);
|
||||||
|
@ -1512,11 +1536,31 @@ else if( $submit || $refresh || $mode != "" )
|
||||||
//
|
//
|
||||||
// Default page
|
// Default page
|
||||||
//
|
//
|
||||||
if(!$userdata['session_logged_in'])
|
if( !$userdata['session_logged_in'] )
|
||||||
{
|
{
|
||||||
header("Location: " . append_sid("login.$phpEx?redirect=privmsg.$phpEx&folder=inbox", true));
|
header("Location: " . append_sid("login.$phpEx?redirect=privmsg.$phpEx&folder=inbox", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update unread status
|
||||||
|
//
|
||||||
|
$sql = "UPDATE " . USERS_TABLE . "
|
||||||
|
SET user_unread_privmsg = " . ( $userdata['user_new_privmsg'] + $userdata['user_unread_privmsg'] ) . ", user_new_privmsg = 0, user_last_privmsg = " . $userdata['session_start'] . "
|
||||||
|
WHERE user_id = " . $userdata['user_id'];
|
||||||
|
if( !$status = $db->sql_query($sql) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, "Could not update private message new/read status for user.", "", __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reset PM counters
|
||||||
|
//
|
||||||
|
$userdata['user_new_privmsg'] = 0;
|
||||||
|
$userdata['user_unread_privmsg'] = ( $userdata['user_new_privmsg'] + $userdata['user_unread_privmsg'] );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Generate page
|
||||||
|
//
|
||||||
$page_title = $lang['Private_Messaging'];
|
$page_title = $lang['Private_Messaging'];
|
||||||
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue