diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-02-08 15:56:52 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-02-10 12:37:10 +0100 |
commit | e4129687cbd5d80b73997965ba6a20b1140036d2 (patch) | |
tree | d1969e9962e36141e627308e42d4832ad1613e2d /phpBB/download | |
parent | 8744b0da6d050275f9f2da8f12068238fd44da3c (diff) | |
download | forums-e4129687cbd5d80b73997965ba6a20b1140036d2.tar forums-e4129687cbd5d80b73997965ba6a20b1140036d2.tar.gz forums-e4129687cbd5d80b73997965ba6a20b1140036d2.tar.bz2 forums-e4129687cbd5d80b73997965ba6a20b1140036d2.tar.xz forums-e4129687cbd5d80b73997965ba6a20b1140036d2.zip |
[ticket/12171] Split post and pm download links
PHPBB3-12171
PHPBB3-12172
Diffstat (limited to 'phpBB/download')
-rw-r--r-- | phpBB/download/file.php | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 155e77501f..e44d8c0b3a 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -144,7 +144,8 @@ require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); $download_id = request_var('id', 0); $topic_id = $request->variable('topic_id', 0); -$post_msg_id = $request->variable('post_msg_id', 0); +$post_id = $request->variable('post_id', 0); +$msg_id = $request->variable('msg_id', 0); $archive = $request->variable('archive', '.tar'); $mode = request_var('mode', ''); $thumbnail = request_var('t', false); @@ -165,10 +166,15 @@ if ($download_id) // Attachment id (only 1 attachment) $sql_where = 'attach_id = ' . $download_id; } -else if ($post_msg_id) +else if ($msg_id) { - // Post id or private message id (multiple attachments) - $sql_where = 'is_orphan = 0 AND post_msg_id = ' . $post_msg_id; + // Private message id (multiple attachments) + $sql_where = 'is_orphan = 0 AND in_message = 1 AND post_msg_id = ' . $msg_id; +} +else if ($post_id) +{ + // Post id (multiple attachments) + $sql_where = 'is_orphan = 0 AND in_message = 0 AND post_msg_id = ' . $post_id; } else if ($topic_id) { @@ -328,20 +334,17 @@ else $archive = '.tar'; } - if ($post_msg_id) + if ($msg_id) { - if ($attachment['in_message']) - { - $sql = 'SELECT message_subject AS attach_subject - FROM ' . PRIVMSGS_TABLE . " - WHERE msg_id = $post_msg_id"; - } - else - { - $sql = 'SELECT post_subject AS attach_subject, forum_id - FROM ' . POSTS_TABLE . " - WHERE post_id = $post_msg_id"; - } + $sql = 'SELECT message_subject AS attach_subject + FROM ' . PRIVMSGS_TABLE . " + WHERE msg_id = $msg_id"; + } + else if ($post_id) + { + $sql = 'SELECT post_subject AS attach_subject, forum_id + FROM ' . POSTS_TABLE . " + WHERE post_id = $post_id"; } else { @@ -361,7 +364,7 @@ else } $clean_name = phpbb_download_clean_filename($row['attach_subject']); - $suffix = '_' . (($post_msg_id) ? $post_msg_id : $topic_id) . '_' . $clean_name; + $suffix = '_' . (($msg_id) ? 'm' . $msg_id : (($post_id) ? 'p' . $post_id : 't' . $topic_id)) . '_' . $clean_name; $archive_name = 'attachments' . $suffix; $store_name = 'att_' . time() . '_' . unique_id(); |