diff options
Diffstat (limited to 'phpBB/phpbb/feed')
-rw-r--r-- | phpBB/phpbb/feed/attachments_base.php | 83 | ||||
-rw-r--r-- | phpBB/phpbb/feed/forum.php | 3 | ||||
-rw-r--r-- | phpBB/phpbb/feed/news.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/feed/post_base.php | 42 | ||||
-rw-r--r-- | phpBB/phpbb/feed/topic.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/feed/topic_base.php | 23 | ||||
-rw-r--r-- | phpBB/phpbb/feed/topics.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/feed/topics_active.php | 7 |
8 files changed, 126 insertions, 55 deletions
diff --git a/phpBB/phpbb/feed/attachments_base.php b/phpBB/phpbb/feed/attachments_base.php new file mode 100644 index 0000000000..a9a8175928 --- /dev/null +++ b/phpBB/phpbb/feed/attachments_base.php @@ -0,0 +1,83 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\feed; + +/** +* Abstract class for feeds displaying attachments +* +* @package phpBB3 +*/ +abstract class attachments_base extends \phpbb\feed\base +{ + /** + * Attachments that may be displayed + */ + protected $attachments = array(); + + /** + * Retrieve the list of attachments that may be displayed + */ + protected function fetch_attachments() + { + $sql_array = array( + 'SELECT' => 'a.*', + 'FROM' => array( + ATTACHMENTS_TABLE => 'a' + ), + 'WHERE' => 'a.in_message = 0 ', + 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC', + ); + + if (isset($this->topic_id)) + { + $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id; + } + else if (isset($this->forum_id)) + { + $sql_array['LEFT_JOIN'] = array( + array( + 'FROM' => array(TOPICS_TABLE => 't'), + 'ON' => 'a.topic_id = t.topic_id', + ) + ); + $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id; + } + + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); + + // Set attachments in feed items + while ($row = $this->db->sql_fetchrow($result)) + { + $this->attachments[$row['post_msg_id']][] = $row; + } + $this->db->sql_freeresult($result); + } + + /** + * {@inheritDoc} + */ + public function open() + { + parent::open(); + $this->fetch_attachments(); + } + + /** + * Get attachments related to a given post + * + * @param $post_id int Post id + * @return mixed Attachments related to $post_id + */ + public function get_attachments($post_id) + { + return $this->attachments[$post_id]; + } +} diff --git a/phpBB/phpbb/feed/forum.php b/phpBB/phpbb/feed/forum.php index 85ecb60f7e..e35ec4baa4 100644 --- a/phpBB/phpbb/feed/forum.php +++ b/phpBB/phpbb/feed/forum.php @@ -80,6 +80,8 @@ class forum extends \phpbb\feed\post_base unset($forum_ids_passworded); } + + parent::open(); } function get_sql() @@ -130,6 +132,7 @@ class forum extends \phpbb\feed\post_base parent::adjust_item($item_row, $row); $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title']; + $item_row['forum_id'] = $this->forum_id; } function get_item() diff --git a/phpBB/phpbb/feed/news.php b/phpBB/phpbb/feed/news.php index 1b7c452a92..2242525db6 100644 --- a/phpBB/phpbb/feed/news.php +++ b/phpBB/phpbb/feed/news.php @@ -64,9 +64,8 @@ class news extends \phpbb\feed\topic_base // We really have to get the post ids first! $sql = 'SELECT topic_first_post_id, topic_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $this->db->sql_in_set('forum_id', $in_fid_ary) . ' - AND topic_moved_id = 0 - AND topic_visibility = ' . ITEM_APPROVED . ' + WHERE topic_moved_id = 0 + AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . ' ORDER BY topic_time DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); @@ -85,7 +84,7 @@ class news extends \phpbb\feed\topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_time, t.topic_last_post_time, - p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment', + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, t.topic_visibility', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', diff --git a/phpBB/phpbb/feed/post_base.php b/phpBB/phpbb/feed/post_base.php index c797d6a8ca..cfcd8671a3 100644 --- a/phpBB/phpbb/feed/post_base.php +++ b/phpBB/phpbb/feed/post_base.php @@ -14,7 +14,7 @@ namespace phpbb\feed; * * @package phpBB3 */ -abstract class post_base extends \phpbb\feed\base +abstract class post_base extends \phpbb\feed\attachments_base { var $num_items = 'feed_limit_post'; var $attachments = array(); @@ -46,44 +46,8 @@ abstract class post_base extends \phpbb\feed\base { $item_row['statistics'] = $this->user->lang['POSTED'] . ' ' . $this->user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) . ' ' . $this->separator_stats . ' ' . $this->user->format_date($row[$this->get('published')]) - . (($this->is_moderator_approve_forum($row['forum_id']) && $row['post_visibility'] !== ITEM_APPROVED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_UNAPPROVED'] : ''); + . (($this->is_moderator_approve_forum($row['forum_id']) && (int)$row['post_visibility'] === ITEM_UNAPPROVED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_UNAPPROVED'] : '') + . (($this->is_moderator_approve_forum($row['forum_id']) && (int)$row['post_visibility'] === ITEM_DELETED) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POST_DELETED'] : ''); } } - - function fetch_attachments() - { - $sql_array = array( - 'SELECT' => 'a.*', - 'FROM' => array( - ATTACHMENTS_TABLE => 'a' - ), - 'WHERE' => 'a.in_message = 0 ', - 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC', - ); - - if (isset($this->topic_id)) - { - $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id; - } - else if (isset($this->forum_id)) - { - $sql_array['LEFT_JOIN'] = array( - array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'a.topic_id = t.topic_id', - ) - ); - $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id; - } - - $sql = $this->db->sql_build_query('SELECT', $sql_array); - $result = $this->db->sql_query($sql); - - // Set attachments in feed items - while ($row = $this->db->sql_fetchrow($result)) - { - $this->attachments[$row['post_msg_id']][] = $row; - } - $this->db->sql_freeresult($result); - } } diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index a7acfb502f..10b0f4f645 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -83,6 +83,8 @@ class topic extends \phpbb\feed\post_base unset($forum_ids_passworded); } + + parent::open(); } function get_sql() @@ -103,6 +105,13 @@ class topic extends \phpbb\feed\post_base return true; } + function adjust_item(&$item_row, &$row) + { + parent::adjust_item($item_row, $row); + + $item_row['forum_id'] = $this->forum_id; + } + function get_item() { return ($row = parent::get_item()) ? array_merge($this->topic_data, $row) : $row; diff --git a/phpBB/phpbb/feed/topic_base.php b/phpBB/phpbb/feed/topic_base.php index 7e28e67b82..d25bd0b50f 100644 --- a/phpBB/phpbb/feed/topic_base.php +++ b/phpBB/phpbb/feed/topic_base.php @@ -14,7 +14,7 @@ namespace phpbb\feed; * * @package phpBB3 */ -abstract class topic_base extends \phpbb\feed\base +abstract class topic_base extends \phpbb\feed\attachments_base { var $num_items = 'feed_limit_topic'; @@ -45,9 +45,24 @@ abstract class topic_base extends \phpbb\feed\base { $item_row['statistics'] = $this->user->lang['POSTED'] . ' ' . $this->user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) . ' ' . $this->separator_stats . ' ' . $this->user->format_date($row[$this->get('published')]) - . ' ' . $this->separator_stats . ' ' . $this->user->lang['REPLIES'] . ' ' . $this->content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1 - . ' ' . $this->separator_stats . ' ' . $this->user->lang['VIEWS'] . ' ' . $row['topic_views'] - . (($this->is_moderator_approve_forum($row['forum_id']) && $row['topic_posts_unapproved']) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POSTS_UNAPPROVED'] : ''); + . ' ' . $this->separator_stats . ' ' . $this->user->lang['REPLIES'] . ' ' . ($this->content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1) + . ' ' . $this->separator_stats . ' ' . $this->user->lang['VIEWS'] . ' ' . $row['topic_views']; + + if ($this->is_moderator_approve_forum($row['forum_id'])) + { + if ( (int)$row['topic_visibility'] === ITEM_DELETED) + { + $item_row['statistics'] .= ' ' . $this->separator_stats . ' ' . $this->user->lang['TOPIC_DELETED']; + } + else if ((int)$row['topic_visibility'] === ITEM_UNAPPROVED) + { + $item_row['statistics'] .= ' ' . $this->separator_stats . ' ' . $this->user->lang['TOPIC_UNAPPROVED']; + } + else if ($row['topic_posts_unapproved']) + { + $item_row['statistics'] .= ' ' . $this->separator_stats . ' ' . $this->user->lang['POSTS_UNAPPROVED']; + } + } } } } diff --git a/phpBB/phpbb/feed/topics.php b/phpBB/phpbb/feed/topics.php index e8b9f6de6c..b6d9ec7cc6 100644 --- a/phpBB/phpbb/feed/topics.php +++ b/phpBB/phpbb/feed/topics.php @@ -36,9 +36,8 @@ class topics extends \phpbb\feed\topic_base // We really have to get the post ids first! $sql = 'SELECT topic_first_post_id, topic_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $this->db->sql_in_set('forum_id', $in_fid_ary) . ' - AND topic_moved_id = 0 - AND topic_visibility = ' . ITEM_APPROVED . ' + WHERE topic_moved_id = 0 + AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . ' ORDER BY topic_time DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); @@ -57,7 +56,7 @@ class topics extends \phpbb\feed\topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_time, t.topic_last_post_time, - p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment', + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, t.topic_visibility', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', diff --git a/phpBB/phpbb/feed/topics_active.php b/phpBB/phpbb/feed/topics_active.php index 809a536c2a..c7234510fb 100644 --- a/phpBB/phpbb/feed/topics_active.php +++ b/phpBB/phpbb/feed/topics_active.php @@ -51,9 +51,8 @@ class topics_active extends \phpbb\feed\topic_base // We really have to get the post ids first! $sql = 'SELECT topic_last_post_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' - WHERE ' . $this->db->sql_in_set('forum_id', $in_fid_ary) . ' - AND topic_moved_id = 0 - AND topic_visibility = ' . ITEM_APPROVED . ' + WHERE topic_moved_id = 0 + AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . ' ' . $last_post_time_sql . ' ORDER BY topic_last_post_time DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); @@ -74,7 +73,7 @@ class topics_active extends \phpbb\feed\topic_base 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_views, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time, - p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment', + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, t.topic_visibility', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', |