1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-23 19:45:10 +01:00

- 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
This commit is contained in:
Meik Sievertsen 2007-11-06 11:15:38 +00:00
parent 5abe1ea4fe
commit ac88c61e63
8 changed files with 43 additions and 108 deletions

View File

@ -92,6 +92,7 @@
<li>[Fix] Fixing false new private message indicator (Bug #14627)</li>
<li>[Fix] Let newly activated passwords work if users were converted (Bug #14787)</li>
<li>[Fix] Quote bbcode fixes. Letting parse quote=&quot;[&quot; and re-allowing whitelisted bbcodes within username portion (Bug #14770)</li>
<li>[Fix] Allow alternative text for styled buttons if images turned off, but CSS staying on</li>
<li>[Sec] Fix bbcode helpline display for custom bbcodes - this requires style changes for any custom style (Bug #14850)</li>
<li>[Fix] Correctly count announcements when filtering forums by date (Bug #14877)</li>
<li>[Fix] Allow charset names containing underscores or spaces</li>

View File

@ -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);
}
/**

View File

@ -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)

View File

@ -11,9 +11,9 @@
<!-- IF U_POST_REPLY_PM or U_POST_NEW_TOPIC or U_FORWARD_PM -->
<li class="buttons">
<!-- IF U_POST_REPLY_PM --><div class="pmreply-icon"><a title="{L_POST_REPLY_PM}" href="{U_POST_REPLY_PM}"><span>{L_POST_REPLY_PM}</span></a></div>
<!-- ELSEIF U_POST_NEW_TOPIC --><div class="newpm-icon"><a href="{U_POST_NEW_TOPIC}" accesskey="n"><span>{L_UCP_PM_COMPOSE}</span></a></div><!-- ENDIF -->
<!-- IF U_FORWARD_PM --><div class="forwardpm-icon"><a title="{L_POST_FORWARD_PM}" href="{U_FORWARD_PM}"><span>{L_FORWARD_PM}</span></a></div><!-- ENDIF -->
<!-- IF U_POST_REPLY_PM --><div class="pmreply-icon"><a title="{L_POST_REPLY_PM}" href="{U_POST_REPLY_PM}"><span></span>{L_POST_REPLY_PM}</a></div>
<!-- ELSEIF U_POST_NEW_TOPIC --><div class="newpm-icon"><a href="{U_POST_NEW_TOPIC}" accesskey="n" title="{L_UCP_PM_COMPOSE}"><span></span>{L_UCP_PM_COMPOSE}</a></div><!-- ENDIF -->
<!-- IF U_FORWARD_PM --><div class="forwardpm-icon"><a title="{L_POST_FORWARD_PM}" href="{U_FORWARD_PM}"><span></span>{L_FORWARD_PM}</a></div><!-- ENDIF -->
</li>
<!-- ENDIF -->

View File

@ -39,7 +39,7 @@
<!-- IF not S_IS_BOT and S_DISPLAY_POST_INFO -->
<div class="buttons">
<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}"><span><!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF --></span></a></div>
<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF -->"><span></span><!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF --></a></div>
</div>
<!-- ENDIF -->
@ -183,7 +183,7 @@
<div class="topic-actions">
<!-- IF not S_IS_BOT and S_DISPLAY_POST_INFO -->
<div class="buttons">
<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}"><span><!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF --></span></a></div>
<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->" title="<!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}"><span></span><!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF --></a></div>
</div>
<!-- ENDIF -->

View File

@ -32,7 +32,7 @@
<div class="buttons">
<!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO -->
<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}"><span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></span></a></div>
<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"><span></span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></a></div>
<!-- ENDIF -->
</div>
@ -240,7 +240,7 @@
<div class="topic-actions">
<div class="buttons">
<!-- IF not S_IS_BOT and S_DISPLAY_REPLY_INFO -->
<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}"><span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></span></a></div>
<div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->reply-icon<!-- ENDIF -->"><a href="{U_POST_REPLY_TOPIC}" title="<!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF -->"><span></span><!-- IF S_IS_LOCKED -->{L_TOPIC_LOCKED}<!-- ELSE -->{L_POST_REPLY}<!-- ENDIF --></a></div>
<!-- ENDIF -->
</div>

View File

@ -23,19 +23,22 @@
width: 100%;
height: 100%;
background-position: 0 0;
position: relative;
}
/* Hide <a> 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; }

View File

@ -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");