Extensions
This commit is contained in:
52
ext/phpbbstudio/dice/migrations/install_acp_module.php
Normal file
52
ext/phpbbstudio/dice/migrations/install_acp_module.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Install ACP module.
|
||||
*/
|
||||
class install_acp_module extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v32x\v325'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dice extension modules to the database.
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['module.add', [
|
||||
'acp',
|
||||
'ACP_CAT_DOT_MODS',
|
||||
'ACP_DICE_CAT',
|
||||
]],
|
||||
['module.add', [
|
||||
'acp',
|
||||
'ACP_DICE_CAT',
|
||||
[
|
||||
'module_basename' => '\phpbbstudio\dice\acp\dice_module',
|
||||
'modes' => ['dashboard'],
|
||||
],
|
||||
]],
|
||||
];
|
||||
}
|
||||
}
|
||||
41
ext/phpbbstudio/dice/migrations/install_config_text.php
Normal file
41
ext/phpbbstudio/dice/migrations/install_config_text.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Install text configuration.
|
||||
*/
|
||||
class install_config_text extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v32x\v325'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dice extension text configurations to the database.
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config_text.add', ['dice_skins', json_encode(['bajahs_red', 'classic_steel'])]],
|
||||
['config_text.add', ['dice_sides', json_encode([4, 6, 8, 10, 12, 20])]],
|
||||
];
|
||||
}
|
||||
}
|
||||
72
ext/phpbbstudio/dice/migrations/install_configs.php
Normal file
72
ext/phpbbstudio/dice/migrations/install_configs.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Install configuration.
|
||||
*/
|
||||
class install_configs extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Check if the migration is effectively installed (entirely optional).
|
||||
*
|
||||
* @return bool True if this migration is installed, False if this migration is not installed
|
||||
* @access public
|
||||
*/
|
||||
public function effectively_installed()
|
||||
{
|
||||
return isset($this->config['dice_version']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v32x\v325'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dice extension configurations to the database.
|
||||
*
|
||||
* @return array Array of configs
|
||||
* @access public
|
||||
*/
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.add', ['dice_sides_only', '1']], /* real dice (bool) */
|
||||
['config.add', ['dice_version', '2.0.0-beta']], /* Dice version */
|
||||
|
||||
['config.add', ['dice_skins_dir', 'ext/phpbbstudio/dice/skins']], /* skin directory relative to root */
|
||||
|
||||
['config.add', ['dice_skins_img_height', 48]], /* skin image height */
|
||||
['config.add', ['dice_skins_img_width', 48]], /* skin image width */
|
||||
|
||||
['config.add', ['dice_max_rolls', '20']], /* rolls limit per post - notations */
|
||||
['config.add', ['dice_per_notation', '0']], /* (eg 2 in 1d6+3d4) */
|
||||
['config.add', ['dice_qty_per_dice', '0']], /* (eg the 2 in 2d6) */
|
||||
['config.add', ['dice_qty_dice_per_notation', '0']], /* (eg 5 in 2d6+3d4) */
|
||||
['config.add', ['dice_sides_per_dice', '0']], /* Sides */
|
||||
['config.add', ['dice_pc_dice_per_notation', '0']], /* Percentile */
|
||||
['config.add', ['dice_fudge_dice_per_notation', '0']], /* Fudge */
|
||||
['config.add', ['dice_penetration_dice_per_notation', '0']], /* Penetration */
|
||||
['config.add', ['dice_compound_dice_per_notation', '0']], /* Compound */
|
||||
['config.add', ['dice_exploding_dice_per_notation', '0']], /* Explode */
|
||||
['config.add', ['dice_rolls_per_dice', '0']], /* (include/exclude compounding rolls) */
|
||||
['config.add', ['dice_rolls_per_notation', '0']], /* (include/exclude compounding rolls) */
|
||||
|
||||
['config.add', ['dice_link_locations', 8]], /* Dice link locations */
|
||||
];
|
||||
}
|
||||
}
|
||||
58
ext/phpbbstudio/dice/migrations/install_permissions.php
Normal file
58
ext/phpbbstudio/dice/migrations/install_permissions.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Install permissions.
|
||||
*/
|
||||
class install_permissions extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v32x\v325'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dice extension permissions to the database.
|
||||
*
|
||||
* @return array Array of permissions
|
||||
* @access public
|
||||
*/
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
/* Forum User permissions */
|
||||
['permission.add', ['f_dice_roll', false]], /* Can roll dice */
|
||||
['permission.add', ['f_dice_edit', false]], /* Can edit a rolled dice */
|
||||
['permission.add', ['f_dice_delete', false]], /* Can delete own dice */
|
||||
['permission.add', ['f_dice_no_limit', false]], /* Can ignore dice limit per post */
|
||||
['permission.add', ['f_dice_view', false]], /* Can view rolled dice */
|
||||
|
||||
/* Forum Moderator permissions */
|
||||
['permission.add', ['f_mod_dice_add', false]], /* Can roll dice on other users' post */
|
||||
['permission.add', ['f_mod_dice_edit', false]], /* Can edit rolled dice on other users' post */
|
||||
['permission.add', ['f_mod_dice_delete', false]], /* Can delete dice on other users' post */
|
||||
|
||||
/* Admin Group permissions */
|
||||
['permission.add', ['a_dice_admin']], /* Can administer the extension's ACP */
|
||||
|
||||
/* Registered user Group permissions */
|
||||
['permission.add', ['u_dice_use_ucp']], /* Can manage the extension's UCP */
|
||||
['permission.add', ['u_dice_test']], /* Can use the 'test notation'page */
|
||||
['permission.add', ['u_dice_skin']], /* Can change dice skin */
|
||||
];
|
||||
}
|
||||
}
|
||||
93
ext/phpbbstudio/dice/migrations/install_roles.php
Normal file
93
ext/phpbbstudio/dice/migrations/install_roles.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Install permission roles.
|
||||
*/
|
||||
class install_roles extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v32x\v325',
|
||||
'\phpbbstudio\dice\migrations\install_permissions',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dice extension permissions to the database.
|
||||
*
|
||||
* @return array Array of permissions
|
||||
* @access public
|
||||
*/
|
||||
public function update_data()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
/* Forum User permissions */
|
||||
if ($this->role_exists('ROLE_FORUM_STANDARD'))
|
||||
{
|
||||
$data[] = ['permission.permission_set', ['ROLE_FORUM_STANDARD', 'f_dice_roll']];
|
||||
$data[] = ['permission.permission_set', ['ROLE_FORUM_STANDARD', 'f_dice_edit']];
|
||||
$data[] = ['permission.permission_set', ['ROLE_FORUM_STANDARD', 'f_dice_delete']];
|
||||
$data[] = ['permission.permission_unset', ['ROLE_FORUM_STANDARD', 'f_dice_no_limit']];
|
||||
$data[] = ['permission.permission_set', ['ROLE_FORUM_STANDARD', 'f_dice_view']];
|
||||
}
|
||||
|
||||
/* Forum Moderator permissions */
|
||||
if ($this->role_exists('ROLE_FORUM_FULL'))
|
||||
{
|
||||
$data[] = ['permission.permission_set', ['ROLE_FORUM_FULL', 'f_mod_dice_add']];
|
||||
$data[] = ['permission.permission_set', ['ROLE_FORUM_FULL', 'f_mod_dice_edit']];
|
||||
$data[] = ['permission.permission_set', ['ROLE_FORUM_FULL', 'f_mod_dice_delete']];
|
||||
}
|
||||
|
||||
/* Admin Group permissions */
|
||||
if ($this->role_exists('ROLE_ADMIN_FULL'))
|
||||
{
|
||||
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_dice_admin']];
|
||||
}
|
||||
|
||||
/* Registered user Group permissions */
|
||||
if ($this->role_exists('ROLE_USER_STANDARD'))
|
||||
{
|
||||
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_dice_use_ucp']];
|
||||
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_dice_test']];
|
||||
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_dice_skin']];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given role does exist or not.
|
||||
*
|
||||
* @param string $role The name of the role
|
||||
* @return bool true if the role exists, false otherwise
|
||||
* @access protected
|
||||
*/
|
||||
protected function role_exists($role)
|
||||
{
|
||||
$sql = 'SELECT role_id
|
||||
FROM ' . $this->table_prefix . "acl_roles
|
||||
WHERE role_name = '" . $this->db->sql_escape($role) . "'";
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$role_id = $this->db->sql_fetchfield('role_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return (bool) $role_id;
|
||||
}
|
||||
}
|
||||
69
ext/phpbbstudio/dice/migrations/install_roles_2.php
Normal file
69
ext/phpbbstudio/dice/migrations/install_roles_2.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Install permission roles.
|
||||
*/
|
||||
class install_roles_2 extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v32x\v325',
|
||||
'\phpbbstudio\dice\migrations\install_roles',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dice extension permissions to the database.
|
||||
*
|
||||
* @return array Array of permissions
|
||||
* @access public
|
||||
*/
|
||||
public function update_data()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
/* Forum User permissions */
|
||||
if ($this->role_exists('ROLE_FORUM_STANDARD'))
|
||||
{
|
||||
$data[] = ['permission.permission_unset', ['ROLE_FORUM_STANDARD', 'f_dice_edit']];
|
||||
$data[] = ['permission.permission_unset', ['ROLE_FORUM_STANDARD', 'f_dice_delete']];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given role does exist or not.
|
||||
*
|
||||
* @param string $role The name of the role
|
||||
* @return bool true if the role exists, false otherwise
|
||||
* @access protected
|
||||
*/
|
||||
protected function role_exists($role)
|
||||
{
|
||||
$sql = 'SELECT role_id
|
||||
FROM ' . $this->table_prefix . "acl_roles
|
||||
WHERE role_name = '" . $this->db->sql_escape($role) . "'";
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$role_id = $this->db->sql_fetchfield('role_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return (bool) $role_id;
|
||||
}
|
||||
}
|
||||
71
ext/phpbbstudio/dice/migrations/install_ucp_module.php
Normal file
71
ext/phpbbstudio/dice/migrations/install_ucp_module.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Install ACP module.
|
||||
*/
|
||||
class install_ucp_module extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Check if the migration is effectively installed (entirely optional).
|
||||
*
|
||||
* @return bool True if this migration is installed, False if this migration is not installed
|
||||
* @access public
|
||||
*/
|
||||
public function effectively_installed()
|
||||
{
|
||||
$sql = 'SELECT module_id
|
||||
FROM ' . $this->table_prefix . "modules
|
||||
WHERE module_class = 'ucp'
|
||||
AND module_langname = 'UCP_DICE_TITLE'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$module_id = (bool) $this->db->sql_fetchfield('module_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $module_id !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v32x\v325'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dice extension modules to the database.
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['module.add', [
|
||||
'ucp',
|
||||
0,
|
||||
'UCP_DICE_TITLE',
|
||||
]],
|
||||
['module.add', [
|
||||
'ucp',
|
||||
'UCP_DICE_TITLE',
|
||||
[
|
||||
'module_basename' => '\phpbbstudio\dice\ucp\main_module',
|
||||
'modes' => ['settings'],
|
||||
],
|
||||
]],
|
||||
];
|
||||
}
|
||||
}
|
||||
118
ext/phpbbstudio/dice/migrations/install_user_schema.php
Normal file
118
ext/phpbbstudio/dice/migrations/install_user_schema.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Install dice tables and columns.
|
||||
*/
|
||||
class install_user_schema extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Check if the migration is effectively installed (entirely optional).
|
||||
*
|
||||
* @return bool True if this migration is installed, False if this migration is not installed
|
||||
* @access public
|
||||
*/
|
||||
public function effectively_installed()
|
||||
{
|
||||
return $this->db_tools->sql_column_exists($this->table_prefix . 'forums', 'dice_enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v32x\v325'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dice extension schema to the database.
|
||||
*
|
||||
* @return array Array of table schema
|
||||
* @access public
|
||||
*/
|
||||
public function update_schema()
|
||||
{
|
||||
return [
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'forums' => [
|
||||
'dice_enabled' => ['BOOL', 0], /* Dice forum (0 = No) */
|
||||
'dice_f_skin' => ['VCHAR_UNI', 'bajahs_red'], /* The skin to use as default */
|
||||
'dice_skin_override' => ['BOOL', 0], /* Override user's choice (0 = No) */
|
||||
],
|
||||
$this->table_prefix . 'users' => [
|
||||
'dice_u_skin' => ['VCHAR_UNI', 'bajahs_red'], /* The skin to use as default */
|
||||
'dice_u_roll_limit' => ['BOOL', 0], /* Overrides forum permission */
|
||||
],
|
||||
],
|
||||
'add_tables' => [
|
||||
$this->table_prefix . 'dice_rolls' => [
|
||||
'COLUMNS' => [
|
||||
'roll_num' => ['ULINT', null, 'auto_increment'],
|
||||
'roll_id' => ['ULINT', 0],
|
||||
'roll_notation' => ['VCHAR_UNI', ''],
|
||||
'roll_dices' => ['TEXT_UNI', ''],
|
||||
'roll_rolls' => ['TEXT_UNI', ''],
|
||||
'roll_output' => ['TEXT_UNI', ''],
|
||||
'roll_total' => ['ULINT', 0],
|
||||
'roll_successes' => ['USINT', 0],
|
||||
'roll_is_pool' => ['BOOL', 0],
|
||||
'roll_time' => ['TIMESTAMP', 0],
|
||||
'roll_edit_user' => ['ULINT', 0],
|
||||
'roll_edit_time' => ['TIMESTAMP', 0],
|
||||
'roll_edit_count' => ['ULINT', 0],
|
||||
'forum_id' => ['ULINT', 0],
|
||||
'topic_id' => ['ULINT', 0],
|
||||
'post_id' => ['ULINT', 0],
|
||||
'user_id' => ['ULINT', 0],
|
||||
],
|
||||
'PRIMARY_KEY' => 'roll_num',
|
||||
'KEYS' => [
|
||||
'roll_id' => ['INDEX', 'roll_id'],
|
||||
'forum_id' => ['INDEX', 'forum_id'],
|
||||
'topic_id' => ['INDEX', 'topic_id'],
|
||||
'post_id' => ['INDEX', 'post_id'],
|
||||
'user_id' => ['INDEX', 'user_id'],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop the dice rolls schema from the database.
|
||||
*
|
||||
* @return array Array of table schema
|
||||
* @access public
|
||||
*/
|
||||
public function revert_schema()
|
||||
{
|
||||
return [
|
||||
'drop_columns' => [
|
||||
$this->table_prefix . 'forums' => [
|
||||
'dice_enabled',
|
||||
'dice_f_skin',
|
||||
'dice_skin_override',
|
||||
],
|
||||
$this->table_prefix . 'users' => [
|
||||
'dice_u_skin',
|
||||
'dice_u_roll_limit',
|
||||
],
|
||||
],
|
||||
'drop_tables' => [
|
||||
$this->table_prefix . 'dice_rolls',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
72
ext/phpbbstudio/dice/migrations/update_skins_directory.php
Normal file
72
ext/phpbbstudio/dice/migrations/update_skins_directory.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* phpBB Studio's Dice extension for the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) 2019 phpBB Studio <https://www.phpbbstudio.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*/
|
||||
|
||||
namespace phpbbstudio\dice\migrations;
|
||||
|
||||
/**
|
||||
* phpBB Studio's Dice Migration: Update skins directory.
|
||||
*/
|
||||
class update_skins_directory extends \phpbb\db\migration\migration
|
||||
{
|
||||
/**
|
||||
* Assign migration file dependencies for this migration.
|
||||
*
|
||||
* @return array Array of migration files
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static public function depends_on()
|
||||
{
|
||||
return [
|
||||
'\phpbb\db\migration\data\v32x\v325',
|
||||
'\phpbbstudio\dice\migrations\install_configs',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the dice skin directory configuration.
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['config.remove', ['dice_version']],
|
||||
|
||||
['if', [
|
||||
$this->config['dice_skins_dir'] === 'ext/phpbbstudio/dice/skins',
|
||||
['config.update', ['dice_skins_dir', 'images/dice']],
|
||||
]],
|
||||
['custom', [[$this, 'mirror_skin_directory']]],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirror the dice skin directory.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function mirror_skin_directory()
|
||||
{
|
||||
global $phpbb_container;
|
||||
|
||||
/** @var \phpbb\filesystem\filesystem $filesystem */
|
||||
$filesystem = $phpbb_container->get('filesystem');
|
||||
|
||||
$origin = $this->phpbb_root_path . 'ext/phpbbstudio/dice/skins';
|
||||
$target = $this->phpbb_root_path . 'images/dice';
|
||||
|
||||
if (!$filesystem->exists($target))
|
||||
{
|
||||
$filesystem->mirror($origin, $target, null, [false, false, false]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user