create character name config moved to settings

This commit is contained in:
slawkens 2023-07-22 10:57:42 +02:00
parent d82e3a21e5
commit aad175548a
7 changed files with 32 additions and 20 deletions

View File

@ -48,12 +48,6 @@ $config = array(
// won't be displayed if there is only one item (rookgaard for example)
'character_towns' => array(1),
// characters length
// This is the minimum and the maximum length that a player can create a character. It is highly recommend the maximum length to be 21.
'character_name_min_length' => 4,
'character_name_max_length' => 21,
'character_name_npc_check' => true,
// list of towns
// if you use TFS 1.3 with support for 'towns' table in database, then you can ignore this - it will be configured automatically (from MySQL database - Table - towns)
// otherwise it will try to load from your .OTBM map file

View File

@ -18,8 +18,8 @@ class CreateCharacter
*/
public function checkName($name, &$errors)
{
$minLength = config('character_name_min_length');
$maxLength = config('character_name_max_length');
$minLength = setting('core.create_character_name_min_length');
$maxLength = setting('core.create_character_name_max_length');
if(empty($name)) {
$errors['name'] = 'Please enter a name for your character!';

View File

@ -180,8 +180,8 @@ class Validator
return false;
}
$minLength = config('character_name_min_length');
$maxLength = config('character_name_max_length');
$minLength = setting('core.create_character_name_min_length');
$maxLength = setting('core.create_character_name_max_length');
// installer doesn't know config.php yet
// that's why we need to ignore the nulls
@ -221,7 +221,7 @@ class Validator
return false;
}
$npcCheck = config('character_name_npc_check');
$npcCheck = setting('core.create_character_name_npc_check');
if ($npcCheck) {
require_once LIBS . 'npc.php';
NPCS::load();
@ -332,7 +332,7 @@ class Validator
return false;
}
$npcCheck = config('character_name_npc_check');
$npcCheck = setting('core.create_character_name_npc_check');
if ($npcCheck) {
require_once LIBS . 'npc.php';
NPCS::load();

View File

@ -28,8 +28,8 @@ else
if($points < $config['account_change_character_name_points'])
$errors[] = 'You need ' . $config['account_change_character_name_points'] . ' premium points to change name. You have <b>'.$points.'<b> premium points.';
$minLength = config('character_name_min_length');
$maxLength = config('character_name_max_length');
$minLength = setting('core.create_character_name_min_length');
$maxLength = setting('core.create_character_name_max_length');
if(empty($errors) && empty($name))
$errors[] = 'Please enter a new name for your character!';

View File

@ -620,8 +620,26 @@ Sent by MyAAC,<br/>
'type' => 'section',
'title' => 'Create Character',
],
'create_character_name_npc_check' => [
'name' => 'Create Character Name Check NPC Names',
'type' => 'boolean',
'desc' => 'should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io',
'default' => true,
],
'create_character_name_min_length' => [
'name' => 'Name Min Length',
'type' => 'number',
'desc' => '',
'default' => 4,
],
'create_character_name_max_length' => [
'name' => 'Name Max Length',
'type' => 'number',
'desc' => 'It is highly recommend the maximum length to be 21',
'default' => 21,
],
'create_character_name_blocked_prefix' => [
'name' => 'Create Character Blocked Prefix',
'name' => 'Create Character Name Blocked Prefix',
'type' => 'textarea',
'desc' => 'Space after is important!',
'default' => 'admin ,administrator ,gm ,cm ,god ,tutor',
@ -632,7 +650,7 @@ Sent by MyAAC,<br/>
],
],
'create_character_name_blocked_names' => [
'name' => 'Create Character Blocked Names',
'name' => 'Create Character Name Blocked Names',
'type' => 'textarea',
'desc' => 'Separated by comma (,)',
'default' => 'admin,administrator,gm,cm,god,tutor',
@ -643,7 +661,7 @@ Sent by MyAAC,<br/>
],
],
'create_character_name_blocked_words' => [
'name' => 'Create Character Blocked Words',
'name' => 'Create Character Name Blocked Words',
'type' => 'textarea',
'desc' => 'Separated by comma (,)',
'default' => "admin,administrator,gamemaster,game master,game-master,game'master,fuck,sux,suck,noob,tutor",

View File

@ -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('create_character_name_max_length') }}" maxlength="{{ setting('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>

View File

@ -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('create_character_name_max_length') }}" maxlength="{{ setting('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>