diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2001-11-19 01:04:58 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2001-11-19 01:04:58 +0000 |
commit | 4f387057cacf04e406f60741d85c993dc899e878 (patch) | |
tree | ff077a62db827278763fb46a4a2e42f9a6c15688 | |
parent | f51520553d3808c1b38b7fe8a9aa9fe41f4892e9 (diff) | |
download | forums-4f387057cacf04e406f60741d85c993dc899e878.tar forums-4f387057cacf04e406f60741d85c993dc899e878.tar.gz forums-4f387057cacf04e406f60741d85c993dc899e878.tar.bz2 forums-4f387057cacf04e406f60741d85c993dc899e878.tar.xz forums-4f387057cacf04e406f60741d85c993dc899e878.zip |
Altered storage of private message info
git-svn-id: file:///svn/phpbb/trunk@1367 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/includes/page_header.php | 47 | ||||
-rw-r--r-- | phpBB/language/lang_english/lang_main.php | 3 | ||||
-rw-r--r-- | phpBB/privmsg.php | 48 |
3 files changed, 83 insertions, 15 deletions
diff --git a/phpBB/includes/page_header.php b/phpBB/includes/page_header.php index 9162940373..0d2897e4e2 100644 --- a/phpBB/includes/page_header.php +++ b/phpBB/includes/page_header.php @@ -157,30 +157,50 @@ $l_online_users .= ( $guests_online == 1 ) ? sprintf($lang['Guest_user_total'], // if( $userdata['session_logged_in'] ) { - $sql = "SELECT COUNT(privmsgs_type) AS new_messages - FROM " . PRIVMSGS_TABLE . " - WHERE privmsgs_type = " . PRIVMSGS_NEW_MAIL . " - AND privmsgs_to_userid = " . $userdata['user_id']; - if( !$result_pm = $db->sql_query($sql) ) + if( $userdata['user_new_privmsg'] ) { - 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) ) - { - $new_pm_messages = $pm_result['new_messages']; + if( $userdata['user_last_privmsg'] > $userdata['session_start'] ) + { + $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']; - $l_privmsgs_text = sprintf($l_message_new, $new_pm_messages); + $s_privmsg_new = true; + } + else + { + $s_privmsg_new = 0; + } } else { $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 { $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, "LOGGED_IN_USER_LIST" => $online_userlist, "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), "L_USERNAME" => $lang['Username'], diff --git a/phpBB/language/lang_english/lang_main.php b/phpBB/language/lang_english/lang_main.php index 49658eea2a..ecbe55bc17 100644 --- a/phpBB/language/lang_english/lang_main.php +++ b/phpBB/language/lang_english/lang_main.php @@ -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_pm'] = "You have %d new message"; // You have 1 new message $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['Outbox'] = "Outbox"; diff --git a/phpBB/privmsg.php b/phpBB/privmsg.php index e468e62702..a1fe253214 100644 --- a/phpBB/privmsg.php +++ b/phpBB/privmsg.php @@ -75,6 +75,9 @@ init_userprefs($userdata); // End session management // +// +// Var definitions +// 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']; @@ -218,6 +221,14 @@ if( $mode == "read" ) 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 // @@ -766,7 +777,8 @@ else if( $submit || $refresh || $mode != "" ) // // This 'will' handle a simple user search // 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" ) { + + // + // 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']) ) { $path = (dirname($HTTP_SERVER_VARS['SCRIPT_NAME']) == "/") ? "" : dirname($HTTP_SERVER_VARS['SCRIPT_NAME']); @@ -1512,11 +1536,31 @@ else if( $submit || $refresh || $mode != "" ) // // Default page // -if(!$userdata['session_logged_in']) +if( !$userdata['session_logged_in'] ) { 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']; include($phpbb_root_path . 'includes/page_header.'.$phpEx); |