From ac88c61e63ff5d7f7ea91b81e6cc73380171bc3b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 6 Nov 2007 11:15:38 +0000 Subject: [PATCH] - fix images off, css on problem for post/reply buttons - changed calculating new/unread pm count to no longer rely on code logic, but apply all rules, operate on messages and then re-calculating after delivery. git-svn-id: file:///svn/phpbb/trunk@8229 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/docs/CHANGELOG.html | 1 + phpBB/includes/functions_privmsgs.php | 82 ++++--------------- phpBB/includes/ucp/ucp_pm.php | 23 +----- .../template/ucp_pm_message_header.html | 6 +- .../prosilver/template/viewforum_body.html | 4 +- .../prosilver/template/viewtopic_body.html | 4 +- phpBB/styles/prosilver/theme/buttons.css | 19 +++-- phpBB/styles/prosilver/theme/colours.css | 12 +-- 8 files changed, 43 insertions(+), 108 deletions(-) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index d0bc033fb6..afe468b28b 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -92,6 +92,7 @@
  • [Fix] Fixing false new private message indicator (Bug #14627)
  • [Fix] Let newly activated passwords work if users were converted (Bug #14787)
  • [Fix] Quote bbcode fixes. Letting parse quote="[" and re-allowing whitelisted bbcodes within username portion (Bug #14770)
  • +
  • [Fix] Allow alternative text for styled buttons if images turned off, but CSS staying on
  • [Sec] Fix bbcode helpline display for custom bbcodes - this requires style changes for any custom style (Bug #14850)
  • [Fix] Correctly count announcements when filtering forums by date (Bug #14877)
  • [Fix] Allow charset names containing underscores or spaces
  • diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index d33ecf603f..43b2979b17 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -313,9 +313,9 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id) } /** -* Fix user PM count +* Update user PM count */ -function fix_pm_counts() +function update_pm_counts() { global $user, $db; @@ -368,12 +368,11 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) return 0; } - $user_new_privmsg = (int) $user->data['user_new_privmsg']; $user_message_rules = (int) $user->data['user_message_rules']; $user_id = (int) $user->data['user_id']; $action_ary = $move_into_folder = array(); - $num_not_moved = $num_removed = 0; + $num_removed = 0; // Newly processing on-hold messages if ($release) @@ -383,27 +382,6 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) WHERE folder_id = ' . PRIVMSGS_HOLD_BOX . " AND user_id = $user_id"; $db->sql_query($sql); - - // If there are no rows affected there is something wrong with the new and unread message count. - // We try to fix this on our way down... - if (!$db->sql_affectedrows()) - { - fix_pm_counts(); - - // The function needs this value to be up-to-date - $user_new_privmsg = (int) $user->data['user_new_privmsg']; - } - } - else - { - // If not relasing we need to check the number of not moved messages... - $sql = 'SELECT COUNT(msg_id) as num_messages - FROM ' . PRIVMSGS_TO_TABLE . " - WHERE user_id = $user_id - AND folder_id = " . PRIVMSGS_HOLD_BOX; - $result = $db->sql_query($sql); - $num_not_moved = (int) $db->sql_fetchfield('num_messages'); - $db->sql_freeresult($result); } // Get those messages not yet placed into any box @@ -422,7 +400,6 @@ 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']; } $db->sql_freeresult($result); } @@ -510,7 +487,6 @@ 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']; } } @@ -518,14 +494,12 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) } // We place actions into arrays, to save queries. - $num_new = $num_unread = 0; $sql = $unread_ids = $delete_ids = $important_ids = array(); foreach ($action_ary as $msg_id => $msg_ary) { // It is allowed to execute actions more than once, except placing messages into folder - $folder_action = false; - $message_removed = false; + $folder_action = $message_removed = false; foreach ($msg_ary as $pos => $rule_ary) { @@ -540,7 +514,6 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) // Folder actions have precedence, so we will remove any other ones $folder_action = true; $move_into_folder[(int) $rule_ary['folder_id']][] = $msg_id; - $num_new++; break; case ACTION_MARK_AS_READ: @@ -572,10 +545,6 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) } } -// $num_new += sizeof(array_unique($delete_ids)); -// $num_unread += sizeof(array_unique($delete_ids)); - $num_unread += sizeof(array_unique($unread_ids)); - // Do not change the order of processing // The number of queries needed to be executed here highly depends on the defined rules and are // only gone through if new messages arrive. @@ -583,7 +552,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) // Delete messages if (sizeof($delete_ids)) { - $num_removed = sizeof($delete_ids); + $num_removed += sizeof($delete_ids); delete_pm($user_id, $delete_ids, PRIVMSGS_NO_BOX); } @@ -689,6 +658,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) } $db->sql_freeresult($result); + $num_removed += sizeof($delete_ids); delete_pm($user_id, $delete_ids, $dest_folder); } } @@ -696,13 +666,6 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) // if ($full_folder_action == FULL_FOLDER_HOLD) { - $num_not_moved += sizeof($msg_ary); - - if ($num_new) - { - $num_new -= sizeof($msg_ary); - } - $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . ' SET folder_id = ' . PRIVMSGS_HOLD_BOX . ' WHERE folder_id = ' . PRIVMSGS_NO_BOX . " @@ -728,10 +691,6 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) AND user_id = $user_id"; $db->sql_query($sql); } - else - { - $num_new += $db->sql_affectedrows(); - } } } @@ -746,26 +705,19 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false) $db->sql_query($sql); } - // Update unread and new status field - if ($num_unread || $num_new) - { - $set_sql = ($num_unread) ? 'user_unread_privmsg = user_unread_privmsg - ' . $num_unread : ''; - if ($num_new) - { - $set_sql .= ($set_sql != '') ? ', ' : ''; - $set_sql .= 'user_new_privmsg = user_new_privmsg - ' . $num_new; - } - - $db->sql_query('UPDATE ' . USERS_TABLE . " SET $set_sql WHERE user_id = $user_id"); + // Update new/unread count + update_pm_counts(); - $user->data['user_new_privmsg'] -= $num_new; - $user->data['user_unread_privmsg'] -= $num_unread; - } + // Now check how many messages got not moved... + $sql = 'SELECT COUNT(msg_id) as num_messages + FROM ' . PRIVMSGS_TO_TABLE . " + WHERE user_id = $user_id + AND folder_id = " . PRIVMSGS_HOLD_BOX; + $result = $db->sql_query($sql); + $num_not_moved = (int) $db->sql_fetchfield('num_messages'); + $db->sql_freeresult($result); - return array( - 'not_moved' => $num_not_moved, - 'deleted' => $num_removed, - ); + return array($num_not_moved, $num_removed); } /** diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php index 9ad6766ee8..3d6c287bab 100644 --- a/phpBB/includes/ucp/ucp_pm.php +++ b/phpBB/includes/ucp/ucp_pm.php @@ -253,28 +253,7 @@ class ucp_pm if ($user->data['user_new_privmsg'] && $action == 'view_folder') { - $return = place_pm_into_folder($global_privmsgs_rules, $release); - $num_not_moved = $return['not_moved']; - - // Make sure num_not_moved is valid. - if ($user->data['user_new_privmsg'] < 0 || $num_not_moved < 0) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_new_privmsg = 0, user_unread_privmsg = 0 - WHERE user_id = ' . $user->data['user_id']; - $db->sql_query($sql); - - $num_not_moved = $user->data['user_new_privmsg'] = $user->data['user_unread_privmsg'] = 0; - } - - // Assign the number of private messages being removed due to rules. - $num_removed = $return['deleted']; - } - - // If user released the message, we will re-calculate the statistics (again) - if ($release) - { - fix_pm_counts(); + list($num_not_moved, $num_removed) = each(place_pm_into_folder($global_privmsgs_rules, $release)); } if (!$msg_id && $folder_id == PRIVMSGS_NO_BOX) diff --git a/phpBB/styles/prosilver/template/ucp_pm_message_header.html b/phpBB/styles/prosilver/template/ucp_pm_message_header.html index 2cc3107548..08cdc02d56 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_message_header.html +++ b/phpBB/styles/prosilver/template/ucp_pm_message_header.html @@ -11,9 +11,9 @@
  • - - - + + +
  • diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index d91c05d3f2..1a731e0451 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -39,7 +39,7 @@
    - +
    @@ -183,7 +183,7 @@
    diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index a4eca67854..040cd7709a 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -32,7 +32,7 @@ @@ -240,7 +240,7 @@
    diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index 6d07dd3511..33410c7f0a 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -23,19 +23,22 @@ width: 100%; height: 100%; background-position: 0 0; + position: relative; } /* Hide text and hide off-state image when rolling over (prevents flicker in IE) */ -.buttons div span { display: none; } -.buttons div a:hover { background-image: none; } +/*.buttons div span { display: none; }*/ +/*.buttons div a:hover { background-image: none; }*/ +.buttons div span { position: absolute; width: 100%; height: 100%; cursor: pointer; } +.buttons div a:hover span { background-position: 0 100%; } /* Big button images */ -.reply-icon, .reply-icon a { background: transparent none 0 0 no-repeat; } -.post-icon, .post-icon a { background: transparent none 0 0 no-repeat; } -.locked-icon, .locked-icon a { background: transparent none 0 0 no-repeat; } -.pmreply-icon, .pmreply-icon a { background: none 0 0 no-repeat; } -.newpm-icon, .newpm-icon a { background: none 0 0 no-repeat; } -.forwardpm-icon, .forwardpm-icon a { background: none 0 0 no-repeat; } +.reply-icon span { background: transparent none 0 0 no-repeat; } +.post-icon span { background: transparent none 0 0 no-repeat; } +.locked-icon span { background: transparent none 0 0 no-repeat; } +.pmreply-icon span { background: none 0 0 no-repeat; } +.newpm-icon span { background: none 0 0 no-repeat; } +.forwardpm-icon span { background: none 0 0 no-repeat; } /* Set big button dimensions */ .buttons div.reply-icon { width: {IMG_BUTTON_TOPIC_REPLY_WIDTH}px; height: {IMG_BUTTON_TOPIC_REPLY_HEIGHT}px; } diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index e8b405fefb..06a05b5616 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -647,12 +647,12 @@ Colours and backgrounds for buttons.css -------------------------------------------------------------- */ /* Big button images */ -.reply-icon, .reply-icon a { background-image: url("{IMG_BUTTON_TOPIC_REPLY_SRC}"); } -.post-icon, .post-icon a { background-image: url("{IMG_BUTTON_TOPIC_NEW_SRC}") ;} -.locked-icon, .locked-icon a { background-image: url("{IMG_BUTTON_TOPIC_LOCKED_SRC}"); } -.pmreply-icon, .pmreply-icon a { background-image: url("{IMG_BUTTON_PM_REPLY_SRC}") ;} -.newpm-icon, .newpm-icon a { background-image: url("{IMG_BUTTON_PM_NEW_SRC}") ;} -.forwardpm-icon, .forwardpm-icon a { background-image: url("{IMG_BUTTON_PM_FORWARD_SRC}") ;} +.reply-icon span { background-image: url("{IMG_BUTTON_TOPIC_REPLY_SRC}"); } +.post-icon span { background-image: url("{IMG_BUTTON_TOPIC_NEW_SRC}"); } +.locked-icon span { background-image: url("{IMG_BUTTON_TOPIC_LOCKED_SRC}"); } +.pmreply-icon span { background-image: url("{IMG_BUTTON_PM_REPLY_SRC}") ;} +.newpm-icon span { background-image: url("{IMG_BUTTON_PM_NEW_SRC}") ;} +.forwardpm-icon span { background-image: url("{IMG_BUTTON_PM_FORWARD_SRC}") ;} a.print { background-image: url("{T_THEME_PATH}/images/icon_print.gif");