mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[feature/soft-delete] Simplification part2: user can see all item visibilities
If the user can see all visibilities, we can simply leave out the query part, instead of adding a bunch of ANDs. PHPBB3-9657
This commit is contained in:
@@ -79,11 +79,12 @@ if ($view && !$post_id)
|
||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
|
||||
|
||||
$topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0;
|
||||
$sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id);
|
||||
|
||||
$sql = 'SELECT post_id, topic_id, forum_id
|
||||
FROM ' . POSTS_TABLE . "
|
||||
WHERE topic_id = $topic_id
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id) . "
|
||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . "
|
||||
AND post_time > $topic_last_read
|
||||
AND forum_id = $forum_id
|
||||
ORDER BY post_time ASC";
|
||||
@@ -132,12 +133,14 @@ if ($view && !$post_id)
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_visibility = phpbb_content_visibility::get_visibility_sql('topic', $row['forum_id']);
|
||||
|
||||
$sql = 'SELECT topic_id, forum_id
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE forum_id = ' . $row['forum_id'] . "
|
||||
AND topic_moved_id = 0
|
||||
AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
|
||||
AND" . phpbb_content_visibility::get_visibility_sql('topic', $row['forum_id']) . "
|
||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . "
|
||||
ORDER BY topic_last_post_time $sql_ordering";
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
@@ -274,10 +277,12 @@ if ($post_id)
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.');
|
||||
|
||||
$sql = 'SELECT COUNT(p.post_id) AS prev_posts
|
||||
FROM ' . POSTS_TABLE . " p
|
||||
WHERE p.topic_id = {$topic_data['topic_id']}
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.');
|
||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '');
|
||||
|
||||
if ($sort_dir == 'd')
|
||||
{
|
||||
@@ -403,12 +408,13 @@ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $
|
||||
if ($sort_days)
|
||||
{
|
||||
$min_post_time = time() - ($sort_days * 86400);
|
||||
$sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id);
|
||||
|
||||
$sql = 'SELECT COUNT(post_id) AS num_posts
|
||||
FROM ' . POSTS_TABLE . "
|
||||
WHERE topic_id = $topic_id
|
||||
AND post_time >= $min_post_time
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id);
|
||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '');
|
||||
$result = $db->sql_query($sql);
|
||||
$total_posts = (int) $db->sql_fetchfield('num_posts');
|
||||
$db->sql_freeresult($result);
|
||||
@@ -942,10 +948,12 @@ $bbcode_bitfield = '';
|
||||
$i = $i_total = 0;
|
||||
|
||||
// Go ahead and pull all data for this topic
|
||||
$sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.');
|
||||
|
||||
$sql = 'SELECT p.post_id
|
||||
FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
|
||||
WHERE p.topic_id = $topic_id
|
||||
AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.') . "
|
||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . "
|
||||
" . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
|
||||
$limit_posts_time
|
||||
ORDER BY $sql_sort_order";
|
||||
|
Reference in New Issue
Block a user