aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/feed/attachments_base.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2017-01-04 17:44:11 +0100
committerMarc Alexander <admin@m-a-styles.de>2017-01-04 17:44:11 +0100
commit03be94c1f7ca62adf59700584c944966560a31bd (patch)
tree1b2701186552f6ed8445a1c6e1937943c7e24a44 /phpBB/phpbb/feed/attachments_base.php
parent0da910df949a1e9404a19ec22a7f7a2af48e69f7 (diff)
parent3d93fd40edb627dafeede3b5ae3780885e2264fe (diff)
downloadforums-03be94c1f7ca62adf59700584c944966560a31bd.tar
forums-03be94c1f7ca62adf59700584c944966560a31bd.tar.gz
forums-03be94c1f7ca62adf59700584c944966560a31bd.tar.bz2
forums-03be94c1f7ca62adf59700584c944966560a31bd.tar.xz
forums-03be94c1f7ca62adf59700584c944966560a31bd.zip
Merge branch '3.1.x' into 3.2.x
Diffstat (limited to 'phpBB/phpbb/feed/attachments_base.php')
-rw-r--r--phpBB/phpbb/feed/attachments_base.php34
1 files changed, 23 insertions, 11 deletions
diff --git a/phpBB/phpbb/feed/attachments_base.php b/phpBB/phpbb/feed/attachments_base.php
index b14dafe15a..5d3272e0d9 100644
--- a/phpBB/phpbb/feed/attachments_base.php
+++ b/phpBB/phpbb/feed/attachments_base.php
@@ -25,8 +25,11 @@ abstract class attachments_base extends base
/**
* Retrieve the list of attachments that may be displayed
+ *
+ * @param array $post_ids Specify for which post IDs to fetch the attachments (optional)
+ * @param array $topic_ids Specify for which topic IDs to fetch the attachments (optional)
*/
- protected function fetch_attachments()
+ protected function fetch_attachments($post_ids = array(), $topic_ids = array())
{
$sql_array = array(
'SELECT' => 'a.*',
@@ -37,7 +40,20 @@ abstract class attachments_base extends base
'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC',
);
- if (isset($this->topic_id))
+ if (!empty($post_ids))
+ {
+ $sql_array['WHERE'] .= 'AND ' . $this->db->sql_in_set('a.post_msg_id', $post_ids);
+ }
+ else if (!empty($topic_ids))
+ {
+ if (isset($this->topic_id))
+ {
+ $topic_ids[] = $this->topic_id;
+ }
+
+ $sql_array['WHERE'] .= 'AND ' . $this->db->sql_in_set('a.topic_id', $topic_ids);
+ }
+ else if (isset($this->topic_id))
{
$sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id;
}
@@ -51,6 +67,11 @@ abstract class attachments_base extends base
);
$sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id;
}
+ else
+ {
+ // Do not allow querying the full attachments table
+ throw new \RuntimeException($this->user->lang('INVALID_FEED_ATTACHMENTS'));
+ }
$sql = $this->db->sql_build_query('SELECT', $sql_array);
$result = $this->db->sql_query($sql);
@@ -64,15 +85,6 @@ abstract class attachments_base extends base
}
/**
- * {@inheritDoc}
- */
- public function open()
- {
- parent::open();
- $this->fetch_attachments();
- }
-
- /**
* Get attachments related to a given post
*
* @param $post_id int Post id