mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-20 16:41:26 +02:00
[ticket/9657] Remove sql_visibility as it is always non-empty
PHPBB3-9657
This commit is contained in:
@@ -90,14 +90,12 @@ class phpbb_feed_forum extends phpbb_feed_post_base
|
|||||||
|
|
||||||
function get_sql()
|
function get_sql()
|
||||||
{
|
{
|
||||||
$sql_visibility = $this->content_visibility->get_visibility_sql('topic', $this->forum_id);
|
|
||||||
|
|
||||||
// Determine topics with recent activity
|
// Determine topics with recent activity
|
||||||
$sql = 'SELECT topic_id, topic_last_post_time
|
$sql = 'SELECT topic_id, topic_last_post_time
|
||||||
FROM ' . TOPICS_TABLE . '
|
FROM ' . TOPICS_TABLE . '
|
||||||
WHERE forum_id = ' . $this->forum_id . '
|
WHERE forum_id = ' . $this->forum_id . '
|
||||||
AND topic_moved_id = 0
|
AND topic_moved_id = 0
|
||||||
' . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . '
|
AND ' . $this->content_visibility->get_visibility_sql('topic', $this->forum_id) . '
|
||||||
ORDER BY topic_last_post_time DESC';
|
ORDER BY topic_last_post_time DESC';
|
||||||
$result = $this->db->sql_query_limit($sql, $this->num_items);
|
$result = $this->db->sql_query_limit($sql, $this->num_items);
|
||||||
|
|
||||||
@@ -116,8 +114,6 @@ class phpbb_feed_forum extends phpbb_feed_post_base
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_visibility = $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.');
|
|
||||||
|
|
||||||
$this->sql = array(
|
$this->sql = array(
|
||||||
'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' .
|
'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' .
|
||||||
'u.username, u.user_id',
|
'u.username, u.user_id',
|
||||||
@@ -127,6 +123,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base
|
|||||||
),
|
),
|
||||||
'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . '
|
'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . '
|
||||||
' . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . '
|
' . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . '
|
||||||
|
AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . '
|
||||||
AND p.post_time >= ' . $min_post_time . '
|
AND p.post_time >= ' . $min_post_time . '
|
||||||
AND p.poster_id = u.user_id',
|
AND p.poster_id = u.user_id',
|
||||||
'ORDER_BY' => 'p.post_time DESC',
|
'ORDER_BY' => 'p.post_time DESC',
|
||||||
|
@@ -56,8 +56,6 @@ class phpbb_feed_overall extends phpbb_feed_post_base
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_visibility = $this->content_visibility->get_visibility_sql('post', array(), 'p.');
|
|
||||||
|
|
||||||
// Get the actual data
|
// Get the actual data
|
||||||
$this->sql = array(
|
$this->sql = array(
|
||||||
'SELECT' => 'f.forum_id, f.forum_name, ' .
|
'SELECT' => 'f.forum_id, f.forum_name, ' .
|
||||||
@@ -74,7 +72,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . '
|
'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . '
|
||||||
' . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . '
|
AND ' . $this->content_visibility->get_visibility_sql('post', array(), 'p.') . '
|
||||||
AND p.post_time >= ' . $min_post_time . '
|
AND p.post_time >= ' . $min_post_time . '
|
||||||
AND u.user_id = p.poster_id',
|
AND u.user_id = p.poster_id',
|
||||||
'ORDER_BY' => 'p.post_time DESC',
|
'ORDER_BY' => 'p.post_time DESC',
|
||||||
|
@@ -93,8 +93,6 @@ class phpbb_feed_topic extends phpbb_feed_post_base
|
|||||||
|
|
||||||
function get_sql()
|
function get_sql()
|
||||||
{
|
{
|
||||||
$sql_visibility = $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.');
|
|
||||||
|
|
||||||
$this->sql = array(
|
$this->sql = array(
|
||||||
'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' .
|
'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' .
|
||||||
'u.username, u.user_id',
|
'u.username, u.user_id',
|
||||||
@@ -103,7 +101,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base
|
|||||||
USERS_TABLE => 'u',
|
USERS_TABLE => 'u',
|
||||||
),
|
),
|
||||||
'WHERE' => 'p.topic_id = ' . $this->topic_id . '
|
'WHERE' => 'p.topic_id = ' . $this->topic_id . '
|
||||||
' . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . '
|
AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . '
|
||||||
AND p.poster_id = u.user_id',
|
AND p.poster_id = u.user_id',
|
||||||
'ORDER_BY' => 'p.post_time DESC',
|
'ORDER_BY' => 'p.post_time DESC',
|
||||||
);
|
);
|
||||||
|
@@ -2000,8 +2000,6 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti
|
|||||||
// Handle update of unapproved topics info.
|
// Handle update of unapproved topics info.
|
||||||
// Only update for moderators having m_approve permission for the forum.
|
// Only update for moderators having m_approve permission for the forum.
|
||||||
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
|
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
|
||||||
$sql_update_unapproved = $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.');
|
|
||||||
$sql_update_unapproved = ($sql_update_unapproved) ? ' AND ' . $sql_update_unapproved : '';
|
|
||||||
|
|
||||||
// Check the forum for any left unread topics.
|
// Check the forum for any left unread topics.
|
||||||
// If there are none, we mark the forum as read.
|
// If there are none, we mark the forum as read.
|
||||||
@@ -2021,8 +2019,8 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti
|
|||||||
AND tt.user_id = ' . $user->data['user_id'] . ')
|
AND tt.user_id = ' . $user->data['user_id'] . ')
|
||||||
WHERE t.forum_id = ' . $forum_id . '
|
WHERE t.forum_id = ' . $forum_id . '
|
||||||
AND t.topic_last_post_time > ' . $mark_time_forum . '
|
AND t.topic_last_post_time > ' . $mark_time_forum . '
|
||||||
AND t.topic_moved_id = 0 ' .
|
AND t.topic_moved_id = 0
|
||||||
$sql_update_unapproved . '
|
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . '
|
||||||
AND (tt.topic_id IS NULL
|
AND (tt.topic_id IS NULL
|
||||||
OR tt.mark_time < t.topic_last_post_time)';
|
OR tt.mark_time < t.topic_last_post_time)';
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
@@ -2046,8 +2044,8 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti
|
|||||||
FROM ' . TOPICS_TABLE . ' t
|
FROM ' . TOPICS_TABLE . ' t
|
||||||
WHERE t.forum_id = ' . $forum_id . '
|
WHERE t.forum_id = ' . $forum_id . '
|
||||||
AND t.topic_last_post_time > ' . $mark_time_forum . '
|
AND t.topic_last_post_time > ' . $mark_time_forum . '
|
||||||
AND t.topic_moved_id = 0 ' .
|
AND t.topic_moved_id = 0
|
||||||
$sql_update_unapproved;
|
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.');
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
$check_forum = $tracking_topics['tf'][$forum_id];
|
$check_forum = $tracking_topics['tf'][$forum_id];
|
||||||
|
@@ -252,7 +252,6 @@ $phpbb_content_visibility = $phpbb_container->get('content.visibility');
|
|||||||
if ($sort_days)
|
if ($sort_days)
|
||||||
{
|
{
|
||||||
$min_post_time = time() - ($sort_days * 86400);
|
$min_post_time = time() - ($sort_days * 86400);
|
||||||
$sql_visibility = $phpbb_content_visibility->get_visibility_sql('topic', $forum_id);
|
|
||||||
|
|
||||||
$sql = 'SELECT COUNT(topic_id) AS num_topics
|
$sql = 'SELECT COUNT(topic_id) AS num_topics
|
||||||
FROM ' . TOPICS_TABLE . "
|
FROM ' . TOPICS_TABLE . "
|
||||||
@@ -260,7 +259,7 @@ if ($sort_days)
|
|||||||
AND (topic_last_post_time >= $min_post_time
|
AND (topic_last_post_time >= $min_post_time
|
||||||
OR topic_type = " . POST_ANNOUNCE . '
|
OR topic_type = " . POST_ANNOUNCE . '
|
||||||
OR topic_type = ' . POST_GLOBAL . ')
|
OR topic_type = ' . POST_GLOBAL . ')
|
||||||
' . (($sql_visibility) ? ' AND ' . $sql_visibility : '');
|
AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
$topics_count = (int) $db->sql_fetchfield('num_topics');
|
$topics_count = (int) $db->sql_fetchfield('num_topics');
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
@@ -373,8 +372,7 @@ $sql_array = array(
|
|||||||
'LEFT_JOIN' => array(),
|
'LEFT_JOIN' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$sql_approved = $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.');
|
$sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.');
|
||||||
$sql_approved = ($sql_approved) ? ' AND ' . $sql_approved : '';
|
|
||||||
|
|
||||||
if ($user->data['is_registered'])
|
if ($user->data['is_registered'])
|
||||||
{
|
{
|
||||||
|
@@ -79,14 +79,12 @@ if ($view && !$post_id)
|
|||||||
{
|
{
|
||||||
// Get topic tracking info
|
// Get topic tracking info
|
||||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_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;
|
$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
|
$sql = 'SELECT post_id, topic_id, forum_id
|
||||||
FROM ' . POSTS_TABLE . "
|
FROM ' . POSTS_TABLE . "
|
||||||
WHERE topic_id = $topic_id
|
WHERE topic_id = $topic_id
|
||||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . "
|
AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . "
|
||||||
AND post_time > $topic_last_read
|
AND post_time > $topic_last_read
|
||||||
AND forum_id = $forum_id
|
AND forum_id = $forum_id
|
||||||
ORDER BY post_time ASC";
|
ORDER BY post_time ASC";
|
||||||
@@ -135,14 +133,12 @@ if ($view && !$post_id)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql_visibility = $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']);
|
|
||||||
|
|
||||||
$sql = 'SELECT topic_id, forum_id
|
$sql = 'SELECT topic_id, forum_id
|
||||||
FROM ' . TOPICS_TABLE . '
|
FROM ' . TOPICS_TABLE . '
|
||||||
WHERE forum_id = ' . $row['forum_id'] . "
|
WHERE forum_id = ' . $row['forum_id'] . "
|
||||||
AND topic_moved_id = 0
|
AND topic_moved_id = 0
|
||||||
AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
|
AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
|
||||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . "
|
AND " . $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']) . "
|
||||||
ORDER BY topic_last_post_time $sql_ordering";
|
ORDER BY topic_last_post_time $sql_ordering";
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
$row = $db->sql_fetchrow($result);
|
$row = $db->sql_fetchrow($result);
|
||||||
@@ -286,12 +282,10 @@ if ($post_id)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.');
|
|
||||||
|
|
||||||
$sql = 'SELECT COUNT(p.post_id) AS prev_posts
|
$sql = 'SELECT COUNT(p.post_id) AS prev_posts
|
||||||
FROM ' . POSTS_TABLE . " p
|
FROM ' . POSTS_TABLE . " p
|
||||||
WHERE p.topic_id = {$topic_data['topic_id']}
|
WHERE p.topic_id = {$topic_data['topic_id']}
|
||||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '');
|
AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.');
|
||||||
|
|
||||||
if ($sort_dir == 'd')
|
if ($sort_dir == 'd')
|
||||||
{
|
{
|
||||||
@@ -405,13 +399,12 @@ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $
|
|||||||
if ($sort_days)
|
if ($sort_days)
|
||||||
{
|
{
|
||||||
$min_post_time = time() - ($sort_days * 86400);
|
$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
|
$sql = 'SELECT COUNT(post_id) AS num_posts
|
||||||
FROM ' . POSTS_TABLE . "
|
FROM ' . POSTS_TABLE . "
|
||||||
WHERE topic_id = $topic_id
|
WHERE topic_id = $topic_id
|
||||||
AND post_time >= $min_post_time
|
AND post_time >= $min_post_time
|
||||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '');
|
AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id);
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
$total_posts = (int) $db->sql_fetchfield('num_posts');
|
$total_posts = (int) $db->sql_fetchfield('num_posts');
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
@@ -946,12 +939,10 @@ $bbcode_bitfield = '';
|
|||||||
$i = $i_total = 0;
|
$i = $i_total = 0;
|
||||||
|
|
||||||
// Go ahead and pull all data for this topic
|
// 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
|
$sql = 'SELECT p.post_id
|
||||||
FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
|
FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . "
|
||||||
WHERE p.topic_id = $topic_id
|
WHERE p.topic_id = $topic_id
|
||||||
" . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . "
|
AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.') . "
|
||||||
" . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
|
" . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . "
|
||||||
$limit_posts_time
|
$limit_posts_time
|
||||||
ORDER BY $sql_sort_order";
|
ORDER BY $sql_sort_order";
|
||||||
|
Reference in New Issue
Block a user