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,78 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: ACP Module.
*/
class install_acp_module extends \phpbb\db\migration\migration
{
/**
* Allows you to check if the migration is effectively installed (entirely optional)
*
* This is checked when a migration is installed. If true is returned, the migration will be set as
* installed without performing the database changes.
* This function is intended to help moving to migrations from a previous database updater, where some
* migrations may have been installed already even though they are not yet listed in the migrations table.
*
* @return bool True if this migration is installed, False if this migration is not installed (checked on install)
* @access public
*/
public function effectively_installed()
{
$sql = 'SELECT module_id
FROM ' . $this->table_prefix . "modules
WHERE module_class = 'acp'
AND module_langname = 'ACP_APS_POINTS'";
$result = $this->db->sql_query($sql);
$module_id = $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 Points 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_APS_POINTS'
]],
['module.add', [
'acp',
'ACP_APS_POINTS',
[
'module_basename' => '\phpbbstudio\aps\acp\main_module',
'modes' => ['settings', 'display', 'points', 'logs'],
],
]],
];
}
}

View File

@@ -0,0 +1,84 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: Configuration.
*/
class install_configuration extends \phpbb\db\migration\migration
{
/**
* Allows you to check if the migration is effectively installed (entirely optional)
*
* This is checked when a migration is installed. If true is returned, the migration will be set as
* installed without performing the database changes.
* This function is intended to help moving to migrations from a previous database updater, where some
* migrations may have been installed already even though they are not yet listed in the migrations table.
*
* @return bool True if this migration is installed, False if this migration is not installed (checked on install)
* @access public
*/
public function effectively_installed()
{
return $this->config->offsetExists('aps_points_name_en');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\aps\migrations\install_user_schema'];
}
/**
* Add the Advanced Points System configuration to the database.
*
* @return array Array of configuration
* @access public
*/
public function update_data()
{
return [
['config.add', ['aps_points_name_en', 'Points']],
['config.add', ['aps_points_safe_mode', false]], // @todo Change to true upon release
['config.add', ['aps_points_icon', 'fa-money']],
['config.add', ['aps_points_icon_position', 1]],
['config.add', ['aps_points_decimals', 2]],
['config.add', ['aps_points_separator_dec', ',']],
['config.add', ['aps_points_separator_thou', htmlspecialchars('&#8239;')]],
['config.add', ['aps_points_display_pm', true]],
['config.add', ['aps_points_display_post', true]],
['config.add', ['aps_points_display_profile', true]],
['config.add', ['aps_points_min', '']],
['config.add', ['aps_points_max', '']],
['config.add', ['aps_points_exclude_words', 1]],
['config.add', ['aps_points_exclude_chars', 1]],
['config.add', ['aps_birthday_last_run', 0, true]],
['config.add', ['aps_notification_id', 0]],
['config.add', ['aps_actions_per_page', 10]],
['config.add', ['aps_chain_merge_delete', false]],
['config.add', ['aps_chain_merge_move', false]],
['config.add', ['aps_chain_warn_pm', false]],
['config.add', ['aps_display_top_change', true]],
['config.add', ['aps_display_top_count', 3]],
['config.add', ['aps_display_adjustments', 5]],
['config.add', ['aps_display_graph_time', 1500]],
];
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: MCP Module.
*/
class install_mcp_module extends \phpbb\db\migration\migration
{
/**
* Allows you to check if the migration is effectively installed (entirely optional)
*
* This is checked when a migration is installed. If true is returned, the migration will be set as
* installed without performing the database changes.
* This function is intended to help moving to migrations from a previous database updater, where some
* migrations may have been installed already even though they are not yet listed in the migrations table.
*
* @return bool True if this migration is installed, False if this migration is not installed (checked on install)
* @access public
*/
public function effectively_installed()
{
$sql = 'SELECT module_id
FROM ' . $this->table_prefix . "modules
WHERE module_class = 'mcp'
AND module_langname = 'MCP_APS_POINTS'";
$result = $this->db->sql_query($sql);
$module_id = $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\aps\migrations\install_acp_module'];
}
/**
* Add the Advanced Points System MCP module to the database.
*
* @return array Array of module data
* @access public
*/
public function update_data()
{
return [
['module.add', [
'mcp',
0,
'MCP_APS_POINTS'
]],
['module.add', [
'mcp',
'MCP_APS_POINTS',
[
'module_basename' => '\phpbbstudio\aps\mcp\main_module',
'modes' => ['front', 'change', 'logs'],
],
]],
];
}
}

View File

@@ -0,0 +1,117 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: 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 ['\phpbbstudio\aps\migrations\install_user_schema'];
}
/**
* Add the Advanced Points System permissions to the database.
*
* @return array Array of permission
* @access public
*/
public function update_data()
{
$data = [
['permission.add', ['a_aps_logs']],
['permission.add', ['a_aps_points']],
['permission.add', ['a_aps_reasons']],
['permission.add', ['a_aps_display']],
['permission.add', ['a_aps_settings']],
['permission.add', ['m_aps_adjust_custom']],
['permission.add', ['m_aps_adjust_reason']],
['permission.add', ['u_aps_view_build']],
['permission.add', ['u_aps_view_logs']],
['permission.add', ['u_aps_view_mod']],
];
if ($this->role_exists('ROLE_USER_STANDARD'))
{
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_aps_view_build']];
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_aps_view_logs']];
// Can NOT view the moderator's name
}
if ($this->role_exists('ROLE_USER_FULL'))
{
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_aps_view_build']];
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_aps_view_logs']];
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_aps_view_mod']];
}
if ($this->role_exists('ROLE_MOD_STANDARD'))
{
$data[] = ['permission.permission_set', ['ROLE_MOD_STANDARD', 'm_aps_adjust_reason']];
// Can NOT adjust a user's points with a custom action, only admin defined ones
}
if ($this->role_exists('ROLE_MOD_FULL'))
{
$data[] = ['permission.permission_set', ['ROLE_MOD_FULL', 'm_aps_adjust_custom']];
$data[] = ['permission.permission_set', ['ROLE_MOD_FULL', 'm_aps_adjust_reason']];
}
if ($this->role_exists('ROLE_ADMIN_STANDARD'))
{
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_aps_logs']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_aps_points']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_aps_reasons']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_aps_display']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_STANDARD', 'a_aps_settings']];
}
if ($this->role_exists('ROLE_ADMIN_FULL'))
{
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_aps_logs']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_aps_points']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_aps_reasons']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_aps_display']];
$data[] = ['permission.permission_set', ['ROLE_ADMIN_FULL', 'a_aps_settings']];
}
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 ' . ACL_ROLES_TABLE . '
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,79 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: UCP Module.
*/
class install_ucp_module extends \phpbb\db\migration\migration
{
/**
* Allows you to check if the migration is effectively installed (entirely optional)
*
* This is checked when a migration is installed. If true is returned, the migration will be set as
* installed without performing the database changes.
* This function is intended to help moving to migrations from a previous database updater, where some
* migrations may have been installed already even though they are not yet listed in the migrations table.
*
* @return bool True if this migration is installed, False if this migration is not installed (checked on install)
* @access public
*/
public function effectively_installed()
{
$sql = 'SELECT module_id
FROM ' . $this->table_prefix . "modules
WHERE module_class = 'ucp'
AND module_langname = 'UCP_APS_POINTS'";
$result = $this->db->sql_query($sql);
$module_id = $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\aps\migrations\install_acp_module'];
}
/**
* Add the Advanced Points System UCP module to the database.
*
* @return array Array of module data
* @access public
*/
public function update_data()
{
return [
['module.add', [
'ucp',
0,
[
'module_enabled' => 1,
'module_display' => 1,
'module_basename' => '',
'module_class' => 'ucp',
'parent_id' => 0,
'module_langname' => 'UCP_APS_POINTS',
'module_mode' => '',
'module_auth' => 'ext_phpbbstudio/aps',
]
]],
];
}
}

