mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-13 04:04:12 +02:00
[ticket/16820] Move ATTACHMENT_CATEGORY_ constants to attachment namespace
PHPBB3-16820
This commit is contained in:
32
phpBB/phpbb/attachment/attachment_category.php
Normal file
32
phpBB/phpbb/attachment/attachment_category.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\attachment;
|
||||
|
||||
abstract class attachment_category
|
||||
{
|
||||
/** @var int None category */
|
||||
public const NONE = 0;
|
||||
|
||||
/** @var int Inline images */
|
||||
public const IMAGE = 1;
|
||||
|
||||
/** @var int Not used within the database, only while displaying posts */
|
||||
public const THUMB = 4;
|
||||
|
||||
/** @var int Browser-playable audio files */
|
||||
public const AUDIO = 7;
|
||||
|
||||
/** @var int Browser-playable video files */
|
||||
public const VIDEO = 8;
|
||||
}
|
@@ -131,7 +131,7 @@ class upload
|
||||
}
|
||||
|
||||
// Whether the uploaded file is in the image category
|
||||
$is_image = (isset($this->extensions[$this->file->get('extension')]['display_cat'])) ? $this->extensions[$this->file->get('extension')]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE : false;
|
||||
$is_image = (isset($this->extensions[$this->file->get('extension')]['display_cat'])) ? $this->extensions[$this->file->get('extension')]['display_cat'] == \phpbb\attachment\attachment_category::IMAGE : false;
|
||||
|
||||
if (!$this->auth->acl_get('a_') && !$this->auth->acl_get('m_', $forum_id))
|
||||
{
|
||||
|
@@ -132,7 +132,7 @@ class generate extends \phpbb\console\command\command
|
||||
$thumbnail_created = array();
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE)
|
||||
if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == \phpbb\attachment\attachment_category::IMAGE)
|
||||
{
|
||||
$source = $this->phpbb_root_path . $this->config['upload_path'] . '/' . $row['physical_filename'];
|
||||
$destination = $this->phpbb_root_path . $this->config['upload_path'] . '/thumb_' . $row['physical_filename'];
|
||||
|
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\db\migration\data\v400;
|
||||
|
||||
use phpbb\attachment\attachment_category;
|
||||
|
||||
class add_audio_files_attachment_group extends \phpbb\db\migration\migration
|
||||
{
|
||||
public static function depends_on()
|
||||
@@ -40,7 +42,7 @@ class add_audio_files_attachment_group extends \phpbb\db\migration\migration
|
||||
{
|
||||
$sql = 'INSERT INTO ' . $this->table_prefix . 'extension_groups ' . $this->db->sql_build_array('INSERT', [
|
||||
'group_name' => 'AUDIO_FILES',
|
||||
'cat_id' => ATTACHMENT_CATEGORY_AUDIO,
|
||||
'cat_id' => attachment_category::AUDIO,
|
||||
'allow_group' => 0,
|
||||
'upload_icon' => '',
|
||||
'max_filesize' => 0,
|
||||
@@ -51,7 +53,7 @@ class add_audio_files_attachment_group extends \phpbb\db\migration\migration
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->table_prefix . 'extension_groups SET cat_id = ' . ATTACHMENT_CATEGORY_AUDIO . '
|
||||
$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);
|
||||
}
|
||||
|
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace phpbb\db\migration\data\v400;
|
||||
|
||||
use phpbb\attachment\attachment_category;
|
||||
|
||||
class add_video_files_attachment_group extends \phpbb\db\migration\migration
|
||||
{
|
||||
public static function depends_on()
|
||||
@@ -40,7 +42,7 @@ class add_video_files_attachment_group extends \phpbb\db\migration\migration
|
||||
{
|
||||
$sql = 'INSERT INTO ' . $this->table_prefix . 'extension_groups ' . $this->db->sql_build_array('INSERT', [
|
||||
'group_name' => 'VIDEO_FILES',
|
||||
'cat_id' => ATTACHMENT_CATEGORY_VIDEO,
|
||||
'cat_id' => attachment_category::VIDEO,
|
||||
'allow_group' => 0,
|
||||
'upload_icon' => '',
|
||||
'max_filesize' => 0,
|
||||
@@ -51,7 +53,7 @@ class add_video_files_attachment_group extends \phpbb\db\migration\migration
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'UPDATE ' . $this->table_prefix . 'extension_groups SET cat_id = ' . ATTACHMENT_CATEGORY_VIDEO . '
|
||||
$sql = 'UPDATE ' . $this->table_prefix . 'extension_groups SET cat_id = ' . attachment_category::VIDEO . '
|
||||
WHERE ' . $this->db->sql_build_array('SELECT', ['group_id' => $video_group_id]);
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace phpbb\storage\controller;
|
||||
|
||||
use phpbb\attachment\attachment_category;
|
||||
use phpbb\auth\auth;
|
||||
use phpbb\cache\service;
|
||||
use phpbb\config\config;
|
||||
@@ -183,9 +184,9 @@ class attachment extends controller
|
||||
{
|
||||
$attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename'];
|
||||
}
|
||||
else if ($display_cat == ATTACHMENT_CATEGORY_NONE && !$attachment['is_orphan'])
|
||||
else if ($display_cat == attachment_category::NONE && !$attachment['is_orphan'])
|
||||
{
|
||||
if (!(($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$this->user->optionget('viewimg')))
|
||||
if (!(($display_cat == attachment_category::IMAGE || $display_cat == attachment_category::THUMB) && !$this->user->optionget('viewimg')))
|
||||
{
|
||||
// Update download count
|
||||
$this->phpbb_increment_downloads($attachment['attach_id']);
|
||||
|
Reference in New Issue
Block a user