Ajout d'une extension

This commit is contained in:
Gauvain Boiché
2020-04-04 18:27:27 +02:00
parent c3ed8cc1c1
commit 3a964fe237
387 changed files with 58921 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: ACP Module migration
*/
class install_acp_module extends \phpbb\db\migration\migration
{
/**
* Checks whether the Advanced Shop System ACP module does exist or not.
*
* @return bool True if the module exists, false otherwise
* @access public
*/
public function effectively_installed()
{
$sql = 'SELECT module_id
FROM ' . $this->table_prefix . "modules
WHERE module_class = 'acp'
AND module_langname = 'ACP_ASS_SYSTEM'";
$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\v327'];
}
/**
* Add the Advanced Shop System ACP module to the database.
*
* @return array Array of module data
* @access public
*/
public function update_data()
{
return [
['module.add', [
'acp',
'ACP_CAT_DOT_MODS',
'ACP_ASS_SYSTEM',
]],
['module.add', [
'acp',
'ACP_ASS_SYSTEM',
[
'module_basename' => '\phpbbstudio\ass\acp\main_module',
'modes' => ['overview', 'settings', 'items', 'files', 'logs'],
],
]],
];
}
}

View File

@@ -0,0 +1,120 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: Configuration migration
*/
class install_configuration extends \phpbb\db\migration\container_aware_migration
{
/**
* Checks whether the Advanced Shop System configuration does exist or not.
*
* @return bool True if this migration is installed, false otherwise.
* @access public
*/
public function effectively_installed()
{
return $this->config->offsetExists('ass_enabled');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\ass\migrations\install_tables'];
}
/**
* Add the Advanced Shop System configuration to the database.
*
* @return array Array of configuration
* @access public
*/
public function update_data()
{
$parser = $this->container->get('text_formatter.parser');
$notes = ':white_check_mark: Install the [b][color=#313131]“Advanced Shop System”[/color][/b].
:arrow_forward: Create your [b]first category[/b].
:arrow_forward: Create your [b]first item[/b].
:arrow_forward: [color=#313131]Purchase[/color] your first item!
:tada: [color=#313131]Celebrate having a shop![/color]';
$notes = $parser->parse($notes);
return [
['config.add', ['ass_enabled', 1]],
['config.add', ['ass_active', 1]],
['config_text.add', ['ass_inactive_desc', '']],
['config.add', ['ass_shop_icon', 'fa-shopping-cart']],
['config.add', ['ass_inventory_icon', 'fa-archive']],
['config.add', ['ass_no_image_icon', 'fa-picture-o']],
['config.add', ['ass_gift_icon', 'fa-gift']],
['config.add', ['ass_gift_enabled', 1]],
['config.add', ['ass_deactivate_conflicts', 1]],
['config.add', ['ass_items_per_page', 20]],
['config.add', ['ass_logs_per_page', 10]],
['config.add', ['ass_panel_featured_banner_size', '']],
['config.add', ['ass_panel_featured_banner_colour', 'gold']],
['config.add', ['ass_panel_featured_icon_colour', 'lighten']],
['config.add', ['ass_panel_featured_icon', 'fa-star']],
['config.add', ['ass_panel_featured_limit', 5]],
['config.add', ['ass_panel_sale_banner_size', '']],
['config.add', ['ass_panel_sale_banner_colour', 'green']],
['config.add', ['ass_panel_sale_icon_colour', 'darken']],
['config.add', ['ass_panel_sale_icon', 'fa-tag']],
['config.add', ['ass_panel_sale_limit', 5]],
['config.add', ['ass_panel_featured_sale_banner_size', 'small']],
['config.add', ['ass_panel_featured_sale_banner_colour', 'purple']],
['config.add', ['ass_panel_featured_sale_icon_colour', 'white']],
['config.add', ['ass_panel_featured_sale_icon', 'fa-lightbulb-o']],
['config.add', ['ass_panel_featured_sale_limit', 3]],
['config.add', ['ass_panel_recent_banner_size', 'small']],
['config.add', ['ass_panel_recent_banner_colour', 'blue']],
['config.add', ['ass_panel_recent_icon_colour', 'white']],
['config.add', ['ass_panel_recent_icon', 'fa-line-chart']],
['config.add', ['ass_panel_recent_limit', 5]],
['config.add', ['ass_panel_limited_banner_size', 'small']],
['config.add', ['ass_panel_limited_banner_colour', 'red']],
['config.add', ['ass_panel_limited_icon_colour', 'white']],
['config.add', ['ass_panel_limited_icon', 'fa-sort-numeric-desc']],
['config.add', ['ass_panel_limited_limit', 5]],
['config.add', ['ass_panel_random_banner_size', '']],
['config.add', ['ass_panel_random_banner_colour', '']],
['config.add', ['ass_panel_random_icon_colour', '']],
['config.add', ['ass_panel_random_icon', '']],
['config.add', ['ass_panel_random_limit', 10]],
['config.add', ['ass_carousel_arrows', 1]],
['config.add', ['ass_carousel_dots', 1]],
['config.add', ['ass_carousel_fade', 0]],
['config.add', ['ass_carousel_play', 1]],
['config.add', ['ass_carousel_play_speed', 3000]],
['config.add', ['ass_carousel_speed', 300]],
['config.add', ['ass_notification_gift_id', 0]],
['config.add', ['ass_notification_stock_id', 0]],
['config_text.add', ['ass_admin_notes', $notes]],
];
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: Directories migration
*/
class install_directories 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 ['\phpbbstudio\ass\migrations\install_configuration'];
}
/**
* Create the shop directories to the filesystem.
*
* @return array
* @access public
*/
public function update_data()
{
return [
['custom', [[$this, 'create_shop_directories']]],
];
}
/**
* Create the shop directories.
*
* @throws \Exception
* @return void
* @access public
*/
public function create_shop_directories()
{
global $phpbb_container;
/** @var \phpbb\filesystem\filesystem $filesystem */
$filesystem = $phpbb_container->get('filesystem');
$directories = [
$this->phpbb_root_path . 'files/aps',
$this->phpbb_root_path . 'images/aps',
];
$filesystem->mkdir($directories);
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: Permissions migration
*/
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 ['\phpbbstudio\ass\migrations\install_acp_module'];
}
/**
* Add the ASS extension permissions to the database.
*
* @return array Array of permissions
* @access public
*/
public function update_data()
{
return [
/* Admin Group permissions */
['permission.add', ['a_ass_overview']],
['permission.add', ['a_ass_settings']],
['permission.add', ['a_ass_items']],
['permission.add', ['a_ass_files']],
['permission.add', ['a_ass_logs']],
/* Registered user Group permissions */
['permission.add', ['u_ass_can_purchase']],
['permission.add', ['u_ass_can_view_inactive_shop']],
['permission.add', ['u_ass_can_view_inactive_items']],
['permission.add', ['u_ass_can_gift']],
['permission.add', ['u_ass_can_receive_gift']],
['permission.add', ['u_ass_can_receive_stock_notifications']],
];
}
}

View File

@@ -0,0 +1,96 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: Permission roles migration
*/
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 ['\phpbbstudio\ass\migrations\install_permissions'];
}
/**
* Add the Advanced Shop System permissions' roles to the database.
*
* @return array Array of permission
* @access public
*/
public function update_data()
{
$data = [];
if ($this->role_exists('ROLE_USER_STANDARD'))
{
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_ass_can_purchase']];
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_ass_can_view_inactive_shop']];
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_ass_can_view_inactive_items']];
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_ass_can_gift']];
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_ass_can_receive_gift']];
}
if ($this->role_exists('ROLE_USER_FULL'))
{
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_ass_can_purchase']];
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_ass_can_view_inactive_shop']];
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_ass_can_view_inactive_items']];
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_ass_can_gift']];
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_ass_can_receive_gift']];
}
if ($this->role_exists('ROLE_ADMIN_STANDARD'))
{
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_ass_overview']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_ass_settings']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_ass_items']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_ass_files']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_ass_logs']];
}
if ($this->role_exists('ROLE_ADMIN_FULL'))
{
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_ass_overview']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_ass_settings']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_ass_items']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_ass_files']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_ass_logs']];
}
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
*/
private 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;
}
}

