From 72c79e005aea22e24591a7a82cda1afacacb319e Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 10 Feb 2020 23:07:23 +0100 Subject: [PATCH] Add some new hooks for the account/create page Also moved some account-create text to plugins --- .gitignore | 2 + plugins/account-create-hint.json | 17 ++++++++ plugins/account-create-hint/hint.html.twig | 3 ++ plugins/account-create-hint/hint.php | 15 +++++++ system/hooks.php | 21 ++++++++- system/pages/createaccount.php | 20 ++++++++- system/templates/account.create.html.twig | 51 +++++++++++++++++++--- 7 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 plugins/account-create-hint.json create mode 100644 plugins/account-create-hint/hint.html.twig create mode 100644 plugins/account-create-hint/hint.php diff --git a/.gitignore b/.gitignore index 63e362db..c2acb088 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,6 @@ system/logs/* plugins/* !plugins/.htaccess !plugins/example.json +!plugins/account-create-hint.json +!plugins/account-create-hint landing diff --git a/plugins/account-create-hint.json b/plugins/account-create-hint.json new file mode 100644 index 00000000..87734108 --- /dev/null +++ b/plugins/account-create-hint.json @@ -0,0 +1,17 @@ +{ + "name": "create-account-hint", + "description": "This plugin display text 'To play on Forgotten you need an account. All you have to do to create your new account is to enter an account name, password, country and your email address. Also you have to agree to the terms presented below. If you have done so, your account name will be shown on the following page and your account password will be sent to your email address along with further instructions. If you do not receive the email with your password, please check your spam filter.' on the create account page. Be careful when uninstalling this!", + "version": "1.0", + "author": "slawkens", + "contact": "slawkens@gmail.com", + "hooks": { + "create-account-hint": { + "type": "ACCOUNT_CREATE_BEFORE_FORM", + "file": "plugins/account-create-hint/hint.php" + } + }, + "uninstall": [ + "plugins/account-create-hint.json", + "plugins/account-create-hint" + ] +} diff --git a/plugins/account-create-hint/hint.html.twig b/plugins/account-create-hint/hint.html.twig new file mode 100644 index 00000000..d6069d56 --- /dev/null +++ b/plugins/account-create-hint/hint.html.twig @@ -0,0 +1,3 @@ +To play on {{ config.lua.serverName }} you need an account. +All you have to do to create your new account is to enter an account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %}, password{% if config.recaptcha_enabled %}, confirm reCAPTCHA{% endif %}{% if config.account_country %}, country{% endif %} and your email address. +Also you have to agree to the terms presented below. If you have done so, your account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %} will be shown on the following page and your account password will be sent to your email address along with further instructions. If you do not receive the email with your password, please check your spam filter.

diff --git a/plugins/account-create-hint/hint.php b/plugins/account-create-hint/hint.php new file mode 100644 index 00000000..b88af30a --- /dev/null +++ b/plugins/account-create-hint/hint.php @@ -0,0 +1,15 @@ + + * @copyright 2020 MyAAC + * @link https://my-aac.org + */ +defined('MYAAC') or die('Direct access not allowed!'); + +global $twig_loader; +$twig_loader->prependPath(BASE . 'plugins/account-create'); + +$twig->display('hint.html.twig'); diff --git a/system/hooks.php b/system/hooks.php index a937ec79..c84e5e30 100644 --- a/system/hooks.php +++ b/system/hooks.php @@ -24,8 +24,27 @@ define('HOOK_CHARACTERS_AFTER_CHARACTERS', 12); define('HOOK_LOGIN', 13); define('HOOK_LOGIN_ATTEMPT', 14); define('HOOK_LOGOUT', 15); +define('HOOK_ACCOUNT_CREATE_BEFORE_FORM', 16); +define('HOOK_ACCOUNT_CREATE_BEFORE_BOXES', 17); +define('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1', 18); +define('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_2', 19); +define('HOOK_ACCOUNT_CREATE_AFTER_BOXES', 20); +define('HOOK_ACCOUNT_CREATE_BEFORE_ACCOUNT', 21); +define('HOOK_ACCOUNT_CREATE_AFTER_ACCOUNT', 22); +define('HOOK_ACCOUNT_CREATE_AFTER_EMAIL', 23); +define('HOOK_ACCOUNT_CREATE_AFTER_COUNTRY', 24); +define('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS', 25); +define('HOOK_ACCOUNT_CREATE_AFTER_RECAPTCHA', 26); +define('HOOK_ACCOUNT_CREATE_BEFORE_CHARACTER_NAME', 27); +define('HOOK_ACCOUNT_CREATE_AFTER_CHARACTER_NAME', 28); +define('HOOK_ACCOUNT_CREATE_AFTER_SEX', 29); +define('HOOK_ACCOUNT_CREATE_AFTER_VOCATION', 30); +define('HOOK_ACCOUNT_CREATE_AFTER_TOWNS', 31); +define('HOOK_ACCOUNT_CREATE_BEFORE_SUBMIT_BUTTON', 32); +define('HOOK_ACCOUNT_CREATE_AFTER_FORM', 33); +define('HOOK_ACCOUNT_CREATE_AFTER_SUBMIT', 34); define('HOOK_FIRST', HOOK_STARTUP); -define('HOOK_LAST', HOOK_LOGOUT); +define('HOOK_LAST', HOOK_ACCOUNT_CREATE_AFTER_SUBMIT); require_once LIBS . 'plugins.php'; class Hook diff --git a/system/pages/createaccount.php b/system/pages/createaccount.php index a2e8c464..0b94a2cc 100644 --- a/system/pages/createaccount.php +++ b/system/pages/createaccount.php @@ -121,6 +121,24 @@ if($save) if(!isset($_POST['accept_rules']) || $_POST['accept_rules'] !== 'true') $errors['accept_rules'] = 'You have to agree to the ' . $config['lua']['serverName'] . ' Rules in order to create an account!'; + $params = array( + 'account' => $account_db, + 'email' => $email, + 'country' => $country, + 'password' => $password, + 'password2' => $password2, + 'accept_rules' => isset($_POST['accept_rules']) ? $_POST['accept_rules'] === 'true' : false, + ); + + if(USE_ACCOUNT_NAME) { + $params['account_name'] = $_POST['account']; + } + else { + $params['account_id'] = $_POST['account']; + } + + $hooks->trigger(HOOK_ACCOUNT_CREATE_AFTER_SUBMIT, $params); + if(config('account_create_character_create')) { $character_name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : null; $character_sex = isset($_POST['sex']) ? (int)$_POST['sex'] : null; @@ -313,4 +331,4 @@ if($save && config('account_create_character_create')) { )); } -$twig->display('account.create.html.twig', $params); \ No newline at end of file +$twig->display('account.create.html.twig', $params); diff --git a/system/templates/account.create.html.twig b/system/templates/account.create.html.twig index 21f04e8d..b3a889a5 100644 --- a/system/templates/account.create.html.twig +++ b/system/templates/account.create.html.twig @@ -1,6 +1,4 @@ -To play on {{ config.lua.serverName }} you need an account. -All you have to do to create your new account is to enter an account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %}, password{% if config.recaptcha_enabled %}, confirm reCAPTCHA{% endif %}{% if config.account_country %}, country{% endif %} and your email address. -Also you have to agree to the terms presented below. If you have done so, your account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %} will be shown on the following page and your account password will be sent to your email address along with further instructions. If you do not receive the email with your password, please check your spam filter.

