mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/attach-dl] Also merge topic_id query. a.topic_id can be used.
PHPBB3-11042
This commit is contained in:
parent
940b9e0658
commit
87c822b794
1 changed files with 22 additions and 15 deletions
|
@ -151,24 +151,31 @@ if (!$config['allow_attachments'] && !$config['allow_pm_attach'])
|
||||||
trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
|
trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If multiple arguments are provided, the precedence is as follows:
|
if ($download_id || $post_id || $topic_id)
|
||||||
// $download_id, $post_id, $topic_id
|
|
||||||
if ($download_id || $post_id)
|
|
||||||
{
|
{
|
||||||
$sql = 'SELECT a.attach_id, a.in_message, a.post_msg_id, a.extension, a.is_orphan, a.poster_id, a.filetime
|
$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
|
FROM ' . ATTACHMENTS_TABLE . ' a
|
||||||
WHERE ' . ($download_id ? "a.attach_id = $download_id" : "a.post_msg_id = $post_id");
|
WHERE ';
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
$attachments = $db->sql_fetchrowset($result);
|
switch (true)
|
||||||
$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
|
default:
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a
|
case $download_id:
|
||||||
WHERE p.topic_id = $topic_id
|
// Attachment id (only 1 attachment)
|
||||||
AND p.post_attachment = 1
|
$sql .= "a.attach_id = $download_id";
|
||||||
AND a.post_msg_id = p.post_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);
|
$result = $db->sql_query($sql);
|
||||||
$attachments = $db->sql_fetchrowset($result);
|
$attachments = $db->sql_fetchrowset($result);
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
Loading…
Add table
Reference in a new issue