asdas
This commit is contained in:
@@ -306,6 +306,9 @@ final class ModuleCronScheduler
|
||||
$job = $jobExists ? $jobs[$definition['name']] : [];
|
||||
$timezoneSetting = trim((string) ($definition['timezone_setting'] ?? ''));
|
||||
$fallbackTimezone = $timezoneSetting !== '' ? trim((string) ($settings[$timezoneSetting] ?? '')) : '';
|
||||
if ($fallbackTimezone === '' && function_exists('nexus_cron_timezone_name')) {
|
||||
$fallbackTimezone = trim((string) nexus_cron_timezone_name());
|
||||
}
|
||||
$defaultEntry = [
|
||||
'enabled' => (bool) $definition['default_enabled'],
|
||||
'cron_expression' => trim((string) ($definition['default_cron'] ?? '0 * * * *')),
|
||||
@@ -336,7 +339,7 @@ final class ModuleCronScheduler
|
||||
$result[] = [
|
||||
'enabled' => array_key_exists('enabled', $entry) ? $this->settingBool($entry['enabled'], (bool) $defaultEntry['enabled']) : (bool) $defaultEntry['enabled'],
|
||||
'cron_expression' => trim((string) ($entry['cron_expression'] ?? $defaultEntry['cron_expression'])),
|
||||
'timezone' => trim((string) ($entry['timezone'] ?? $defaultEntry['timezone'])),
|
||||
'timezone' => (($entryTimezone = trim((string) ($entry['timezone'] ?? ''))) !== '' ? $entryTimezone : $defaultEntry['timezone']),
|
||||
'builder' => is_array($entry['builder'] ?? null) ? $entry['builder'] : [],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -336,6 +336,66 @@ function nexus_debug_clear(?string $source = null): void
|
||||
}));
|
||||
}
|
||||
|
||||
function nexus_settings(): array
|
||||
{
|
||||
try {
|
||||
return modules()->settings('_nexus');
|
||||
} catch (\Throwable) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function nexus_save_settings(array $settings): void
|
||||
{
|
||||
modules()->saveSettings('_nexus', $settings);
|
||||
}
|
||||
|
||||
function nexus_system_timezone_name(): string
|
||||
{
|
||||
$timezone = trim((string) date_default_timezone_get());
|
||||
if ($timezone === '') {
|
||||
return 'UTC';
|
||||
}
|
||||
|
||||
try {
|
||||
new \DateTimeZone($timezone);
|
||||
return $timezone;
|
||||
} catch (\Throwable) {
|
||||
return 'UTC';
|
||||
}
|
||||
}
|
||||
|
||||
function nexus_display_timezone_name(): string
|
||||
{
|
||||
$settings = nexus_settings();
|
||||
$useCustom = !empty($settings['display_timezone_custom']);
|
||||
$timezone = trim((string) ($settings['display_timezone'] ?? ''));
|
||||
if ($useCustom && $timezone !== '') {
|
||||
try {
|
||||
new \DateTimeZone($timezone);
|
||||
return $timezone;
|
||||
} catch (\Throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
return nexus_system_timezone_name();
|
||||
}
|
||||
|
||||
function nexus_cron_timezone_name(): string
|
||||
{
|
||||
$settings = nexus_settings();
|
||||
$timezone = trim((string) ($settings['cron_timezone'] ?? ''));
|
||||
if ($timezone !== '') {
|
||||
try {
|
||||
new \DateTimeZone($timezone);
|
||||
return $timezone;
|
||||
} catch (\Throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
return nexus_display_timezone_name();
|
||||
}
|
||||
|
||||
function module_debug_enabled(string $module): bool
|
||||
{
|
||||
if (preg_match('/[^a-zA-Z0-9_\-]/', $module)) {
|
||||
|
||||
Reference in New Issue
Block a user