+{{ hook('HOOK_ACCOUNT_CREATE_BEFORE_FORM') }}
@@ -21,6 +19,7 @@ Also you have to agree to the terms presented below. If you have done so, your a @@ -273,6 +312,7 @@ Also you have to agree to the terms presented below. If you have done so, your a
+ {{ hook('HOOK_ACCOUNT_CREATE_BEFORE_BOXES') }} + + {{ hook('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1') }} + {% if (not config.mail_enabled or not config.account_mail_verify) and config.account_create_character_create %} {% endif %} + + {{ hook('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_2') }} + + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_BOXES') }} +
@@ -28,6 +27,9 @@ Also you have to agree to the terms presented below. If you have done so, your a
+ + {{ hook('HOOK_ACCOUNT_CREATE_BEFORE_ACCOUNT') }} + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_ACCOUNT') }} - + + + + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_EMAIL') }} + {% if config.account_country %} {% endif %} {% endif %} + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_COUNTRY') }} + + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS') }} + {% if config.recaptcha_enabled %} {% endif %} {% endif %} + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_RECAPTCHA') }}
Account {% if constant('USE_ACCOUNT_NAME') %}Name{% else %}Number{% endif %}: @@ -38,6 +40,7 @@ Also you have to agree to the terms presented below. If you have done so, your a
{% if errors.account is defined %}{{ errors.account }}{% endif %}
Email Address: @@ -47,7 +50,12 @@ Also you have to agree to the terms presented below. If you have done so, your a
{% if errors.email is defined %}{{ errors.email }}{% endif %}
{% if errors.email is defined %}{{ errors.email }}{% endif %}
@@ -66,6 +74,9 @@ Also you have to agree to the terms presented below. If you have done so, your a
{{ errors.country }}
Password: @@ -86,6 +97,9 @@ Also you have to agree to the terms presented below. If you have done so, your a
{% if errors.password is defined %}{{ errors.password }}{% endif %}
@@ -99,6 +113,8 @@ Also you have to agree to the terms presented below. If you have done so, your a
{{ errors.verification }}
@@ -107,6 +123,9 @@ Also you have to agree to the terms presented below. If you have done so, your a
@@ -117,6 +136,9 @@ Also you have to agree to the terms presented below. If you have done so, your a
+ + {{ hook('HOOK_ACCOUNT_CREATE_BEFORE_CHARACTER_NAME') }} + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_CHARACTER_NAME') }} + + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_SEX') }} + {% if config.character_samples|length > 1 %} {% endif %} + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_VOCATION') }} + {% if config.character_towns|length > 1 %} {% endif %} + + {{ hook('HOOK_ACCOUNT_CREATE_AFTER_TOWNS') }} +
Character Name: @@ -134,6 +156,8 @@ Also you have to agree to the terms presented below. If you have done so, your a
Sex: @@ -165,6 +189,9 @@ Also you have to agree to the terms presented below. If you have done so, your a {% if errors.sex is defined %}{{ errors.sex }}{% endif %}
@@ -195,6 +222,9 @@ Also you have to agree to the terms presented below. If you have done so, your a
@@ -219,6 +249,9 @@ Also you have to agree to the terms presented below. If you have done so, your a
@@ -232,6 +265,9 @@ Also you have to agree to the terms presented below. If you have done so, your a
@@ -266,6 +302,9 @@ Also you have to agree to the terms presented below. If you have done so, your a

+ {{ hook('HOOK_ACCOUNT_CREATE_BEFORE_SUBMIT_BUTTON') }}
@@ -288,4 +328,5 @@ Also you have to agree to the terms presented below. If you have done so, your a
- \ No newline at end of file +{{ hook('HOOK_ACCOUNT_CREATE_AFTER_FORM') }} +