diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-08-07 01:47:25 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-08-07 01:59:02 +0200 |
commit | 87c822b79448bf375bc76c383d7d9a3606074b19 (patch) | |
tree | 99b74ee0b7d15195cefd59ae405f7a256f325c39 | |
parent | 940b9e0658348be7c66b7f5375f086f2d370abb2 (diff) | |
download | forums-87c822b79448bf375bc76c383d7d9a3606074b19.tar forums-87c822b79448bf375bc76c383d7d9a3606074b19.tar.gz forums-87c822b79448bf375bc76c383d7d9a3606074b19.tar.bz2 forums-87c822b79448bf375bc76c383d7d9a3606074b19.tar.xz forums-87c822b79448bf375bc76c383d7d9a3606074b19.zip |
[feature/attach-dl] Also merge topic_id query. a.topic_id can be used.
PHPBB3-11042
-rw-r--r-- | phpBB/download/file.php | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 0978f93402..75ff708b16 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -151,24 +151,31 @@ if (!$config['allow_attachments'] && !$config['allow_pm_attach']) trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED'); } -// If multiple arguments are provided, the precedence is as follows: -// $download_id, $post_id, $topic_id -if ($download_id || $post_id) +if ($download_id || $post_id || $topic_id) { $sql = 'SELECT a.attach_id, a.in_message, a.post_msg_id, a.extension, a.is_orphan, a.poster_id, a.filetime FROM ' . ATTACHMENTS_TABLE . ' a - WHERE ' . ($download_id ? "a.attach_id = $download_id" : "a.post_msg_id = $post_id"); - $result = $db->sql_query($sql); - $attachments = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); -} -else if ($topic_id) -{ - $sql = 'SELECT a.attach_id, a.in_message, a.post_msg_id, a.extension, a.is_orphan, a.poster_id, a.filetime - FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a - WHERE p.topic_id = $topic_id - AND p.post_attachment = 1 - AND a.post_msg_id = p.post_id"; + WHERE '; + + switch (true) + { + default: + case $download_id: + // Attachment id (only 1 attachment) + $sql .= "a.attach_id = $download_id"; + break; + + case $post_id: + // Post id or private message id (multiple attachments) + $sql .= "a.post_msg_id = $post_id"; + break; + + case $topic_id: + // Topic id (multiple attachments) + $sql .= "a.topic_id = $topic_id"; + break; + } + $result = $db->sql_query($sql); $attachments = $db->sql_fetchrowset($result); $db->sql_freeresult($result); |