diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2007-10-19 13:10:13 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2007-10-19 13:10:13 +0000 |
commit | bc0898f55e2c0bda196fa44cc7d1bb15b6fda649 (patch) | |
tree | 47192341eaa0ae65e53478ea32d9e0047a523579 /phpBB/includes | |
parent | 8963b032de7c14151d9432ca208038c4f515d961 (diff) | |
download | forums-bc0898f55e2c0bda196fa44cc7d1bb15b6fda649.tar forums-bc0898f55e2c0bda196fa44cc7d1bb15b6fda649.tar.gz forums-bc0898f55e2c0bda196fa44cc7d1bb15b6fda649.tar.bz2 forums-bc0898f55e2c0bda196fa44cc7d1bb15b6fda649.tar.xz forums-bc0898f55e2c0bda196fa44cc7d1bb15b6fda649.zip |
fixing some annoying bugs
git-svn-id: file:///svn/phpbb/trunk@8204 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_users.php | 15 | ||||
-rw-r--r-- | phpBB/includes/functions_privmsgs.php | 91 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 4 | ||||
-rwxr-xr-x | phpBB/includes/mcp/mcp_warn.php | 2 | ||||
-rw-r--r-- | phpBB/includes/message_parser.php | 17 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_activate.php | 3 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm.php | 9 |
7 files changed, 91 insertions, 50 deletions
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 344df3169d..833d8e0173 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -322,6 +322,16 @@ class acp_users WHERE user_id = $user_id"; $db->sql_query($sql); } + else + { + // Grabbing the last confirm key - we only send a reminder + $sql = 'SELECT user_actkey + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . $user_id; + $result = $db->sql_query($sql); + $user_actkey = (string) $db->sql_fetchfield('user_actkey'); + $db->sql_freeresult($result); + } $messenger = new messenger(false); @@ -774,8 +784,9 @@ class acp_users if ($update_password) { $sql_ary += array( - 'user_password' => phpbb_hash($data['new_password']), - 'user_passchg' => time(), + 'user_password' => phpbb_hash($data['new_password']), + 'user_passchg' => time(), + 'user_pass_convert' => 0, ); $user->reset_login_keys($user_id); diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 68e77ec421..d33ecf603f 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -313,6 +313,50 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id) } /** +* Fix user PM count +*/ +function fix_pm_counts() +{ + global $user, $db; + + // Update unread count + $sql = 'SELECT COUNT(msg_id) as num_messages + FROM ' . PRIVMSGS_TO_TABLE . ' + WHERE pm_unread = 1 + AND folder_id <> ' . PRIVMSGS_OUTBOX . ' + AND user_id = ' . $user->data['user_id']; + $result = $db->sql_query($sql); + $user->data['user_unread_privmsg'] = (int) $db->sql_fetchfield('num_messages'); + $db->sql_freeresult($result); + + // Update new pm count + $sql = 'SELECT COUNT(msg_id) as num_messages + FROM ' . PRIVMSGS_TO_TABLE . ' + WHERE pm_new = 1 + AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') + AND user_id = ' . $user->data['user_id']; + $result = $db->sql_query($sql); + $user->data['user_new_privmsg'] = (int) $db->sql_fetchfield('num_messages'); + $db->sql_freeresult($result); + + $db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( + 'user_unread_privmsg' => (int) $user->data['user_unread_privmsg'], + 'user_new_privmsg' => (int) $user->data['user_new_privmsg'], + )) . ' WHERE user_id = ' . $user->data['user_id']); + + // Ok, here we need to repair something, other boxes than privmsgs_no_box and privmsgs_hold_box should not carry the pm_new flag. + if (!$user->data['user_new_privmsg']) + { + $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' + SET pm_new = 0 + WHERE pm_new = 1 + AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') + AND user_id = ' . $user->data['user_id']; + $db->sql_query($sql); + } +} + +/** * Place new messages into appropriate folder */ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) @@ -344,42 +388,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) // We try to fix this on our way down... if (!$db->sql_affectedrows()) { - // Update unread count - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE pm_unread = 1 - AND folder_id <> ' . PRIVMSGS_OUTBOX . ' - AND user_id = ' . $user_id; - $result = $db->sql_query($sql); - $num_messages = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_unread_privmsg = ' . $num_messages . ' WHERE user_id = ' . $user_id); - $user->data['user_unread_privmsg'] = $num_messages; - - // Update new pm count - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . ' - WHERE pm_new = 1 - AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND user_id = ' . $user_id; - $result = $db->sql_query($sql); - $num_messages = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); - - $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_new_privmsg = ' . $num_messages . ' WHERE user_id = ' . $user_id); - $user->data['user_new_privmsg'] = $num_messages; - - // Ok, here we need to repair something, other boxes than privmsgs_no_box and privmsgs_hold_box should not carry the pm_new flag. - if (!$num_messages) - { - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' - SET pm_new = 0 - WHERE pm_new = 1 - AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ') - AND user_id = ' . $user_id; - $db->sql_query($sql); - } + fix_pm_counts(); // The function needs this value to be up-to-date $user_new_privmsg = (int) $user->data['user_new_privmsg']; @@ -413,7 +422,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) while ($row = $db->sql_fetchrow($result)) { $action_ary[$row['msg_id']][] = array('action' => false); - $move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id']; +// $move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id']; } $db->sql_freeresult($result); } @@ -501,7 +510,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) if (!$is_match) { $action_ary[$row['msg_id']][] = array('action' => false); - $move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id']; +// $move_into_folder[PRIVMSGS_INBOX][] = $row['msg_id']; } } @@ -688,7 +697,11 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) if ($full_folder_action == FULL_FOLDER_HOLD) { $num_not_moved += sizeof($msg_ary); - $num_new -= sizeof($msg_ary); + + if ($num_new) + { + $num_new -= sizeof($msg_ary); + } $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' SET folder_id = ' . PRIVMSGS_HOLD_BOX . ' diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 32dee77df6..b3be975d00 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2035,7 +2035,7 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var } @ksort($avatar_list); - + $category = (!$category) ? key($avatar_list) : $category; $avatar_categories = array_keys($avatar_list); @@ -2050,7 +2050,7 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var 'S_IN_AVATAR_GALLERY' => true, 'S_CAT_OPTIONS' => $s_category_options) ); - + $avatar_list = (isset($avatar_list[$category])) ? $avatar_list[$category] : array(); foreach ($avatar_list as $avatar_row_ary) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index cab102f1f7..315a2c1362 100755 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -418,7 +418,7 @@ function add_warning($user_row, $warning, $send_pm = true, $post_id = 0) $pm_data = array( 'from_user_id' => $user->data['user_id'], - 'from_user_ip' => $user->data['user_ip'], + 'from_user_ip' => $user->ip, 'from_username' => $user->data['username'], 'enable_sig' => false, 'enable_bbcode' => true, diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 311c75b410..f7ae685e95 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -674,7 +674,11 @@ class bbcode_firstpass extends bbcode /** * If you change this code, make sure the cases described within the following reports are still working: - * #3572, #14667 + * #3572 - [quote="[test]test"]test [ test[/quote] - (correct: parsed) + * #14667 - [quote]test[/quote] test ] and [ test [quote]test[/quote] (correct: parsed) + * #14770 - [quote="["]test[/quote] (correct: parsed) + * [quote="[i]test[/i]"]test[/quote] (correct: parsed) + * [quote="[quote]test[/quote]"]test[/quote] (correct: NOT parsed) */ $in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in))); @@ -684,6 +688,9 @@ class bbcode_firstpass extends bbcode return ''; } + // To let the parser not catch tokens within quote_username quotes we encode them before we start this... + $in = preg_replace('#quote="(.*?)"\]#ie', "'quote="' . str_replace(array('[', ']'), array('[', ']'), '\$1') . '"]'", $in); + $tok = ']'; $out = '['; @@ -745,7 +752,9 @@ class bbcode_firstpass extends bbcode if (isset($m[1]) && $m[1]) { - $username = preg_replace('#\[(?!b|i|u|color|url|email|/b|/i|/u|/color|/url|/email)#iU', '[$1', $m[1]); + $username = str_replace(array('[', ']'), array('[', ']'), $m[1]); + $username = preg_replace('#\[(?!b|i|u|color|url|email|/b|/i|/u|/color|/url|/email)#iU', '[$1', $username); + $end_tags = array(); $error = false; @@ -765,7 +774,7 @@ class bbcode_firstpass extends bbcode if ($error) { - $username = str_replace('[', '[', str_replace(']', ']', $m[1])); + $username = $m[1]; } $out .= 'quote="' . $username . '":' . $this->bbcode_uid . ']'; @@ -1073,7 +1082,7 @@ class parse_message extends bbcode_firstpass } // Check for "empty" message - if (!utf8_clean_string($this->message)) + if ($mode !== 'sig' && !utf8_clean_string($this->message)) { $this->warn_msg[] = $user->lang['TOO_FEW_CHARS']; return $this->warn_msg; diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php index 134729ffe9..355c9898c2 100644 --- a/phpBB/includes/ucp/ucp_activate.php +++ b/phpBB/includes/ucp/ucp_activate.php @@ -63,7 +63,8 @@ class ucp_activate $sql_ary = array( 'user_actkey' => '', 'user_password' => $user_row['user_newpasswd'], - 'user_newpasswd' => '' + 'user_newpasswd' => '', + 'user_pass_convert' => 0, ); $sql = 'UPDATE ' . USERS_TABLE . ' diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php index e843e89139..9ad6766ee8 100644 --- a/phpBB/includes/ucp/ucp_pm.php +++ b/phpBB/includes/ucp/ucp_pm.php @@ -249,10 +249,11 @@ class ucp_pm // If new messages arrived, place them into the appropriate folder $num_not_moved = $num_removed = 0; + $release = request_var('release', 0); if ($user->data['user_new_privmsg'] && $action == 'view_folder') { - $return = place_pm_into_folder($global_privmsgs_rules, request_var('release', 0)); + $return = place_pm_into_folder($global_privmsgs_rules, $release); $num_not_moved = $return['not_moved']; // Make sure num_not_moved is valid. @@ -270,6 +271,12 @@ class ucp_pm $num_removed = $return['deleted']; } + // If user released the message, we will re-calculate the statistics (again) + if ($release) + { + fix_pm_counts(); + } + if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX) { $folder_id = PRIVMSGS_INBOX; |