View File

@@ -0,0 +1,175 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: Tables migration
*/
class install_tables extends \phpbb\db\migration\migration
{
/**
* Checks whether the Advanced Shop System DB table does exist or not.
*
* @return bool True if this migration is installed, false otherwise.
* @access public
*/
public function effectively_installed()
{
return $this->db_tools->sql_table_exists($this->table_prefix . 'ass_categories');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\ass\migrations\install_acp_module'];
}
/**
* Add the Advanced Shop System tables and columns to the database.
*
* @return array Array of tables and columns data
* @access public
*/
public function update_schema()
{
return [
'add_tables' => [
$this->table_prefix . 'ass_categories' => [
'COLUMNS' => [
'category_id' => ['ULINT', null, 'auto_increment'],
'category_order' => ['ULINT', 0],
'category_active' => ['BOOL', 1],
'category_title' => ['VCHAR_UNI', ''],
'category_slug' => ['VCHAR_UNI', ''],
'category_icon' => ['VCHAR_UNI', ''],
'category_desc' => ['MTEXT_UNI', ''],
'item_conflicts' => ['ULINT', 0],
],
'PRIMARY_KEY' => 'category_id',
],
$this->table_prefix . 'ass_items' => [
'COLUMNS' => [
'item_id' => ['ULINT', null, 'auto_increment'],
'item_order' => ['INT:11', 0],
'item_active' => ['BOOL', 1],
'item_title' => ['VCHAR_UNI', ''],
'item_slug' => ['VCHAR_UNI', ''],
'item_icon' => ['VCHAR_UNI', ''],
'item_desc' => ['MTEXT_UNI', ''],
'item_type' => ['VCHAR_UNI', ''],
'item_data' => ['MTEXT_UNI', ''],
'item_price' => ['DECIMAL:14', 0.00],
'item_count' => ['ULINT', 0],
'item_purchases' => ['ULINT', 0],
'item_stock' => ['ULINT', 0],
'item_stock_threshold' => ['ULINT', 0],
'item_stock_unlimited' => ['BOOL', 1],
'item_expire_string' => ['VCHAR_UNI', ''],
'item_expire_seconds' => ['INT:11', 0],
'item_delete_string' => ['VCHAR_UNI', ''],
'item_delete_seconds' => ['INT:11', 0],
'item_refund_string' => ['VCHAR_UNI', ''],
'item_refund_seconds' => ['INT:11', 0],
'item_gift' => ['BOOL', 0],
'item_gift_type' => ['BOOL', 0],
'item_gift_percentage' => ['INT:3', 0],
'item_gift_price' => ['DECIMAL:14', 0.00],
'item_sale_price' => ['DECIMAL:14', 0.00],
'item_sale_start' => ['TIMESTAMP', 0],
'item_sale_until' => ['TIMESTAMP', 0],
'item_featured_start' => ['TIMESTAMP', 0],
'item_featured_until' => ['TIMESTAMP', 0],
'item_create_time' => ['TIMESTAMP', 0],
'item_edit_time' => ['TIMESTAMP', 0],
'item_background' => ['VCHAR_UNI', ''],
'item_images' => ['MTEXT_UNI', ''],
'item_conflict' => ['BOOL', 0],
'category_id' => ['ULINT', 0],
],
'PRIMARY_KEY' => 'item_id',
'KEYS' => [
'category_id' => ['INDEX', 'category_id'],
],
],
$this->table_prefix . 'ass_inventory' => [
'COLUMNS' => [
'inventory_id' => ['ULINT', null, 'auto_increment'],
'category_id' => ['ULINT', 0],
'item_id' => ['ULINT', 0],
'user_id' => ['ULINT', 0],
'gifter_id' => ['ULINT', 0],
'use_count' => ['ULINT', 0],
'use_time' => ['TIMESTAMP', 0],
'purchase_time' => ['TIMESTAMP', 0],
'purchase_price' => ['DECIMAL:14', 0.00],
],
'PRIMARY_KEY' => 'inventory_id',
'KEYS' => [
'category_id' => ['INDEX', 'category_id'],
'item_id' => ['INDEX', 'item_id'],
'user_id' => ['INDEX', 'user_id'],
'gifter_id' => ['INDEX', ['gifter_id']],
],
],
$this->table_prefix . 'ass_logs' => [
'COLUMNS' => [
'log_id' => ['ULINT', null, 'auto_increment'],
'log_ip' => ['VCHAR:40', ''],
'log_time' => ['TIMESTAMP', 0],
'points_old' => ['DECIMAL:14', 0.00],
'points_sum' => ['DECIMAL:14', 0.00],
'points_new' => ['DECIMAL:14', 0.00],
'item_purchase' => ['BOOL', 0],
'item_id' => ['ULINT', 0],
'category_id' => ['ULINT', 0],
'user_id' => ['ULINT', 0],
'recipient_id' => ['ULINT', 0],
],
'PRIMARY_KEY' => 'log_id',
'KEYS' => [
'item_id' => ['INDEX', 'item_id'],
'category_id' => ['INDEX', 'category_id'],
'user_id' => ['INDEX', 'user_id'],
'recipient_id' => ['INDEX', 'recipient_id'],
],
],
],
];
}
/**
* Reverts the database schema by providing a set of change instructions
*
* @return array Array of schema changes
* (compatible with db_tools->perform_schema_changes())
* @access public
*/
public function revert_schema()
{
return [
'drop_tables' => [
$this->table_prefix . 'ass_categories',
$this->table_prefix . 'ass_inventory',
$this->table_prefix . 'ass_items',
$this->table_prefix . 'ass_logs',
],
];
}
}