View File

@@ -0,0 +1,142 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: Database changes.
*/
class install_user_schema extends \phpbb\db\migration\migration
{
/**
* Allows you to check if the migration is effectively installed (entirely optional)
*
* This is checked when a migration is installed. If true is returned, the migration will be set as
* installed without performing the database changes.
* This function is intended to help moving to migrations from a previous database updater, where some
* migrations may have been installed already even though they are not yet listed in the migrations table.
*
* @return bool True if this migration is installed, False if this migration is not installed (checked on install)
* @access public
*/
public function effectively_installed()
{
return $this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_points');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\aps\migrations\install_acp_module'];
}
/**
* Add the Advanced Points 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 . 'users' => [
'user_points' => ['DECIMAL:14', 0.00],
],
],
'add_tables' => [
$this->table_prefix . 'aps_display' => [
'COLUMNS' => [
'user_id' => ['ULINT', 0],
'aps_display' => ['MTEXT_UNI', ''],
],
'PRIMARY_KEY' => 'user_id',
],
$this->table_prefix . 'aps_logs' => [
'COLUMNS' => [
'log_id' => ['ULINT', null, 'auto_increment'],
'log_action' => ['TEXT_UNI', ''],
'log_actions' => ['MTEXT_UNI', ''],
'log_time' => ['TIMESTAMP', 0],
'log_approved' => ['BOOL', 1],
'forum_id' => ['ULINT', 0],
'topic_id' => ['ULINT', 0],
'post_id' => ['ULINT', 0],
'user_id' => ['ULINT', 0],
'reportee_id' => ['ULINT', 0],
'reportee_ip' => ['VCHAR:40', ''],
'points_old' => ['DECIMAL:14', 0.00],
'points_sum' => ['DECIMAL:14', 0.00],
'points_new' => ['DECIMAL:14', 0.00],
],
'PRIMARY_KEY' => 'log_id',
'KEYS' => [
'forum_id' => ['INDEX', 'forum_id'],
'topic_id' => ['INDEX', 'topic_id'],
'post_id' => ['INDEX', 'post_id'],
'user_id' => ['INDEX', 'user_id'],
'reportee_id' => ['INDEX', 'reportee_id'],
],
],
$this->table_prefix . 'aps_points' => [
'COLUMNS' => [
'points_name' => ['VCHAR_UNI', ''],
'points_value' => ['DECIMAL:6', 0.00],
'forum_id' => ['ULINT', 0],
],
'PRIMARY_KEY' => ['points_name', 'forum_id'],
'KEYS' => [
'forum_id' => ['INDEX', 'forum_id'],
],
],
$this->table_prefix . 'aps_reasons' => [
'COLUMNS' => [
'reason_id' => ['ULINT', null, 'auto_increment'],
'reason_title' => ['VCHAR_UNI', ''],
'reason_desc' => ['TEXT_UNI', ''],
'reason_points' => ['DECIMAL:14', 0.00],
'reason_order' => ['UINT', 0],
],
'PRIMARY_KEY' => 'reason_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_columns' => [
$this->table_prefix . 'users' => [
'user_points',
],
],
'drop_tables' => [
$this->table_prefix . 'aps_display',
$this->table_prefix . 'aps_logs',
$this->table_prefix . 'aps_points',
$this->table_prefix . 'aps_reasons',
],
];
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: Configuration.
*/
class update_configuration extends \phpbb\db\migration\migration
{
/**
* Allows you to check if the migration is effectively installed (entirely optional)
*
* This is checked when a migration is installed. If true is returned, the migration will be set as
* installed without performing the database changes.
* This function is intended to help moving to migrations from a previous database updater, where some
* migrations may have been installed already even though they are not yet listed in the migrations table.
*
* @return bool True if this migration is installed, False if this migration is not installed (checked on install)
* @access public
*/
public function effectively_installed()
{
return $this->config->offsetExists('aps_points_icon_img');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\aps\migrations\install_configuration'];
}
/**
* Add the Advanced Points System configuration to the database.
*
* @return array Array of configuration
* @access public
*/
public function update_data()
{
return [
['config.add', ['aps_points_icon_img', '']],
];
}
}

