mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-17 03:03:26 +02:00
Feature: settings (#216)
* New admin panel Pages: Options + Config [WIP] * Forgot the plugin example of options * Rename to settings.php * Add Settings Class * New myaac_settings table * Add $limit parameter to $db->select method * Add $member var annotation * Remove useless title_separator from config * Move $menus to menus.php Also fix active link when menu item has subpage * Settings [WIP] New Settings class New Plugins::load() method Move config.php to settings.php MyAAC Settings will have plugin_name = 'core' Add compat_config.php * Change options.php to settings.php * Change name to settings * Add Settings menu * Add Sections + Add setting($key) function Reorganisation * Add email + password fields as type * Update 33.php * add settings migration * php 8 compatibility * add missing hook * Add categories in tabs, move more settings, revert back getPluginSettings Categories and sections are now not numbered Remove example settings plugin * fix typo * Update .gitignore * Add 36th migration for settings table * Execute migrations just after db connect * Update plugins.php * [WIP] Some work on settings Add hidden settings New method: parse, to parse settings from array Move base html to twig template Remove vocation loading from .xml, instead use predefined voc names * Rename * Fix path * [WIP] More work on settings Move more config to settings (mainly mail_* + some other) Remove mail_admin, wasnt used anywhere Add return type to some functions Add Twig settings(key) function Possibility to save setting to db * Add min, max, step to number field option * Re-enable plugin if disabled and already installed * Add Settings menu, including all plugins with settings One change included in previous commit, due to missclick * Nothing important * Better boolean detection * More detailed error message in settings * Lets call it settings.name instead * Add new function: only_if, to hide fields when they are not enabled [WIP] Not fully finished yet * guild_management: show_if * Hide section title on show_if * Fix: check on page load if radio button is checked * Add: show_if - account_mail_verify * nothing important * Rename team_* variables + add to deprecated * Change variable name * Extract Settings:save function * Add settings.callbacks.get * Move forum config to settings * Move status config to settings * Remove whitespaces * More config to settings: account_types, genders, highscores, admin * Move signature config to settings * Move news config to settings * Rename variable * Save config.php in Settings Egg and hen problem solved :) * Test database connection on save settings -> prevents from making website unusable if connection is wrong * Test server_path -> same There is no config.php anymore, just config.local.php, which can be edited manually and also from admin panel * Remove configs from previous commit * Fix create account, if account_create_character_create is enabled * Add more deprecated configs * Add more info into comment * Update 5-database.php * Fix menu highlighting & opening * Update template.php * Enable script option * Reword email settings + move two new settings * add last_kills_limit + move shop * google_analytics_id * add mail_lost_account_interval * Create character blocked words (by @gpedro), just moved to settings * Fix google_analytics * create character name config moved to settings * Fix for install warning - min/max length * New create character checks configurable: block monsters & spells names * fixes * Improve character npc name check * New setting: donate_column + move donate config to settings * Add super fancy No Refresh saving with a toast * Add new possibility: to deny saving setting if condition is not met * Move database settings to separate category * Fix default value displaying * Add database_hash setting * add last_kills_limit to compat config * Move create character blocked names down * Every setting needs to have default * Move rest of config to settings Remove config.php completely Add new settings category: Game Fix account_login_by_email Min textarea size = 2 + adjusted automatically
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
To change a name of character select player and choose a new name.<br/>
|
||||
<span style="color: red">Change name cost {{ config.account_change_character_name_points }} premium points. You have {{ points }} premium points.</span><br/><br/>
|
||||
<span style="color: red">Change name cost {{ setting('core.account_change_character_name_price') }} premium points. You have {{ points }} premium points.</span><br/><br/>
|
||||
<form action="{{ getLink('account/character/name') }}" method="post">
|
||||
<input type="hidden" name="changenamesave" value="1">
|
||||
<div class="TableContainer">
|
||||
|
@@ -1,5 +1,5 @@
|
||||
To change a sex of character select player and choose a new sex.<br/>
|
||||
<span style="color: red">Change sex cost {{ config.account_change_character_sex_points }} premium points. You have {{ points }} premium points.</span><br/><br/>
|
||||
<span style="color: red">Change sex cost {{ setting('core.account_change_character_sex_price') }} premium points. You have {{ points }} premium points.</span><br/><br/>
|
||||
<form action="{{ getLink('account/character/sex') }}" method="post">
|
||||
<input type="hidden" name="changesexsave" value="1"/>
|
||||
<div class="TableContainer">
|
||||
@@ -73,4 +73,4 @@ To change a sex of character select player and choose a new sex.<br/>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
@@ -59,7 +59,7 @@
|
||||
<td></td><td><span id="email_error" class="FormFieldError">{% if errors.email is defined %}{{ errors.email }}{% endif %}</span></td>
|
||||
</tr>
|
||||
|
||||
{% if config.mail_enabled and config.account_mail_verify %}
|
||||
{% if setting('core.mail_enabled') and config.account_mail_verify %}
|
||||
<tr><td></td><td><span><strong>Please use real address!<br/>We will send a link to validate your Email.</strong></span></td></tr>
|
||||
{% endif %}
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
|
||||
{{ hook('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1') }}
|
||||
|
||||
{% if (not config.mail_enabled or not config.account_mail_verify) and config.account_create_character_create %}
|
||||
{% if (not setting('core.mail_enabled') or not config.account_mail_verify) and config.account_create_character_create %}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="TableShadowContainerRightTop">
|
||||
@@ -140,7 +140,7 @@
|
||||
<span{% if errors.name is defined %} class="red"{% endif %}>Character Name:</span>
|
||||
</td>
|
||||
<td>
|
||||
<input id="character_name" name="name" size="{{ config.character_name_max_length }}" maxlength="{{ config.character_name_max_length }}" value="{{ name }}"/>
|
||||
<input id="character_name" name="name" size="{{ setting('core.create_character_name_max_length') }}" maxlength="{{ setting('core.create_character_name_max_length') }}" value="{{ name }}"/>
|
||||
<img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" style="display: none;" />
|
||||
<br>
|
||||
</td>
|
||||
|
@@ -45,7 +45,7 @@ In any case the name must not violate the naming conventions stated in the <a hr
|
||||
</tr>
|
||||
<tr class="Odd">
|
||||
<td>
|
||||
<input name="name" id="character_name" value="{{ name }}" size="{{ config.character_name_max_length }}" maxlength="{{ config.character_name_max_length }}" >
|
||||
<input name="name" id="character_name" value="{{ name }}" size="{{ setting('core.create_character_name_max_length') }}" maxlength="{{ setting('core.create_character_name_max_length') }}" >
|
||||
<img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" />
|
||||
<br/>
|
||||
<span style="font-size: 10px">
|
||||
@@ -145,4 +145,4 @@ In any case the name must not violate the naming conventions stated in the <a hr
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script type="text/javascript" src="tools/check_name.js"></script>
|
||||
<script type="text/javascript" src="tools/check_name.js"></script>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
To generate new recovery key for your account please enter your password.<br/>
|
||||
<span style="color: red"><b>New recovery key cost {{ config.generate_new_reckey_price }} Premium Points.</span> You have {{ points }} premium points. You will receive e-mail with this recovery key.</b><br/>
|
||||
<span style="color: red"><b>New recovery key cost {{ setting('core.account_generate_new_reckey_price') }} Premium Points.</span> You have {{ points }} premium points. You will receive e-mail with this recovery key.</b><br/>
|
||||
<form action="{{ getLink('account/register/new') }}" method="post">
|
||||
<input type="hidden" name="registeraccountsave" value="1">
|
||||
<div class="TableContainer" >
|
||||
@@ -56,4 +56,4 @@ To generate new recovery key for your account please enter your password.<br/>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
@@ -39,10 +39,10 @@
|
||||
{% for name, link in menus %}
|
||||
<a href="{{ getLink(link) }}">{{ name }}</a>
|
||||
{% endfor %}
|
||||
{% if config.account_change_character_name %}
|
||||
{% if setting('core.account_change_character_name') %}
|
||||
<a href="{{ getLink('account/character/name') }}">Change Name</a>
|
||||
{% endif %}
|
||||
{% if config.account_change_character_sex %}
|
||||
{% if setting('core.account_change_character_sex') %}
|
||||
<a href="{{ getLink('account/character/sex') }}">Change Sex</a>
|
||||
{% endif %}
|
||||
<a href="{{ getLink('account/logout') }}">Logout</a>
|
||||
@@ -192,7 +192,7 @@
|
||||
{% include('buttons.base.html.twig') %}
|
||||
</form>
|
||||
</td>
|
||||
{% if config.account_change_character_name %}
|
||||
{% if setting('core.account_change_character_name') %}
|
||||
<td>
|
||||
<form action="{{ getLink('account/character/name') }}" method="post" >
|
||||
{% set button_name = 'Change Name' %}
|
||||
@@ -200,7 +200,7 @@
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% if config.account_change_character_sex %}
|
||||
{% if setting('core.account_change_character_sex') %}
|
||||
<td>
|
||||
<form action="{{ getLink('account/character/sex') }}" method="post" >
|
||||
{% set button_name = 'Change Sex' %}
|
||||
|
105
system/templates/admin.settings.html.twig
Normal file
105
system/templates/admin.settings.html.twig
Normal file
@@ -0,0 +1,105 @@
|
||||
<div class="card card-primary card-outline card-outline-tabs">
|
||||
<div class="card-header">
|
||||
<h5 class="m-0">Settings</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="settings" method="post">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
<button name="save" type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
<br/>
|
||||
{{ settingsParsed|raw }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.setting-default {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function doShowHide(el, show)
|
||||
{
|
||||
if (show) {
|
||||
$(el).show()
|
||||
}
|
||||
else {
|
||||
$(el).hide()
|
||||
}
|
||||
}
|
||||
|
||||
{% for key, value in settings %}
|
||||
{% if value.show_if is defined %}
|
||||
$(function () {
|
||||
$('input[name="settings[{{ value.show_if[0] }}]"]').change(function () {
|
||||
performChecks_{{ key }}(this);
|
||||
});
|
||||
|
||||
{% if settings[value.show_if[0]]['type'] == 'boolean' %}
|
||||
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]:checked');
|
||||
{% else %}
|
||||
performChecks_{{ key }}('input[name="settings[{{ value.show_if[0] }}]"]');
|
||||
{% endif %}
|
||||
});
|
||||
|
||||
function performChecks_{{ key }}(el)
|
||||
{
|
||||
let success = false;
|
||||
let thisVal = $(el).val();
|
||||
|
||||
let operator = '{{ value.show_if[1]|raw }}';
|
||||
if (operator === '>') {
|
||||
success = thisVal > Number('{{ value.show_if[2] }}');
|
||||
}
|
||||
else if (operator === '<') {
|
||||
success = thisVal < Number('{{ value.show_if[2] }}');
|
||||
}
|
||||
else if (operator === '==' || operator === '=') {
|
||||
success = thisVal == '{{ value.show_if[2] }}';
|
||||
}
|
||||
|
||||
doShowHide('#row_{{ key }}', success);
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</script>
|
||||
{{ script|raw }}
|
||||
<!-- jQuery Form Submit No Refresh + Toastify -->
|
||||
<link rel="stylesheet" type="text/css" href="{{ constant('BASE_URL') }}tools/css/toastify.min.css">
|
||||
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/js/toastify.min.js"></script>
|
||||
<script>
|
||||
$('#settings').submit(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '{{ constant('ADMIN_URL') }}tools/settings_save.php?plugin={{ settingsKeyName }}',
|
||||
data : $(this).serialize(),
|
||||
success : function(response) {
|
||||
Toastify({
|
||||
position: 'center',
|
||||
text: response,
|
||||
duration: 3000,
|
||||
escapeMarkup: false,
|
||||
}).showToast();
|
||||
},
|
||||
error : function(response) {
|
||||
Toastify({
|
||||
position: 'center',
|
||||
text: response.responseText,
|
||||
duration: 3000,
|
||||
style: {
|
||||
background: 'red',
|
||||
},
|
||||
escapeMarkup: false,
|
||||
}).showToast();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
@@ -284,7 +284,7 @@
|
||||
|
||||
{{ hook(constant('HOOK_CHARACTERS_BEFORE_SIGNATURE')) }}
|
||||
|
||||
{% if config.signature_enabled %}
|
||||
{% if setting('core.signature_enabled') %}
|
||||
<!-- SIGNATURE -->
|
||||
<script type="text/javascript">
|
||||
function showSignLinks()
|
||||
|
@@ -155,7 +155,7 @@
|
||||
{% if (item.count > 1) %}
|
||||
<span class="loot_amount">{{ item.count }}</span>
|
||||
{% endif %}
|
||||
<a href="{{ config.creatures_items_url }}{{ item.name|title }}"><img title="{{ item.tooltip }}" src="{{ config.item_images_url }}{{ item.id }}{{ config.item_images_extension }}" class="loot_image"/></a>
|
||||
<a href="{{ config.monsters_items_url }}{{ item.name|title }}"><img title="{{ item.tooltip }}" src="{{ config.item_images_url }}{{ item.id }}{{ config.item_images_extension }}" class="loot_image"/></a>
|
||||
</span>
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
@@ -6,14 +6,14 @@ Remember you can also check the respective skill bar in your skill window of the
|
||||
<td class="white" colspan="5"><b>Experience Table</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
{% for i in 0..config.experiencetable_columns-1 %}
|
||||
{% for i in 0..setting('core.experience_table_columns')-1 %}
|
||||
<td>
|
||||
<table border="0" cellpadding="2" cellspacing="1" width="100%">
|
||||
<tr bgcolor="{{ config.lightborder }}">
|
||||
<td><b>Level</b></td>
|
||||
<td><b>Experience</b></td>
|
||||
</tr>
|
||||
{% for level in i * config.experiencetable_rows + 1..i * config.experiencetable_rows + (config.experiencetable_rows + 1) - 1 %}
|
||||
{% for level in i * setting('core.experience_table_rows') + 1..i * setting('core.experience_table_rows') + (setting('core.experience_table_rows') + 1) - 1 %}
|
||||
<tr bgcolor="{{ config.lightborder }}">
|
||||
<td>{{ level }}</td>
|
||||
<td>{{ experience[level] }}</td>
|
||||
@@ -23,4 +23,4 @@ Remember you can also check the respective skill bar in your skill window of the
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
@@ -4,6 +4,6 @@
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '{{ config.google_analytics_id }}', 'auto');
|
||||
ga('create', '{{ setting('core.google_analytics_id') }}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</script>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<form action="{{ constant('BASE_URL') }}install/" method="post" autocomplete="off">
|
||||
<input type="hidden" name="step" id="step" value="database" />
|
||||
|
||||
{% for value in ['server_path', 'mail_admin'] %}
|
||||
{% for value in ['server_path'] %}
|
||||
<div class="form-group mb-2">
|
||||
<label for="vars_{{ value }}">{{ locale['step_config_' ~ value] }}</label>
|
||||
<input class="form-control" type="{% if value == 'mail_admin' %}email{% else %}text{% endif %}" name="vars[{{ value }}]" id="vars_{{ value }}"{% if session['var_' ~ value] is not null %} value="{{ session['var_' ~ value] }}"{% endif %}/>
|
||||
|
@@ -4,4 +4,4 @@ The request was made on {{ "now"|date("F j, Y, g:i a") }} by a user with the IP:
|
||||
<br/><br/>
|
||||
The new password is: <b>{{ new_password }}</b>
|
||||
<br/><br/>
|
||||
If this was you, please ignore this email. If it was not you, please contact our support department at {{ config.mail_admin }}.
|
||||
If this was you, please ignore this email. If it was not you, please contact our support department.
|
||||
|
@@ -25,7 +25,7 @@
|
||||
<b>Group</b>
|
||||
</td>
|
||||
|
||||
{% if config.team_display_outfit %}
|
||||
{% if setting('core.team_outfit') %}
|
||||
<td width="5%" class="white">
|
||||
<b>Outfit</b>
|
||||
</td>
|
||||
@@ -35,19 +35,19 @@
|
||||
<b>Name</b>
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
{% if setting('core.team_status') %}
|
||||
<td class="white">
|
||||
<b>Status</b>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
{% if (setting('core.multiworld') or setting('core.team_world')) %}
|
||||
<td class="white">
|
||||
<b>World</b>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
{% if setting('core.team_lastlogin') %}
|
||||
<td class="white">
|
||||
<b>Last login</b>
|
||||
</td>
|
||||
@@ -61,7 +61,7 @@
|
||||
<tr bgcolor="{{ getStyle(i) }}" style="height: 32px;">
|
||||
<td>{{ group.group_name|capitalize }}</td>
|
||||
|
||||
{% if config.team_display_outfit %}
|
||||
{% if setting('core.team_outfit') %}
|
||||
<td>
|
||||
<img style="position: absolute; margin-top: {% if member.player.looktype in config.outfit_images_wrong_looktypes %}-16px;margin-left:-0px;{% else %} -45px; margin-left: -30px;{% endif %}" src="{{ member.outfit }}" alt="player outfit"/>
|
||||
</td>
|
||||
@@ -74,7 +74,7 @@
|
||||
{{ member.link|raw }}
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
{% if setting('core.team_status') %}
|
||||
<td>
|
||||
{% if member.status %}
|
||||
<span style="color: green"><b>Online</b></span>
|
||||
@@ -84,13 +84,13 @@
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
{% if (setting('core.multiworld') or setting('core.team_world')) %}
|
||||
<td>
|
||||
<span><b>{{ member.world_name }}</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
{% if setting('core.team_lastlogin') %}
|
||||
<td>
|
||||
<span>{{ member.last_login }}</span>
|
||||
</td>
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
<table cellspacing="1" cellpadding="4" border="0" width="100%">
|
||||
<tr bgcolor="{{ config.vdarkborder }}">
|
||||
{% if config.team_display_outfit %}
|
||||
{% if setting('core.team_outfit') %}
|
||||
<td width="5%" class="white">
|
||||
<b>Outfit</b>
|
||||
</td>
|
||||
@@ -117,19 +117,19 @@
|
||||
<b>Name</b>
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
{% if setting('core.team_status') %}
|
||||
<td class="white">
|
||||
<b>Status</b>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
{% if (setting('core.multiworld') or setting('core.team_world')) %}
|
||||
<td class="white">
|
||||
<b>World</b>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
{% if setting('core.team_lastlogin') %}
|
||||
<td class="white">
|
||||
<b>Last login</b>
|
||||
</td>
|
||||
@@ -139,7 +139,7 @@
|
||||
{% for member in group.members %}
|
||||
{% set i = i + 1 %}
|
||||
<tr bgcolor="{{ getStyle(i) }}" style="height: 32px;">
|
||||
{% if config.team_display_outfit %}
|
||||
{% if setting('core.team_outfit') %}
|
||||
<td>
|
||||
<img style="position: absolute; margin-top: {% if member.player.looktype in config.outfit_images_wrong_looktypes %}-16px;margin-left:-0px;{% else %} -45px; margin-left: -30px;{% endif %}" src="{{ member.outfit }}" alt="player outfit"/>
|
||||
</td>
|
||||
@@ -152,7 +152,7 @@
|
||||
{{ member.link|raw }}
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
{% if setting('core.team_status') %}
|
||||
<td>
|
||||
{% if member.status %}
|
||||
<span style="color: green"><b>Online</b></span>
|
||||
@@ -162,13 +162,13 @@
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
{% if (setting('core.multiworld') or setting('core.team_world')) %}
|
||||
<td>
|
||||
<span><b>{{ member.world_name }}</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
{% if setting('core.team_lastlogin') %}
|
||||
<td>
|
||||
<span>{{ member.last_login }}</span>
|
||||
</td>
|
||||
|
Reference in New Issue
Block a user