View File

@@ -0,0 +1,68 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: ACP Module update migration
*/
class update_acp_module extends \phpbb\db\migration\migration
{
/**
* Checks whether the Advanced Shop System ACP module does exist or not.
*
* @return bool True if the module exists, false otherwise
* @access public
*/
public function effectively_installed()
{
$sql = 'SELECT module_id
FROM ' . $this->table_prefix . "modules
WHERE module_class = 'acp'
AND module_langname = 'ACP_ASS_INVENTORY'";
$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 ['\phpbbstudio\ass\migrations\install_acp_module'];
}
/**
* Update the Advanced Shop System ACP module to the database.
*
* @return array Array of module data
* @access public
*/
public function update_data()
{
return [
['module.add', [
'acp',
'ACP_ASS_SYSTEM',
[
'module_basename' => '\phpbbstudio\ass\acp\main_module',
'modes' => ['inventory'],
],
]],
];
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: Permissions update migration
*/
class update_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 ['\phpbbstudio\ass\migrations\install_permissions'];
}
/**
* Update the ASS extension permissions to the database.
*
* @return array Array of permissions
* @access public
*/
public function update_data()
{
return [
/* Admin Group permissions */
['permission.add', ['a_ass_inventory']],
];
}
}

View File

@@ -0,0 +1,70 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: Permission roles migration
*/
class update_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 ['\phpbbstudio\ass\migrations\update_permissions'];
}
/**
* Update the Advanced Shop System permissions' roles to the database.
*
* @return array Array of permission
* @access public
*/
public function update_data()
{
$data = [];
if ($this->role_exists('ROLE_ADMIN_STANDARD'))
{
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_ass_inventory']];
}
if ($this->role_exists('ROLE_ADMIN_FULL'))
{
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_ass_inventory']];
}
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
*/
private 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;
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: Gift column migration
*/
class update_tables extends \phpbb\db\migration\migration
{
/**
* Checks whether the Advanced Shop System DB column does exist or not.
*
* @return bool True if this migration is installed, false otherwise.
* @access public
*/
public function effectively_installed()
{
return $this->db_tools->sql_column_exists($this->table_prefix . 'ass_items', 'item_gift_only');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\ass\migrations\install_tables'];
}
/**
* Add the Advanced Shop System tables and columns to the database.
*
* @return array Array of tables and columns data
* @access public
*/
public function update_schema()
{
return [
'add_columns' => [
$this->table_prefix . 'ass_items' => [
'item_available_until' => ['TIMESTAMP', 0, 'after' => 'item_featured_until'],
'item_available_start' => ['TIMESTAMP', 0, 'after' => 'item_featured_until'],
'item_gift_only' => ['BOOL', 0, 'after' => 'item_gift'],
'item_related_items' => ['VCHAR:255', '', 'after' => 'item_images'],
'item_related_enabled' => ['BOOL', 1, 'after' => 'item_images'],
],
],
];
}
/**
* Reverts the database schema by providing a set of change instructions
*
* @return array Array of schema changes
* (compatible with db_tools->perform_schema_changes())
* @access public
*/
public function revert_schema()
{
return [
'drop_columns' => [
$this->table_prefix . 'ass_items' => [
'item_available_start',
'item_available_until',
'item_gift_only',
'item_related_enabled',
'item_related_items',
],
],
];
}
}

View File

@@ -0,0 +1,69 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: v1.1.1 Update configuration migration
*/
class v111_update_configuration extends \phpbb\db\migration\container_aware_migration
{
/**
* Checks whether the Advanced Shop System configuration does exist or not.
*
* @return bool True if this migration is installed, false otherwise.
* @access public
*/
public function effectively_installed()
{
return $this->config->offsetExists('ass_panel_sale_width');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\ass\migrations\install_configuration'];
}
/**
* Add the Advanced Shop System configuration to the database.
*
* @return array Array of configuration
* @access public
*/
public function update_data()
{
return [
['config.add', ['ass_panel_featured_order', 1]],
['config.add', ['ass_panel_featured_width', 6]],
['config.add', ['ass_panel_sale_order', 2]],
['config.add', ['ass_panel_sale_width', 6]],
['config.add', ['ass_panel_featured_sale_order', 3]],
['config.add', ['ass_panel_featured_sale_width', 6]],
['config.add', ['ass_panel_recent_order', 4]],
['config.add', ['ass_panel_recent_width', 6]],
['config.add', ['ass_panel_limited_order', 5]],
['config.add', ['ass_panel_limited_width', 6]],
['config.add', ['ass_panel_random_order', 6]],
['config.add', ['ass_panel_random_width', 3]],
];
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: v1.1.1 Permissions update migration
*/
class v111_update_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 ['\phpbbstudio\ass\migrations\install_permissions'];
}
/**
* Update the ASS extension permissions to the database.
*
* @return array Array of permissions
* @access public
*/
public function update_data()
{
$data = [
['permission.add', ['u_ass_can_stack']],
];
if ($this->role_exists('ROLE_USER_STANDARD'))
{
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_ass_can_stack']];
}
if ($this->role_exists('ROLE_USER_FULL'))
{
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_ass_can_stack']];
}
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
*/
private 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;
}
}

View File

@@ -0,0 +1,75 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: v1.1.1 Stack column migration
*/
class v111_update_tables extends \phpbb\db\migration\migration
{
/**
* Checks whether the Advanced Shop System DB column does exist or not.
*
* @return bool True if this migration is installed, false otherwise.
* @access public
*/
public function effectively_installed()
{
return $this->db_tools->sql_column_exists($this->table_prefix . 'ass_items', 'item_stack');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\ass\migrations\install_tables'];
}
/**
* Add the Advanced Shop System tables and columns to the database.
*
* @return array Array of tables and columns data
* @access public
*/
public function update_schema()
{
return [
'add_columns' => [
$this->table_prefix . 'ass_items' => [
'item_stack' => ['ULINT', 1, 'after' => 'item_count'],
],
],
];
}
/**
* Reverts the database schema by providing a set of change instructions
*
* @return array Array of schema changes
* (compatible with db_tools->perform_schema_changes())
* @access public
*/
public function revert_schema()
{
return [
'drop_columns' => [
$this->table_prefix . 'ass_items' => [
'item_stack',
],
],
];
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: v1.1.2 Update configuration migration
*/
class v112_update_configuration extends \phpbb\db\migration\container_aware_migration
{
/**
* Checks whether the Advanced Shop System configuration does exist or not.
*
* @return bool True if this migration is installed, false otherwise.
* @access public
*/
public function effectively_installed()
{
return $this->config->offsetExists('ass_purge_cache');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\ass\migrations\install_configuration'];
}
/**
* Add the Advanced Shop System configuration to the database.
*
* @return array Array of configuration
* @access public
*/
public function update_data()
{
return [
['config.add', ['ass_purge_cache', false]],
];
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
*
* phpBB Studio - Advanced Shop System. An 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\ass\migrations;
/**
* phpBB Studio - Advanced Shop System: v1.1.3 Update configuration migration
*/
class v113_update_configuration extends \phpbb\db\migration\container_aware_migration
{
/**
* Checks whether the Advanced Shop System configuration does exist or not.
*
* @return bool True if this migration is installed, false otherwise.
* @access public
*/
public function effectively_installed()
{
return $this->config->offsetExists('ass_link_locations');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\ass\migrations\install_configuration'];
}
/**
* Add the Advanced Shop System configuration to the database.
*
* @return array Array of configuration
* @access public
*/
public function update_data()
{
return [
['config.add', ['ass_link_locations', 0]],
];
}
}