View File

@@ -0,0 +1,75 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: Permissions update.
*/
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\aps\migrations\install_permissions'];
}
/**
* Add additional Advanced Points System permissions to the database.
*
* @return array Array of permission
* @access public
*/
public function update_data()
{
$data = [
['permission.add', ['u_aps_view_build_other']],
['permission.add', ['u_aps_view_logs_other']],
];
if ($this->role_exists('ROLE_USER_STANDARD'))
{
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_aps_view_build_other']];
$data[] = ['permission.permission_set', ['ROLE_USER_STANDARD', 'u_aps_view_logs_other']];
}
if ($this->role_exists('ROLE_USER_FULL'))
{
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_aps_view_build_other']];
$data[] = ['permission.permission_set', ['ROLE_USER_FULL', 'u_aps_view_logs_other']];
}
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 ' . ACL_ROLES_TABLE . '
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,58 @@
<?php
/**
*
* phpBB Studio - Advanced Points 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\aps\migrations;
/**
* phpBB Studio - Advanced Points System migrations: Configuration.
*/
class v105_configuration extends \phpbb\db\migration\migration
{
/**
* Allows you to check if the migration is effectively installed (entirely optional)
*
* @return bool True if this migration is installed, False if this migration is not installed (checked on install)
* @access public
*/
public function effectively_installed()
{
return $this->config->offsetExists('aps_ignore_criteria');
}
/**
* Assign migration file dependencies for this migration.
*
* @return array Array of migration files
* @access public
* @static
*/
static public function depends_on()
{
return ['\phpbbstudio\aps\migrations\update_configuration'];
}
/**
* Add the Advanced Points System configuration to the database.
*
* @return array Array of configuration
* @access public
*/
public function update_data()
{
return [
['config.add', ['aps_link_locations', 32]],
['config.add', ['aps_ignore_criteria', 0]],
['config.add', ['aps_ignore_min_chars', 0]],
['config.add', ['aps_ignore_min_words', 0]],
['config.add', ['aps_ignore_excluded_chars', 0]],
['config.add', ['aps_ignore_excluded_words', 0]],
];
}
}