mirror of
https://github.com/slawkens/myaac.git
synced 2025-08-23 18:58:31 +02:00
Compare commits
No commits in common. "main" and "v1.8" have entirely different histories.
@ -1,6 +1,6 @@
|
||||
# Changelog
|
||||
|
||||
## [1.8 - 02.08.2025]
|
||||
## [1.8 - 01.08.2025]
|
||||
|
||||
### Added
|
||||
* Templates - Kathrine: Possibility to add custom menu categories (https://github.com/slawkens/myaac/commit/ec11c1402417c25980582467546d1c1e9bb8267f)
|
||||
|
@ -26,7 +26,7 @@
|
||||
if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is required.');
|
||||
|
||||
const MYAAC = true;
|
||||
const MYAAC_VERSION = '1.8.1-dev';
|
||||
const MYAAC_VERSION = '1.8';
|
||||
const DATABASE_VERSION = 45;
|
||||
const TABLE_PREFIX = 'myaac_';
|
||||
define('START_TIME', microtime(true));
|
||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -976,16 +976,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz",
|
||||
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz",
|
||||
"integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
@ -2085,9 +2084,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tmp": {
|
||||
"version": "0.2.4",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.4.tgz",
|
||||
"integrity": "sha512-UdiSoX6ypifLmrfQ/XfiawN6hkjSBpCjhKxxZcWlUUmoXLaCKQU0bx4HF/tdDK2uzRuchf1txGvrWBzYREssoQ==",
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz",
|
||||
"integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
@ -105,17 +105,8 @@ $cached = Cache::remember("online_$order", setting('core.online_cache_ttl') * 60
|
||||
$result = null;
|
||||
$timestamp = false;
|
||||
if($db->hasTable('server_record')) {
|
||||
$timestamp = $db->hasColumn('server_record', 'timestamp');
|
||||
$serverRecordQuery = ServerRecord::query();
|
||||
|
||||
if ($db->hasColumn('server_record', 'world_id')) {
|
||||
$serverRecordQuery->where('world_id', configLua('worldId'));
|
||||
}
|
||||
|
||||
$result = $serverRecordQuery->orderByDesc('record')->first();
|
||||
if ($result) {
|
||||
$result = $result->toArray();
|
||||
}
|
||||
$timestamp = true;
|
||||
$result = ServerRecord::where('world_id', configLua('worldId'))->orderByDesc('record')->first()->toArray();
|
||||
} else if($db->hasTable('server_config')) { // tfs 1.0
|
||||
$row = ServerConfig::where('config', 'players_record')->first();
|
||||
if ($row) {
|
||||
|
@ -1295,7 +1295,7 @@ Sent by MyAAC,<br/>
|
||||
'name' => 'Data Center',
|
||||
'type' => 'text',
|
||||
'desc' => 'Server Location, will be shown on online page',
|
||||
'default' => 'Poland - Warsaw',
|
||||
'default' => 'Frankfurt - Germany',
|
||||
],
|
||||
[
|
||||
'type' => 'section',
|
||||
|
@ -45,22 +45,6 @@ class MigrateRunCommand extends Command
|
||||
|
||||
$down = $input->getOption('down') ?? false;
|
||||
|
||||
/**
|
||||
* Sort according to $down option.
|
||||
* Do we really want it?
|
||||
* Or should we use order provided by user,
|
||||
* even when it's not sorted correctly?
|
||||
* Leaving it for consideration.
|
||||
*/
|
||||
/*
|
||||
if ($down) {
|
||||
rsort($ids);
|
||||
}
|
||||
else {
|
||||
sort($ids);
|
||||
}
|
||||
*/
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$this->executeMigration($id, $io, !$down);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class PluginSetupCommand extends Command
|
||||
class PluginInstallInstallCommand extends Command
|
||||
{
|
||||
protected function configure(): void
|
||||
{
|
@ -3,7 +3,6 @@
|
||||
namespace MyAAC\Commands;
|
||||
|
||||
use MyAAC\Models\Settings as SettingsModel;
|
||||
use MyAAC\Plugins;
|
||||
use MyAAC\Settings;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@ -35,14 +34,7 @@ class SettingsResetCommand extends Command
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
// find by plugin name
|
||||
foreach (Plugins::getAllPluginsSettings() as $key => $setting) {
|
||||
if ($setting['pluginFilename'] === $name) {
|
||||
$name = $key;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
if (!$name) {
|
||||
SettingsModel::truncate();
|
||||
}
|
||||
else {
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace MyAAC\Commands;
|
||||
|
||||
use MyAAC\Models\Settings as SettingsModel;
|
||||
use MyAAC\Plugins;
|
||||
use MyAAC\Settings;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@ -18,7 +17,7 @@ class SettingsSetCommand extends Command
|
||||
->setDescription('Updates the setting specified by argument in database')
|
||||
->addArgument('key',
|
||||
InputArgument::REQUIRED,
|
||||
'Setting key in format name.key'
|
||||
'Setting name/key'
|
||||
)
|
||||
->addArgument('value',
|
||||
InputArgument::REQUIRED,
|
||||
@ -35,18 +34,6 @@ class SettingsSetCommand extends Command
|
||||
$key = $input->getArgument('key');
|
||||
$value = $input->getArgument('value');
|
||||
|
||||
// format settings_name.key
|
||||
// example: core.template
|
||||
$explode = explode('.', $key);
|
||||
|
||||
// find by plugin name
|
||||
foreach (Plugins::getAllPluginsSettings() as $_key => $setting) {
|
||||
if ($setting['pluginFilename'] === $explode[0]) {
|
||||
$explode[0] = $_key;
|
||||
$key = implode('.', $explode);
|
||||
}
|
||||
}
|
||||
|
||||
$settings = Settings::getInstance();
|
||||
$settings->clearCache();
|
||||
$settings->load();
|
||||
@ -57,6 +44,10 @@ class SettingsSetCommand extends Command
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
// format plugin_name.key
|
||||
// example: core.template
|
||||
$explode = explode('.', $key);
|
||||
|
||||
$settings->updateInDatabase($explode[0], $explode[1], $value);
|
||||
$settings->clearCache();
|
||||
|
||||
|
@ -7,13 +7,16 @@ use MyAAC\Models\Settings as ModelsSettings;
|
||||
|
||||
class Settings implements \ArrayAccess
|
||||
{
|
||||
static private ?Settings $instance = null;
|
||||
private array $settingsFile = [];
|
||||
private array $settingsDatabase = [];
|
||||
private array $cache = [];
|
||||
private array $valuesAsked = [];
|
||||
private array $errors = [];
|
||||
static private $instance;
|
||||
private $settingsFile = [];
|
||||
private $settingsDatabase = [];
|
||||
private $cache = [];
|
||||
private $valuesAsked = [];
|
||||
private $errors = [];
|
||||
|
||||
/**
|
||||
* @return Settings
|
||||
*/
|
||||
public static function getInstance(): Settings
|
||||
{
|
||||
if (!self::$instance) {
|
||||
@ -23,21 +26,28 @@ class Settings implements \ArrayAccess
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function load(): void
|
||||
public function load()
|
||||
{
|
||||
$this->settingsDatabase = Cache::remember('settings', 10 * 60, function () {
|
||||
$settingsDatabase = [];
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('settings', $tmp)) {
|
||||
$this->settingsDatabase = unserialize($tmp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$settings = ModelsSettings::all();
|
||||
foreach ($settings as $setting) {
|
||||
$settingsDatabase[$setting->name][$setting->key] = $setting->value;
|
||||
$this->settingsDatabase[$setting->name][$setting->key] = $setting->value;
|
||||
}
|
||||
|
||||
return $settingsDatabase;
|
||||
});
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('settings', serialize($this->settingsDatabase), 600);
|
||||
}
|
||||
}
|
||||
|
||||
public function save($pluginName, $values): bool
|
||||
public function save($pluginName, $values)
|
||||
{
|
||||
$this->loadPlugin($pluginName);
|
||||
|
||||
@ -94,7 +104,7 @@ class Settings implements \ArrayAccess
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateInDatabase($pluginName, $key, $value): void
|
||||
public function updateInDatabase($pluginName, $key, $value)
|
||||
{
|
||||
if (ModelsSettings::where(['name' => $pluginName, 'key' => $key])->exists()) {
|
||||
ModelsSettings::where(['name' => $pluginName, 'key' => $key])->update(['value' => $value]);
|
||||
@ -107,7 +117,7 @@ class Settings implements \ArrayAccess
|
||||
$this->clearCache();
|
||||
}
|
||||
|
||||
public function deleteFromDatabase($pluginName, $key = null): void
|
||||
public function deleteFromDatabase($pluginName, $key = null)
|
||||
{
|
||||
if (!isset($key)) {
|
||||
ModelsSettings::where('name', $pluginName)->delete();
|
||||
@ -207,7 +217,7 @@ class Settings implements \ArrayAccess
|
||||
if (isset($setting['hidden']) && $setting['hidden']) {
|
||||
$value = '';
|
||||
if ($setting['type'] === 'boolean') {
|
||||
$value = (getBoolean($setting['default']) ? 'true' : 'false');
|
||||
$value = ($setting['default'] ? 'true' : 'false');
|
||||
}
|
||||
else if (in_array($setting['type'], ['text', 'number', 'float', 'double', 'email', 'password', 'textarea'])) {
|
||||
$value = $setting['default'];
|
||||
@ -220,7 +230,12 @@ class Settings implements \ArrayAccess
|
||||
}
|
||||
else if ($setting['type'] === 'boolean') {
|
||||
if(isset($settingsDb[$key])) {
|
||||
$value = getBoolean($settingsDb[$key]);
|
||||
if($settingsDb[$key] === 'true') {
|
||||
$value = true;
|
||||
}
|
||||
else {
|
||||
$value = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$value = ($setting['default'] ?? false);
|
||||
@ -368,7 +383,7 @@ class Settings implements \ArrayAccess
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value): void
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
throw new \RuntimeException("Settings: You cannot set empty offset with value: $value!");
|
||||
@ -408,7 +423,7 @@ class Settings implements \ArrayAccess
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset): void
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
@ -440,7 +455,7 @@ class Settings implements \ArrayAccess
|
||||
* @return array|mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset): mixed
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
// try cache hit
|
||||
if(isset($this->cache[$offset])) {
|
||||
@ -506,7 +521,7 @@ class Settings implements \ArrayAccess
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function updateValuesAsked($offset): void
|
||||
private function updateValuesAsked($offset)
|
||||
{
|
||||
$pluginKeyName = $offset;
|
||||
if (strpos($offset, '.')) {
|
||||
@ -522,7 +537,7 @@ class Settings implements \ArrayAccess
|
||||
}
|
||||
}
|
||||
|
||||
private function loadPlugin($offset): void
|
||||
private function loadPlugin($offset)
|
||||
{
|
||||
$this->updateValuesAsked($offset);
|
||||
|
||||
@ -551,7 +566,7 @@ class Settings implements \ArrayAccess
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveConfig($config, $filename, &$content = ''): bool|int
|
||||
public static function saveConfig($config, $filename, &$content = '')
|
||||
{
|
||||
$content = "<?php" . PHP_EOL;
|
||||
|
||||
|
@ -148,7 +148,7 @@ function get_template_menus(): array
|
||||
{
|
||||
global $template_name;
|
||||
|
||||
$result = Cache::remember('template_menus_' . $template_name, 10 * 60, function () use ($template_name) {
|
||||
$result = Cache::remember('template_menus', 10 * 60, function () use ($template_name) {
|
||||
$result = Menu::select(['name', 'link', 'blank', 'color', 'category'])
|
||||
->where('template', $template_name)
|
||||
->orderBy('category')
|
||||
|
@ -90,7 +90,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% if setting('core.online_record') and record|length > 0 %}
|
||||
{% if setting('core.online_record') %}
|
||||
<tr>
|
||||
<td class="LabelV150"><b>Online Record:</b></td>
|
||||
<td>
|
||||
@ -161,7 +161,7 @@
|
||||
{% endif %}
|
||||
|
||||
<td style="width:70%; text-align:left">
|
||||
{{ player.name|raw }}{{ player.skull|raw }}
|
||||
{{ player.name|raw }}{{ player.skull }}
|
||||
</td>
|
||||
<td style="width:10%">{{ player.level }}</td>
|
||||
<td style="width:20%">{{ player.vocation }}</td>
|
||||
|
@ -164,10 +164,6 @@ if(isset($config['boxes']))
|
||||
function InitializeMenu()
|
||||
{
|
||||
for(menuItemName in menu[0]) {
|
||||
if (!document.getElementById(menuItemName+"_Submenu")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(menu[0][menuItemName] == "0") {
|
||||
document.getElementById(menuItemName+"_Submenu").style.visibility = "hidden";
|
||||
document.getElementById(menuItemName+"_Submenu").style.display = "none";
|
||||
@ -391,7 +387,7 @@ foreach($config['menu_categories'] as $id => $cat) {
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if ($i == $countElements) {
|
||||
if($id == MENU_CATEGORY_SHOP || (!setting('core.gifts_system') && $i == $countElements)) {
|
||||
?>
|
||||
<div id='MenuBottom' style='background-image:url(<?php echo $template_path; ?>/images/general/box-bottom.gif);'></div>
|
||||
<?php
|
||||
|
Loading…
x
Reference in New Issue
Block a user