diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ad759dbd0c..a8f16e206e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,6 +74,18 @@ Deprecations rule of thumb: * Squash when merging. This makes backporting easier. If you think your changes deserve multiple commits, consider splitting them into multiple pull requests. * Mark the pull request with the appropriate milestone. [@Derkades](https://github.com/Derkades) keeps an eye on merged PRs and cherry-pick changes to the appropriate release branch. +## Adding new modules to core + +After adding a new module to core, you need to do the following: +1. Update the `Dockerfile.phpdoc` file to include the new module classes folder (this generates our [PHPDoc](https://phpdoc.namelessmc.com/) site) +2. Update `composer.json` to autoload the new module classes folder +3. Add a new term to the `custom/languages/en_UK.json` file for the module description to be shown during instal + - The term should be in the format `module_{module_name}_description` + - Don't forget to add it to the `WHITELISTED_TERMS` array in `dev/scripts/find_unused_language_terms.sh` +4. Create new database entry to install it by default + - Update `core/installation/includes/upgrade_perform.php` around line 637 + - Add a new entry in `core/classes/Database/DatabaseInitialiser.php` around line 83 + ## Releasing a new version 1. Ensure you have a clean copy of the source code without leftover files from testing. For example, clone the Nameless repository into a new directory diff --git a/Dockerfile.phpdoc b/Dockerfile.phpdoc index 46f9f27aa9..9b7049f92e 100644 --- a/Dockerfile.phpdoc +++ b/Dockerfile.phpdoc @@ -7,7 +7,7 @@ RUN mkdir /target && \ -d /source/modules/Core/classes \ -d "/source/modules/Discord Integration/classes" \ -d "/source/modules/Cookie Consent/classes" \ - -d /source/modules/Forum/classes + -d /source/modules/Forum/classes \ -d /source/modules/Members/classes -t /target -i /vendor FROM nginxinc/nginx-unprivileged:stable diff --git a/core/installation/installer.php b/core/installation/installer.php index d392c1ba9e..415d279961 100644 --- a/core/installation/installer.php +++ b/core/installation/installer.php @@ -16,7 +16,6 @@ if (!file_exists(__DIR__ . '/steps/' . $step . '.php')) { $error = 'Unknown step.'; } - } if (isset($step) && $step == 'ajax_initialise') { @@ -39,6 +38,7 @@ create_step($language->get('installer', 'step_database_config'), 'server icon', ['database_configuration', 'database_initialization', 'upgrade', 'upgrade_perform']); create_step($language->get('installer', 'step_site_config'), 'globe icon', ['site_configuration', 'site_initialization']); create_step($language->get('installer', 'step_admin_account'), 'user icon', ['admin_account_setup']); + create_step($language->get('installer', 'step_select_modules'), 'puzzle piece icon', ['select_modules']); create_step($language->get('installer', 'step_conversion'), 'exchange icon', ['conversion']); create_step($language->get('installer', 'step_finish'), 'check icon', ['finish']); ?> diff --git a/core/installation/steps/admin_account_setup.php b/core/installation/steps/admin_account_setup.php index 3c1b6f8fe6..6ab46553b7 100644 --- a/core/installation/steps/admin_account_setup.php +++ b/core/installation/steps/admin_account_setup.php @@ -1,6 +1,6 @@ addGroup(2); - Redirect::to('?step=conversion'); + Redirect::to('?step=select_modules'); } DB::getInstance()->delete('users', ['id', 1]); diff --git a/core/installation/steps/conversion.php b/core/installation/steps/conversion.php index f9d42fed64..bd7315ae9c 100644 --- a/core/installation/steps/conversion.php +++ b/core/installation/steps/conversion.php @@ -1,6 +1,6 @@ diff --git a/core/installation/steps/finish.php b/core/installation/steps/finish.php index edede002ae..af6bed9a27 100644 --- a/core/installation/steps/finish.php +++ b/core/installation/steps/finish.php @@ -1,13 +1,13 @@ get('installer', 'module_' . strtolower(str_replace(' ', '-', $module)) . '_description'); + } +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $cache = new Cache(['name' => 'nameless', 'extension' => '.cache', 'path' => ROOT_PATH . '/cache/']); + $cache->setCache('modulescache'); + $enabled_modules = array_filter($cache->retrieve('enabled_modules'), static function ($module) { + return Input::get('modules')[$module['name']] === '1' || $module['name'] === 'Core'; + }); + $cache->store('enabled_modules', $enabled_modules); + + foreach (Input::get('modules') as $module => $value) { + if ($module === 'Core') { + continue; + } + + DB::getInstance()->update('modules', ['name', $module], [ + 'enabled' => $value === '1', + ]); + } + + $_SESSION['modules_selected'] = true; + Redirect::to('?step=conversion'); +} +?> + +
+
+
+

+ get('installer', 'select_modules'); ?> +

+
+
+

get('installer', 'select_modules_details'); ?>

+ +
+ $description) { ?> +
+ +
+
+ + + + + + +
+
+ +
+
+
+ +
+
+
+ +
+
+
+ + diff --git a/custom/languages/en_UK.json b/custom/languages/en_UK.json index 3391904701..cc75b3c002 100644 --- a/custom/languages/en_UK.json +++ b/custom/languages/en_UK.json @@ -914,6 +914,11 @@ "installer/installer_upgrading_database": "Please wait whilst the installer upgrades your database...", "installer/installer_welcome": "Welcome to NamelessMC version 2.0", "installer/language": "Language", + "installer/module_core_description": "This module is required for NamelessMC to function correctly.", + "installer/module_cookie-consent_description": "Allows users to accept the use of cookies on your website.", + "installer/module_forum_description": "Adds a forum to your website.", + "installer/module_discord-integration_description": "Allows users to link their Discord account to their website account and perform various synchronisation actions.", + "installer/module_members_description": "Adds a detailed members page and statistics to your website.", "installer/new_installation": "New installation »", "installer/new_installation_question": "Firstly, is this a new installation?", "installer/no": "No", @@ -927,6 +932,8 @@ "installer/reload_page": "Reload page", "installer/requirements": "Requirements:", "installer/requirements_error": "You must have all of the required extensions installed, and have correct permissions set, in order to proceed with installation.", + "installer/select_modules": "Select Modules", + "installer/select_modules_details": "Select the modules you would like to enable on your site. These can be toggled later on through the admin panel.", "installer/session_doesnt_exist": "Unable to detect session. Sessions saving are a requirement to use Nameless. Please try again after clearing cookies in your web browser, and if the issue persists, please contact your web host for support.", "installer/site_name": "Site Name", "installer/step_admin_account": "Admin Account", @@ -936,6 +943,7 @@ "installer/step_general_config": "General Configuration", "installer/step_home": "Home", "installer/step_requirements": "Requirements", + "installer/step_select_modules": "Select Modules", "installer/step_site_config": "Site Configuration", "installer/support_message": "If you need any support, check out our website: {{websiteLinkStart}}here{{websiteLinkEnd}}; you can also visit our Discord server: {{discordLinkStart}}Discord server{{discordLinkEnd}}, or our GitHub repository: {{githubLinkStart}}here{{githubLinkEnd}}", "installer/terms_and_conditions": "By continuing you agree to the terms and conditions.", diff --git a/dev/scripts/find_unused_language_terms.sh b/dev/scripts/find_unused_language_terms.sh index 7d054abe98..3f87f71d7c 100644 --- a/dev/scripts/find_unused_language_terms.sh +++ b/dev/scripts/find_unused_language_terms.sh @@ -13,6 +13,14 @@ FILES=( "modules/Discord Integration/language/en_UK.json" "modules/Members/language/en_UK.json" ) +# terms which are too tricky to detect, or are used in a different way +WHITELISTED_TERMS=( + "installer/module_cookie-consent_description" + "installer/module_discord-integration_description" + "installer/module_forum_description" + "installer/module_core_description" + "installer/module_members_description" +) for FILE in "${FILES[@]}" do @@ -20,6 +28,11 @@ do KEYS=$(jq -M -r 'keys | .[]' "$FILE") for KEY in $KEYS do + # check if the term is whitelisted + if [[ " ${WHITELISTED_TERMS[*]} " =~ ${KEY} ]]; then + continue + fi + BEFORE_SLASH="${KEY%%/*}" AFTER_SLASH="${KEY#*/}" diff --git a/modules/Cookie Consent/classes/CookieConsent.php b/modules/Cookie Consent/classes/CookieConsent.php index 1253441757..7c804a5f34 100644 --- a/modules/Cookie Consent/classes/CookieConsent.php +++ b/modules/Cookie Consent/classes/CookieConsent.php @@ -2,7 +2,7 @@ /** * CookieConsent module main class * - * @package Modules\Cookie Consent + * @package Modules\CookieConsent * @author Samerton * @version 2.0.0-pr13 * @license MIT diff --git a/modules/Cookie Consent/classes/CookieConsent_Sitemap.php b/modules/Cookie Consent/classes/CookieConsent_Sitemap.php index c0d0f850df..3f786c86d5 100644 --- a/modules/Cookie Consent/classes/CookieConsent_Sitemap.php +++ b/modules/Cookie Consent/classes/CookieConsent_Sitemap.php @@ -5,7 +5,7 @@ /** * CookieConsent sitemap class * - * @package Modules\Cookie Consent + * @package Modules\CookieConsent * @author Samerton * @version 2.0.0-pr13 * @license MIT diff --git a/modules/Discord Integration/classes/Discord.php b/modules/Discord Integration/classes/Discord.php index 0a27924477..e192e88bc3 100644 --- a/modules/Discord Integration/classes/Discord.php +++ b/modules/Discord Integration/classes/Discord.php @@ -2,7 +2,7 @@ /** * Discord utility class * - * @package Modules\Discord Integration + * @package Modules\DiscordIntegration * @author Aberdeener * @version 2.0.0-pr13 * @license MIT diff --git a/modules/Discord Integration/classes/DiscordApiErrors.php b/modules/Discord Integration/classes/DiscordApiErrors.php index c6a965850c..436f711784 100644 --- a/modules/Discord Integration/classes/DiscordApiErrors.php +++ b/modules/Discord Integration/classes/DiscordApiErrors.php @@ -3,7 +3,7 @@ * Contains namespaced API error messages for the Discord Integration module. * These have no versioning, and are not meant to be used by any other modules. * - * @package Modules\Discord Integration + * @package Modules\DiscordIntegration * @author Aberdeener * @version 2.0.0-pr13 * @license MIT diff --git a/modules/Discord Integration/classes/DiscordGroupSyncInjector.php b/modules/Discord Integration/classes/DiscordGroupSyncInjector.php index 0d456a222e..8ae3ffaf6c 100644 --- a/modules/Discord Integration/classes/DiscordGroupSyncInjector.php +++ b/modules/Discord Integration/classes/DiscordGroupSyncInjector.php @@ -2,7 +2,7 @@ /** * Discord group sync injector implementation. * - * @package Modules\Discord Integration + * @package Modules\DiscordIntegration * @author Aberdeener * @version 2.0.3 * @license MIT diff --git a/modules/Members/classes/MemberListProvider.php b/modules/Members/classes/MemberListProvider.php index cd6fb7aadb..d6b9e62967 100644 --- a/modules/Members/classes/MemberListProvider.php +++ b/modules/Members/classes/MemberListProvider.php @@ -3,7 +3,7 @@ /** * Base class for member list providers. * - * @package Modules\Forum + * @package Modules\Members * @author Aberdener * @version 2.1.0 * @license MIT