mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/11148] Pass mimetype guesser to upload_attachment() function
PHPBB3-11148
This commit is contained in:
parent
9bc6e641bf
commit
94a81fa01d
3 changed files with 25 additions and 3 deletions
|
@ -398,11 +398,12 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
|
|||
* @param string $local_storage The path to the local file
|
||||
* @param bool $is_message Whether it is a PM or not
|
||||
* @param \filespec $local_filedata A filespec object created for the local file
|
||||
* @param \phpbb\mimetype\guesser $mimetype_guesser The mimetype guesser object if used
|
||||
* @param \phpbb\plupload\plupload $plupload The plupload object if one is being used
|
||||
*
|
||||
* @return object filespec
|
||||
*/
|
||||
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false, \phpbb\plupload\plupload $plupload = null)
|
||||
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
|
||||
{
|
||||
global $auth, $user, $config, $db, $cache;
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
@ -434,7 +435,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
|
|||
$extensions = $cache->obtain_attach_extensions((($is_message) ? false : (int) $forum_id));
|
||||
$upload->set_allowed_extensions(array_keys($extensions['_allowed_']));
|
||||
|
||||
$file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->form_upload($form_name, $plupload);
|
||||
$file = ($local) ? $upload->local_upload($local_storage, $local_filedata, $mimetype_guesser) : $upload->form_upload($form_name, $mimetype_guesser, $plupload);
|
||||
|
||||
if ($file->init_error)
|
||||
{
|
||||
|
|
|
@ -1082,6 +1082,12 @@ class parse_message extends bbcode_firstpass
|
|||
*/
|
||||
protected $plupload;
|
||||
|
||||
/**
|
||||
* The mimetype guesser object used for attachment mimetypes
|
||||
* @var \phpbb\mimetype\guesser
|
||||
*/
|
||||
protected $mimetype_guesser;
|
||||
|
||||
/**
|
||||
* Init - give message here or manually
|
||||
*/
|
||||
|
@ -1560,7 +1566,7 @@ class parse_message extends bbcode_firstpass
|
|||
{
|
||||
if ($num_attachments < $cfg['max_attachments'] || $auth->acl_gets('m_', 'a_', $forum_id))
|
||||
{
|
||||
$filedata = upload_attachment($form_name, $forum_id, false, '', $is_message, false, $this->plupload);
|
||||
$filedata = upload_attachment($form_name, $forum_id, false, '', $is_message, false, $this->mimetype_guesser, $this->plupload);
|
||||
$error = array_merge($error, $filedata['error']);
|
||||
|
||||
if (!sizeof($error))
|
||||
|
@ -1792,4 +1798,17 @@ class parse_message extends bbcode_firstpass
|
|||
{
|
||||
$this->plupload = $plupload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter function for passing the mimetype_guesser object
|
||||
*
|
||||
* @param \phpbb\mimetype\guesser $mimetype_guesser The mimetype_guesser
|
||||
* object
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function set_mimetype_guesser(\phpbb\mimetype\guesser $mimetype_guesser)
|
||||
{
|
||||
$this->mimetype_guesser = $mimetype_guesser;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -523,7 +523,9 @@ $orig_poll_options_size = sizeof($post_data['poll_options']);
|
|||
|
||||
$message_parser = new parse_message();
|
||||
$plupload = $phpbb_container->get('plupload');
|
||||
$mimetype_guesser = $phpbb_container->get('mimetype.guesser');
|
||||
$message_parser->set_plupload($plupload);
|
||||
$message_parser->set_mimetype_guesser($mimetype_guesser);
|
||||
|
||||
if (isset($post_data['post_text']))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue