mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-11 03:04:09 +02:00
Merge pull request #5446 from hubaishan/ticket/14771
[Ticket/14771] Support playing audio attachments
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v400;
|
||||
|
||||
class add_audio_files_attachment_group extends \phpbb\db\migration\migration
|
||||
{
|
||||
public static function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v400\dev'];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['custom', [[$this, 'add_audio_files']]],
|
||||
];
|
||||
}
|
||||
|
||||
public function add_audio_files()
|
||||
{
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . $this->table_prefix . 'extension_groups
|
||||
WHERE ' . $this->db->sql_build_array('SELECT', ['group_name' => 'AUDIO_FILES']);
|
||||
$result = $this->db->sql_query($sql);
|
||||
$audio_group_id = $this->db->sql_fetchfield('group_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($audio_group_id === false)
|
||||
{
|
||||
$sql = 'INSERT INTO ' . $this->table_prefix . 'extension_groups ' . $this->db->sql_build_array('INSERT', [
|
||||
'group_name' => 'AUDIO_FILES',
|
||||
'cat_id' => ATTACHMENT_CATEGORY_AUDIO,
|
||||
'allow_group' => 0,
|
||||
'upload_icon' => '',
|
||||
'max_filesize' => 0,
|
||||
'allowed_forums' => '',
|
||||
]);
|
||||
$this->db->sql_query($sql);
|
||||
$audio_group_id = $this->db->sql_nextid();
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->table_prefix . 'extension_groups SET cat_id = ' . ATTACHMENT_CATEGORY_AUDIO . '
|
||||
WHERE ' . $this->db->sql_build_array('SELECT', ['group_id' => $audio_group_id]);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
||||
$audio_extensions = ['mp3', 'wav', 'm4a', 'ogg', 'webm'];
|
||||
|
||||
foreach ($audio_extensions as $audio_extension)
|
||||
{
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . $this->table_prefix . 'extensions
|
||||
WHERE ' . $this->db->sql_build_array('SELECT', ['extension' => $audio_extension]);
|
||||
$result = $this->db->sql_query($sql);
|
||||
$extension_group_id = $this->db->sql_fetchfield('group_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if ($extension_group_id === false)
|
||||
{
|
||||
$sql = 'INSERT INTO ' . $this->table_prefix . 'extensions ' . $this->db->sql_build_array('INSERT', [
|
||||
'group_id' => $audio_group_id,
|
||||
'extension' => $audio_extension,
|
||||
]);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
else if ($extension_group_id != $audio_group_id)
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->table_prefix . "extensions SET group_id = $audio_group_id
|
||||
WHERE " . $this->db->sql_build_array('SELECT', ['extension' => $audio_extension]);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -196,6 +196,8 @@ class extension_guesser extends guesser_base
|
||||
'm2a' => 'audio/mpeg',
|
||||
'm2v' => 'video/mpeg',
|
||||
'm3u' => 'audio/x-mpequrl',
|
||||
'm4a' => 'audio/mp4',
|
||||
'm4v' => 'video/mp4',
|
||||
'man' => 'application/x-troff-man',
|
||||
'map' => 'application/x-navimap',
|
||||
'mar' => 'text/plain',
|
||||
@@ -220,7 +222,8 @@ class extension_guesser extends guesser_base
|
||||
'mov' => 'video/quicktime',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'mp2' => 'audio/x-mpeg',
|
||||
'mp3' => 'audio/x-mpeg-3',
|
||||
'mp3' => 'audio/mpeg',
|
||||
'mp4' => 'video/mp4',
|
||||
'mpa' => 'audio/mpeg',
|
||||
'mpc' => 'application/x-project',
|
||||
'mpe' => 'video/mpeg',
|
||||
@@ -248,6 +251,9 @@ class extension_guesser extends guesser_base
|
||||
'o' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'omc' => 'application/x-omc',
|
||||
'oga' => 'audio/ogg',
|
||||
'ogg' => 'audio/ogg',
|
||||
'ogm' => 'video/ogg',
|
||||
'omcd' => 'application/x-omcdatamaker',
|
||||
'omcr' => 'application/x-omcregerator',
|
||||
'p' => 'text/x-pascal',
|
||||
@@ -419,6 +425,7 @@ class extension_guesser extends guesser_base
|
||||
'wb1' => 'application/x-qpro',
|
||||
'wbmp' => 'image/vnd.wap.wbmp',
|
||||
'web' => 'application/vnd.xara',
|
||||
'webm' => 'audio/webm',
|
||||
'wiz' => 'application/msword',
|
||||
'wk1' => 'application/x-123',
|
||||
'wmf' => 'windows/metafile',
|
||||
|
@@ -254,7 +254,7 @@ class attachment extends controller
|
||||
$response->headers->set('Content-Type', $attachment['mimetype']);
|
||||
|
||||
// Display images in browser and force download for other file types
|
||||
if (strpos($attachment['mimetype'], 'image') !== false)
|
||||
if (strpos($attachment['mimetype'], 'image') !== false || strpos($attachment['mimetype'], 'audio') !== false)
|
||||
{
|
||||
$disposition = $response->headers->makeDisposition(
|
||||
ResponseHeaderBag::DISPOSITION_INLINE,
|
||||
|
Reference in New Issue
Block a user