diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index c5b44fc..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,14 +0,0 @@ -# These are supported funding model platforms - -github: rmcgirr83 -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -polar: # Replace with a single Polar username -buy_me_a_coffee: rmcgirr83 -custom: https://www.paypal.com/paypalme/rmcgirr83 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..ef48cd3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,38 @@ +name: Lint + +# PHP syntax check on the lowest PHP version this extension supports and the +# newest one phpBB 3.3 supports. tests.yml covers PHP 8.2 with phpBB's own +# checks (code sniffer, EPV). +on: + push: + branches: + - master + pull_request: + branches: + - master + +permissions: + contents: read + +jobs: + lint: + name: PHP ${{ matrix.php }} lint + runs-on: ubuntu-latest + strategy: + matrix: + php: ['7.4', '8.4'] + steps: + - uses: actions/checkout@v4 + + - name: Set up PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: composer:v2 + + - name: PHP syntax check + run: find . -name '*.php' -not -path './.git/*' -not -path './vendor/*' -print0 | xargs -0 -n1 php -l + + - name: Validate composer.json + run: composer validate --no-check-all --no-check-publish diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4ef4b05..897f464 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,7 @@ name: Tests env: - EXTNAME: rmcgirr83/contactadmin # Your extension vendor/package name + EXTNAME: phpbbmodders/contactadmin # Your extension vendor/package name SNIFF: 1 # Run code sniffer on your code? 1 or 0 IMAGE_ICC: 1 # Run icc profile sniffer on your images? 1 or 0 EPV: 1 # Run EPV (Extension Pre Validator) on your code? 1 or 0 diff --git a/README.MD b/README.MD deleted file mode 100644 index 5bdb0b1..0000000 --- a/README.MD +++ /dev/null @@ -1,26 +0,0 @@ -# ![Contact Admin](https://imattpro.github.io/logo/search.png "Contact Admin") Contact Admin for phpBB3 - -phpBB extension that allows guests and/or registered users to either send an email to admins or to either send a PM or make a Post in a designated forum. It also overrides the default contact admin link found on the forum. A port of the phpBB 3.0.x mod “Contact Board Administration” - -[![Build Status](https://github.com/rmcgirr83/contactadmin/workflows/Tests/badge.svg)](https://github.com/rmcgirr83/contactadmin/actions) - -## Installation - -### 1. clone -Clone (or download and move) the repository into the folder ext/rmcgirr83/contactadmin: - -``` -cd phpBB3 -git clone https://github.com/rmcgirr83/contactadmin.git ext/rmcgirr83/contactadmin/ -``` - -### 2. activate -Go to admin panel -> tab customise -> Manage extensions -> enable Contact Admin - -Within the Admin panel visit the Extensions tab and choose the settings for the extension. - -## Update instructions: -1. Go to you phpBB-Board > Admin Control Panel > Customise > Manage extensions > Contact Admin: disable -2. Delete all files of the extension from ext/rmcgirr83/contactadmin -3. Upload all the new files to the same locations -4. Go to you phpBB-Board > Admin Control Panel > Customise > Manage extensions > Contact Admin: enable diff --git a/README.md b/README.md new file mode 100644 index 0000000..2ee78c6 --- /dev/null +++ b/README.md @@ -0,0 +1,59 @@ +# Contact Admin + +[![Tests](https://github.com/phpbbmodders/contactadmin/actions/workflows/tests.yml/badge.svg)](https://github.com/phpbbmodders/contactadmin/actions/workflows/tests.yml) [![Lint](https://github.com/phpbbmodders/contactadmin/actions/workflows/lint.yml/badge.svg)](https://github.com/phpbbmodders/contactadmin/actions/workflows/lint.yml) + +A contact form that lets guests and members reach the board administrators by email, private message or forum post. + +## Features + +- Replaces phpBB's built-in contact page and links to it from the header, the footer, failed logins and the registration page. +- Messages go out by email, as a private message, or as a post in a forum you choose. Send to all administrators, the board founder or the board's default email address. +- Optional list of contact reasons for the sender to pick from. +- Private messages and posts can come from a "contact bot" user, for guests only or for everyone. +- Optional CAPTCHA (for everyone or guests only, with an attempt limit), attachments, a privacy-policy checkbox, and checks that stop guests from using a registered member's username or email address. +- Settings under **ACP → Extensions → Contact Admin**. +- Works with [Stop Forum Spam](https://github.com/phpbbmodders/stopforumspam), which can check messages sent through the form. + +## Requirements + +- phpBB 3.3.19 or later +- PHP 7.4 or later + +## Installation + +1. Copy the extension to `/ext/phpbbmodders/contactadmin` +2. In the Administration Control Panel, go to **Customise → Manage extensions** +3. Enable the **Contact Admin** extension +4. Choose the settings under **ACP → Extensions → Contact Admin** + +### Upgrading from `rmcgirr83/contactadmin` + +This extension used to be installed as `rmcgirr83/contactadmin`. Your settings carry over: + +1. Disable the old **Contact Admin** extension in the ACP. Do **not** delete its data. +2. Upload this version to `/ext/phpbbmodders/contactadmin` and enable it. The old install's migration history and ACP module are moved to the new name automatically. +3. Delete the `/ext/rmcgirr83/contactadmin` folder and purge the board cache. + +If you use [Stop Forum Spam](https://github.com/phpbbmodders/stopforumspam), update it as well so it keeps checking the contact form. + +If you disable the old extension from the command line (`bin/phpbbcli.php`) instead of the ACP, run `bin/phpbbcli.php cache:purge` before enabling the new one; the command-line disable doesn't clear the cache. + +## Contributing + +Contributions are welcome! + +- **Bug reports**: [Open an issue](https://github.com/phpbbmodders/contactadmin/issues). +- **Everything else** (questions, feature requests, ideas, general discussion): [Use Discussions](https://github.com/orgs/phpbbmodders/discussions), or the [community forum](https://www.phpbbmodders.com/community/). +- Pull requests are welcome for bug fixes or discussed features. + +## Acknowledgments + +- A port of the phpBB 3.0 **Contact Board Administration** MOD. +- Extension by Rich McGirr ([RMcGirr83](https://github.com/rmcgirr83)). +- Code review, bug fixes, and documentation assisted by [Claude](https://www.anthropic.com/claude). + +## License + +This extension is licensed under the **GNU General Public License v2.0**. + +See [license.txt](license.txt) for more information. diff --git a/acp/contactadmin_info.php b/acp/contactadmin_info.php index 926a4a4..ea39166 100644 --- a/acp/contactadmin_info.php +++ b/acp/contactadmin_info.php @@ -1,24 +1,25 @@ '\rmcgirr83\contactadmin\acp\contactadmin_module', + 'filename' => '\phpbbmodders\contactadmin\acp\contactadmin_module', 'title' => 'ACP_CAT_CONTACTADMIN', 'version' => '1.0.0', 'modes' => [ - 'configuration' => ['title' => 'ACP_CONTACTADMIN_CONFIG', 'auth' => 'ext_rmcgirr83/contactadmin && acl_a_board', 'cat' => ['ACP_CAT_CONTACTADMIN']], + 'configuration' => ['title' => 'ACP_CONTACTADMIN_CONFIG', 'auth' => 'ext_phpbbmodders/contactadmin && acl_a_board', 'cat' => ['ACP_CAT_CONTACTADMIN']], ], ]; } diff --git a/acp/contactadmin_module.php b/acp/contactadmin_module.php index bc46c63..b6e4180 100644 --- a/acp/contactadmin_module.php +++ b/acp/contactadmin_module.php @@ -1,14 +1,15 @@ page_title = $phpbb_container->get('language')->lang('ACP_CAT_CONTACTADMIN'); // Get an instance of the admin controller - $admin_controller = $phpbb_container->get('rmcgirr83.contactadmin.admin.controller'); + $admin_controller = $phpbb_container->get('phpbbmodders.contactadmin.admin.controller'); // Make the $u_action url available in the admin controller $admin_controller->set_page_url($this->u_action); diff --git a/adm/style/acp_contactadmin.html b/adm/style/acp_contactadmin.html index a64b837..15947e2 100644 --- a/adm/style/acp_contactadmin.html +++ b/adm/style/acp_contactadmin.html @@ -7,13 +7,6 @@ var imageTag = false;

