Skip to content

Commit 13a6d8e

Browse files
committed
fix: correzione wizard configurazione database
1 parent 0180efd commit 13a6d8e

1 file changed

Lines changed: 50 additions & 14 deletions

File tree

include/init/configuration.php

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,38 @@
263263
}
264264

265265
// Controlli per essere sicuro che l'utente abbia letto la licenza
266+
$json_flags = JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT;
267+
$cannot_proceed_title_js = json_encode(tr('Impossibile procedere'), $json_flags);
268+
$license_required_message_js = json_encode(tr('Devi accettare la licenza per proseguire!'), $json_flags);
269+
$mysql_incompatible_title_js = json_encode(tr('Configurazione MySQL incompatibile'), $json_flags);
270+
$mysql_incompatible_message_js = json_encode(
271+
tr('La SQL mode del server MySQL contiene ONLY_FULL_GROUP_BY, incompatibile con OpenSTAManager.')
272+
."\n\n".tr('Aggiungi nel file my.ini nella sezione [mysqld]:')
273+
."\n\nsql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\n\n"
274+
.tr('Poi riavvia MySQL e riprova.'),
275+
$json_flags,
276+
);
277+
$connection_error_title_js = json_encode(tr('Errore di connessione'), $json_flags);
278+
$connection_error_message_js = json_encode(tr('Impossibile connettersi al database con i parametri inseriti').'.', $json_flags);
279+
$insufficient_permissions_title_js = json_encode(tr('Permessi insufficienti'), $json_flags);
280+
$insufficient_permissions_message_js = json_encode(tr("L'utente MySQL non ha i permessi necessari per creare e modificare le tabelle. Verifica i permessi o usa un altro utente.").'.', $json_flags);
281+
$connection_success_title_js = json_encode(tr('Connessione riuscita'), $json_flags);
282+
$connection_success_message_js = json_encode(
283+
tr('Connessione al database stabilita correttamente').'. '
284+
.tr('Clicca su _BTN_ per procedere con l\'installazione', [
285+
'_BTN_' => "'".tr('Procedi')."'",
286+
]).'.',
287+
$json_flags,
288+
);
289+
$generic_error_prefix_js = json_encode(tr('Errore').': ', $json_flags);
290+
266291
echo '
267292
<script>
268293
$(document).ready(function(){
269294
// Custom tab navigation
270295
function navigateToStep(stepNumber) {
271296
var targetStep = "step-" + stepNumber;
297+
var targetHash = "#" + targetStep;
272298
273299
// Remove active class from all tabs
274300
$(".config-wizard-tabs li").removeClass("active");
@@ -282,6 +308,13 @@ function navigateToStep(stepNumber) {
282308
// Show target step
283309
$("#" + targetStep).show();
284310
311+
// Keep URL hash in sync with the current step
312+
if (window.history && window.history.replaceState) {
313+
window.history.replaceState(null, "", targetHash);
314+
} else {
315+
window.location.hash = targetHash;
316+
}
317+
285318
// Scroll to top of steps
286319
$("html, body").animate({ scrollTop: $("#steps").offset().top }, 500);
287320
@@ -333,7 +366,7 @@ function updateNavigationButtons(currentStep) {
333366
// Validazione per step 2 (licenza)
334367
if (currentStep === 2) {
335368
if (!$("#agree").is(":checked")) {
336-
swal("'.tr('Impossibile procedere').'", "'.tr('Devi accettare la licenza per proseguire!').'", "error");
369+
swal('.$cannot_proceed_title_js.', '.$license_required_message_js.', "error");
337370
return false;
338371
}
339372
}
@@ -343,11 +376,16 @@ function updateNavigationButtons(currentStep) {
343376
}
344377
});
345378
346-
// Set first tab as active by default
347-
$(".config-wizard-tabs li:first").addClass("active");
348-
$(".config-wizard-content > div[id^=\"step-\"]").hide();
349-
$("#step-1").show();
350-
updateNavigationButtons(1);
379+
// Set active tab based on hash or default to first step
380+
var totalSteps = $(".config-wizard-tabs li").length;
381+
var hashMatch = window.location.hash.match(/^#step-([1-9][0-9]*)$/);
382+
var initialStep = hashMatch ? parseInt(hashMatch[1], 10) : 1;
383+
384+
if (!initialStep || initialStep < 1 || initialStep > totalSteps) {
385+
initialStep = 1;
386+
}
387+
388+
navigateToStep(initialStep);
351389
352390
// Inizializza il widget collapse per le card
353391
$(document).on("click", "[data-card-widget=\"collapse\"]", function(e) {
@@ -389,8 +427,8 @@ function updateNavigationButtons(currentStep) {
389427
$installBtn.prop("disabled", false);
390428
$("#test").prop("disabled", false);
391429
swal(
392-
"'.tr('Configurazione MySQL incompatibile').'",
393-
"'.addslashes(tr('La SQL mode del server MySQL contiene ONLY_FULL_GROUP_BY, incompatibile con OpenSTAManager.') . "\n\n" . tr('Aggiungi nel file my.ini nella sezione [mysqld]:') . "\n\nsql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\n\n" . tr('Poi riavvia MySQL e riprova.')).'",
430+
'.$mysql_incompatible_title_js.',
431+
'.$mysql_incompatible_message_js.',
394432
"error"
395433
);
396434
} else {
@@ -427,17 +465,15 @@ function updateNavigationButtons(currentStep) {
427465
$("#install").prop("disabled", false);
428466
429467
if(data == 0){
430-
swal("'.tr('Errore di connessione').'", "'.tr('Impossibile connettersi al database con i parametri inseriti').'.", "error");
468+
swal('.$connection_error_title_js.', '.$connection_error_message_js.', "error");
431469
} else if(data == 1){
432-
swal("'.tr('Permessi insufficienti').'", "'.tr("L'utente MySQL non ha i permessi necessari per creare e modificare le tabelle. Verifica i permessi o usa un altro utente.").'.", "error");
470+
swal('.$insufficient_permissions_title_js.', '.$insufficient_permissions_message_js.', "error");
433471
} else {
434-
swal("'.tr('Connessione riuscita').'", "'.tr('Connessione al database stabilita correttamente').'. '.tr('Clicca su _BTN_ per procedere con l\'installazione', [
435-
'_BTN_' => "'".tr('Procedi')."'",
436-
]).'.", "success");
472+
swal('.$connection_success_title_js.', '.$connection_success_message_js.', "success");
437473
}
438474
},
439475
error: function(data) {
440-
alert("'.tr('Errore').': " + data);
476+
alert('.$generic_error_prefix_js.' + data);
441477
}
442478
});
443479
}

0 commit comments

Comments
 (0)