{{ lang('ACP_CAT_CONTACTADMIN') }}

-
- {{ lang('BUY_ME_A_BEER') }} -
-

{{ lang('BUY_ME_A_BEER_EXPLAIN') }}
-
{{ lang('PAYPAL_ALT') }}
-
-
{% if CONTACT_ERROR %}

{{ lang('WARNING') }}

{{ CONTACT_ERROR }}

diff --git a/composer.json b/composer.json index 3343157..489aa52 100644 --- a/composer.json +++ b/composer.json @@ -1,25 +1,32 @@ { - "name": "rmcgirr83/contactadmin", + "name": "phpbbmodders/contactadmin", "type": "phpbb-extension", - "description": "This form allows guests and/or registered users to either send an email to admins or to either send a PM or make a Post in a designated forum. It also overrides the default contact admin link found on the forum. A port of the phpBB 3.0.x mod “Contact Board Adminnistration”", - "homepage": "https://github.com/rmcgirr83/contactadmin", + "description": "A contact form that lets guests and members reach the board administrators by email, private message or forum post.", + "homepage": "https://www.phpbbmodders.com/", "version": "1.4.4", "time": "2025-01-15", "keywords": [ "phpbb", "extension", - "contact admin" + "contact admin", + "contact-form" ], "license": "GPL-2.0-only", "authors": [ + { + "name": "phpBB Modders", + "email": "board@phpbbmodders.com", + "homepage": "https://www.phpbbmodders.com/", + "role": "Extension Developer" + }, { "name": "Rich McGirr", - "role": "Developer" + "role": "Past Developer" } ], "require": { "php": ">=7.4", - "phpbb/phpbb": ">=3.3", + "phpbb/phpbb": ">=3.3.19", "composer/installers": "^1.0 || ^2.0" }, "require-dev": { @@ -28,7 +35,7 @@ "extra": { "display-name": "Contact Admin", "soft-require": { - "phpbb/phpbb": ">=3.3" + "phpbb/phpbb": ">=3.3.19,<4.0.0@dev" }, "version-check": { "host": "www.phpbb.com", diff --git a/config/routing.yml b/config/routing.yml index 329a329..099876f 100644 --- a/config/routing.yml +++ b/config/routing.yml @@ -1,9 +1,9 @@ -rmcgirr83_contactadmin_displayform: +phpbbmodders_contactadmin_displayform: path: /contactadmin - defaults: { _controller: rmcgirr83.contactadmin.main.controller:displayform } + defaults: { _controller: phpbbmodders.contactadmin.main.controller:displayform } -rmcgirr83_contactadmin_botuserinfo: +phpbbmodders_contactadmin_botuserinfo: path: /contact_bot_info/{user_id} - defaults: { _controller: rmcgirr83.contactadmin.core:bot_user_info } + defaults: { _controller: phpbbmodders.contactadmin.core:bot_user_info } requirements: user_id: \d+ \ No newline at end of file diff --git a/config/services.yml b/config/services.yml index 3edb049..41fe806 100644 --- a/config/services.yml +++ b/config/services.yml @@ -2,8 +2,8 @@ imports: - {resource: contact_constants.yml} services: - rmcgirr83.contactadmin.admin.controller: - class: rmcgirr83\contactadmin\controller\admin_controller + phpbbmodders.contactadmin.admin.controller: + class: phpbbmodders\contactadmin\controller\admin_controller arguments: - '@auth' - '@config' @@ -15,13 +15,13 @@ services: - '@request' - '@template' - '@user' - - '@rmcgirr83.contactadmin.core' + - '@phpbbmodders.contactadmin.core' - '%core.root_path%' - '%core.php_ext%' - '%contact_constants%' - rmcgirr83.contactadmin.main.controller: - class: rmcgirr83\contactadmin\controller\main_controller + phpbbmodders.contactadmin.main.controller: + class: phpbbmodders\contactadmin\controller\main_controller arguments: - '@auth' - '@config' @@ -34,14 +34,14 @@ services: - '@request' - '@template' - '@user' - - '@rmcgirr83.contactadmin.core' + - '@phpbbmodders.contactadmin.core' - '@captcha.factory' - '%core.root_path%' - '%core.php_ext%' - '%contact_constants%' - rmcgirr83.contactadmin.listener: - class: rmcgirr83\contactadmin\event\listener + phpbbmodders.contactadmin.listener: + class: phpbbmodders\contactadmin\event\listener arguments: - '@config' - '@controller.helper' @@ -51,8 +51,8 @@ services: tags: - { name: event.listener } - rmcgirr83.contactadmin.core: - class: rmcgirr83\contactadmin\core\contactadmin + phpbbmodders.contactadmin.core: + class: phpbbmodders\contactadmin\core\contactadmin arguments: - '@auth' - '@cache' diff --git a/controller/admin_controller.php b/controller/admin_controller.php index d01ca3d..c5136b9 100644 --- a/controller/admin_controller.php +++ b/controller/admin_controller.php @@ -1,14 +1,15 @@ language->add_lang(['acp/board', 'posting']); - $this->language->add_lang('acp_contact', 'rmcgirr83/contactadmin'); + $this->language->add_lang('acp_contact', 'phpbbmodders/contactadmin'); // Create a form key for preventing CSRF attacks add_form_key('contactadmin_settings'); @@ -295,7 +296,7 @@ public function display_options() 'S_BBCODE_FLASH' => true, 'S_LINKS_ALLOWED' => true, - 'AJAX_BOT_USER_INFO' => $this->helper->route('rmcgirr83_contactadmin_botuserinfo', ['user_id' => (int) $this->config['contactadmin_bot_user']]), + 'AJAX_BOT_USER_INFO' => $this->helper->route('phpbbmodders_contactadmin_botuserinfo', ['user_id' => (int) $this->config['contactadmin_bot_user']]), 'U_ACTION' => $this->u_action, ]); diff --git a/controller/main_controller.php b/controller/main_controller.php index 3ea0ed8..097039f 100644 --- a/controller/main_controller.php +++ b/controller/main_controller.php @@ -1,13 +1,14 @@ language->add_lang(['ucp', 'posting']); - $this->language->add_lang('contact', 'rmcgirr83/contactadmin'); + $this->language->add_lang('contact', 'phpbbmodders/contactadmin'); // move this from the constructor so the query isn't run on every page $contact_reasons = $this->db_text->get_array(['contactadmin_reasons']); @@ -390,13 +391,13 @@ public function displayform() /** * Modify data and error strings * - * @event rmcgirr83.contactadmin.modify_data_and_error + * @event phpbbmodders.contactadmin.modify_data_and_error * @var array error Error strings * @var array data An array with data * @since 1.0.0 */ $vars = ['error', 'data']; - extract($this->dispatcher->trigger_event('rmcgirr83.contactadmin.modify_data_and_error', compact($vars))); + extract($this->dispatcher->trigger_event('phpbbmodders.contactadmin.modify_data_and_error', compact($vars))); // no errors, let's proceed if (!sizeof($error)) @@ -518,7 +519,7 @@ public function displayform() // build an array of all lang directories for the extension and check to make sure we have the lang available that is being chosen // if the lang isn't present then errors will present themselves due to no email template found - $dir_array = $this->contactadmin->dir_to_array($this->root_path .'ext/rmcgirr83/contactadmin/language'); + $dir_array = $this->contactadmin->dir_to_array($this->root_path .'ext/phpbbmodders/contactadmin/language'); $size = count($contact_users); // Loop through our list of users @@ -550,7 +551,7 @@ public function displayform() // now check if the email template may exist. Can't be helped if there is a lang dir and no email dir // use en if not exist $contact_users[$i]['user_lang'] = (in_array($contact_users[$i]['user_lang'], $dir_array)) ? $contact_users[$i]['user_lang'] : 'en'; - $messenger->template('@rmcgirr83_contactadmin/contact', $contact_users[$i]['user_lang']); + $messenger->template('@phpbbmodders_contactadmin/contact', $contact_users[$i]['user_lang']); $messenger->to($contact_users[$i]['user_email'], $contact_users[$i]['username']); $messenger->im($contact_users[$i]['user_jabber'], $contact_users[$i]['username']); @@ -674,7 +675,7 @@ public function displayform() 'S_CONTACT_ADMIN' => true, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ERROR' => (isset($error) && count($error)) ? implode('
', $error) : '', - 'S_CONTACT_ACTION' => $this->helper->route('rmcgirr83_contactadmin_displayform'), + 'S_CONTACT_ACTION' => $this->helper->route('phpbbmodders_contactadmin_displayform'), 'S_CONTACT_GDPR' => ($this->config['contactadmin_gdpr'] && empty($this->user->data['is_registered'])) ? true : false, ]); diff --git a/core/contactadmin.php b/core/contactadmin.php index a9db1f4..56372cf 100644 --- a/core/contactadmin.php +++ b/core/contactadmin.php @@ -1,13 +1,14 @@ language->lang('CONTACT_BOT_MESSAGE', $this->user->data['username'], $this->config['sitename'], $this->language->lang('FORUM'), $server_url); $this->contact_send_email($email_template, $email_message); @@ -218,7 +219,7 @@ public function contact_check($mode, $forum_id = false, $bot_id = false, $method if (!$row && $this->config['email_enable']) { // send an email to the board default - $email_template = '@rmcgirr83_contactadmin/contact_error'; + $email_template = '@phpbbmodders_contactadmin/contact_error'; $email_message = $this->language->lang('CONTACT_BOT_MESSAGE', $this->user->data['username'], $this->config['sitename'], $this->language->lang('USER'), $server_url); $this->contact_send_email($email_template, $email_message); @@ -259,7 +260,7 @@ public function contact_check($mode, $forum_id = false, $bot_id = false, $method if ($this->config['email_enable']) { // send an email to the board default - $email_template = '@rmcgirr83_contactadmin/contact_error'; + $email_template = '@phpbbmodders_contactadmin/contact_error'; $email_message = $this->language->lang('CONTACT_NONE', $this->user->data['username'], $this->config['sitename'], $error, $server_url); $this->contact_send_email($email_template, $email_message); @@ -295,7 +296,7 @@ public function contact_check($mode, $forum_id = false, $bot_id = false, $method */ private function contact_send_email($email_template, $email_message) { - $dir_array = $this->dir_to_array($this->root_path .'ext/rmcgirr83/contactadmin/language'); + $dir_array = $this->dir_to_array($this->root_path .'ext/phpbbmodders/contactadmin/language'); $lang = (in_array($this->config['default_lang'], $dir_array)) ? $this->config['default_lang'] : 'en'; diff --git a/event/listener.php b/event/listener.php index 570468c..cbf0214 100644 --- a/event/listener.php +++ b/event/listener.php @@ -1,13 +1,14 @@ config->set('contact_admin_form_enable', true); } @@ -110,7 +111,7 @@ public function enable_default_contact($event) */ public function extension_enabled($event) { - $this->language->add_lang('acp_contact', 'rmcgirr83/contactadmin'); + $this->language->add_lang('acp_contact', 'phpbbmodders/contactadmin'); $this->template->assign_vars([ 'L_CONTACT_US_ENABLE_EXPLAIN' => $this->language->lang('CONTACT_EXTENSION_ACTIVE'), ]); @@ -154,7 +155,7 @@ public function page_header_after($event) $this->template->assign_vars([ 'U_CONTACT_US' => false, - 'U_CONTACTADMIN' => $this->helper->route('rmcgirr83_contactadmin_displayform'), + 'U_CONTACTADMIN' => $this->helper->route('phpbbmodders_contactadmin_displayform'), 'S_FORUM_VERSION' => $version, ]); } @@ -173,7 +174,7 @@ public function login_box_failed($event) $result = $event['result']; if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') { - $error = $this->language->lang($result['error_msg'], '', ''); + $error = $this->language->lang($result['error_msg'], '', ''); } $event['err'] = $error; } @@ -188,7 +189,7 @@ public function login_box_failed($event) public function contact_form_register($event) { $this->template->assign_vars([ - 'L_CONFIRM_EXPLAIN' => $this->language->lang('CONFIRM_EXPLAIN', '', ''), + 'L_CONFIRM_EXPLAIN' => $this->language->lang('CONFIRM_EXPLAIN', '', ''), ]); } } diff --git a/ext.php b/ext.php index de4efb3..0c2564d 100644 --- a/ext.php +++ b/ext.php @@ -1,30 +1,192 @@ container->get('config'); + if (!$this->check_phpbb_version() || !$this->check_php_version()) + { + $language = $this->container->get('language'); + $language->add_lang('install_contactadmin', 'phpbbmodders/contactadmin'); + + return $language->lang('CONTACTADMIN_NOT_ENABLEABLE'); + } + + if ($this->container->get('ext.manager')->is_enabled(self::OLD_EXT_NAME)) + { + return ['Disable the old "' . self::OLD_EXT_NAME . '" extension first (keep its data, do not delete it).']; + } + + return true; + } + + /** + * Require phpBB 3.3.19 + * + * @return bool + */ + public function check_phpbb_version() + { + return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>='); + } + + /** + * Require PHP 7.4 + * + * @return bool + */ + public function check_php_version() + { + return PHP_VERSION_ID >= 70400; + } + + /** + * Move an old install's data to the new name, then enable as usual. + * + * @param mixed $old_state State returned by previous call of this method + * @return bool|string + */ + public function enable_step($old_state) + { + if ($old_state === false) + { + $this->move_old_install(); + + // The migrator loaded its state before this ran; reload it so the + // moved migration history counts as already installed. + $this->migrator->load_migration_state(); + } + + return parent::enable_step($old_state); + } + + /** + * Rewrite everything the database stores under the old name. + * + * Rows are filtered in PHP rather than with LIKE, because namespace + * backslashes and underscores are special characters in LIKE patterns + * on some databases. The tables involved are small. + */ + protected function move_old_install() + { + $db = $this->container->get('dbal.conn'); + $prefix = $this->container->getParameter('core.table_prefix'); + + $db->sql_transaction('begin'); + + // Migration history, including each migration's dependency list + $result = $db->sql_query('SELECT migration_name, migration_depends_on FROM ' . $prefix . 'migrations'); + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + foreach ($rows as $row) + { + // Other extensions' migrations may depend on ours, so their + // dependency lists are rewritten too, not just our own rows + $old_depends_on = unserialize($row['migration_depends_on'], ['allowed_classes' => false]); + $old_depends_on = is_array($old_depends_on) ? $old_depends_on : []; + $depends_on = array_map([$this, 'new_class_name'], $old_depends_on); + $name = $this->new_class_name($row['migration_name']); + + if ($name === $row['migration_name'] && $depends_on === $old_depends_on) + { + continue; + } + + $db->sql_query('UPDATE ' . $prefix . 'migrations SET ' . $db->sql_build_array('UPDATE', [ + 'migration_name' => $name, + 'migration_depends_on' => serialize($depends_on), + ]) . " WHERE migration_name = '" . $db->sql_escape($row['migration_name']) . "'"); + } + + // Module classes and their "ext_vendor/name" auth checks + $result = $db->sql_query('SELECT module_id, module_basename, module_auth FROM ' . $prefix . 'modules'); + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + foreach ($rows as $row) + { + $basename = $this->new_class_name($row['module_basename']); + $auth = str_replace('ext_' . self::OLD_EXT_NAME, 'ext_' . self::NEW_EXT_NAME, $row['module_auth']); + + if ($basename !== $row['module_basename'] || $auth !== $row['module_auth']) + { + $db->sql_query('UPDATE ' . $prefix . 'modules SET ' . $db->sql_build_array('UPDATE', [ + 'module_basename' => $basename, + 'module_auth' => $auth, + ]) . ' WHERE module_id = ' . (int) $row['module_id']); + } + } + + // The old extension's own record (only once it's disabled) + $db->sql_query('DELETE FROM ' . $prefix . "ext + WHERE ext_name = '" . $db->sql_escape(self::OLD_EXT_NAME) . "' + AND ext_active = 0"); + + $db->sql_transaction('commit'); + } + + /** + * Map an old fully qualified class name to the new namespace. + * + * @param string $class_name Class name, possibly under the old namespace + * @return string + */ + protected function new_class_name($class_name) + { + if (!is_string($class_name)) + { + return $class_name; + } + + // Class names may be stored with or without the leading backslash + foreach ([self::OLD_NAMESPACE, ltrim(self::OLD_NAMESPACE, '\\')] as $old) + { + if (strpos($class_name, $old) === 0) + { + $new = ($old === self::OLD_NAMESPACE) ? self::NEW_NAMESPACE : ltrim(self::NEW_NAMESPACE, '\\'); + return $new . substr($class_name, strlen($old)); + } + } - return phpbb_version_compare($config['version'], '3.3', '>='); + return $class_name; } } diff --git a/language/en/acp/info_acp_contact.php b/language/en/acp/info_acp_contact.php index 8ad2dc3..e59f41e 100644 --- a/language/en/acp/info_acp_contact.php +++ b/language/en/acp/info_acp_contact.php @@ -1,12 +1,13 @@ 'The Contact Admin extension is allowing emails but the forum is not setup to allow emails. The extension has been disabled.', 'LOG_CONTACT_NONE' => 'No Administrators are allowing users to contact them via %1$s in the Contact Admin extension', 'LOG_CONTACT_CONFIG_UPDATE' => 'Updated Contact Admin config settings', - //Donation - 'PAYPAL_IMAGE_URL' => 'https://www.paypalobjects.com/webstatic/en_US/i/btn/png/silver-pill-paypal-26px.png', - 'PAYPAL_ALT' => 'Donate using PayPal', - 'BUY_ME_A_BEER_URL' => 'https://paypal.me/RMcGirr83', - 'BUY_ME_A_BEER' => 'Buy me a beer for creating this extension', - 'BUY_ME_A_BEER_SHORT' => 'Make a donation for this extension', - 'BUY_ME_A_BEER_EXPLAIN' => 'This extension is completely free. It is a project that I spend my time on for the enjoyment and use of the phpBB community. If you enjoy using this extension, or if it has benefited your forum, please consider buying me a beer. It would be greatly appreciated. ', ]); diff --git a/language/en/acp_contact.php b/language/en/acp_contact.php index 5ffb8d7..060f30a 100644 --- a/language/en/acp_contact.php +++ b/language/en/acp_contact.php @@ -1,12 +1,13 @@ 'Contact Admin could not be enabled. The minimum requirements of phpBB 3.3.19 and/or PHP 7.4.0 were not satisfied.', +]); diff --git a/migrations/m1_update_data.php b/migrations/m1_update_data.php index 23db2de..3f20633 100644 --- a/migrations/m1_update_data.php +++ b/migrations/m1_update_data.php @@ -1,14 +1,15 @@ '\rmcgirr83\contactadmin\acp\contactadmin_module', + 'module_basename' => '\phpbbmodders\contactadmin\acp\contactadmin_module', 'modes' => array('configuration'), ), )),