Fix section with root pass restored when required if hidden

This commit is contained in:
Laurent Destailleur 2022-09-11 23:47:32 +02:00
parent 4cde1e8991
commit 0016e7c5e8
2 changed files with 40 additions and 24 deletions

View File

@ -448,7 +448,10 @@ if (!empty($force_install_noedit)) {
<input type="checkbox" <input type="checkbox"
id="db_create_database" id="db_create_database"
name="db_create_database" name="db_create_database"
<?php if ($force_install_createdatabase) { <?php
$checked = 0;
if ($force_install_createdatabase) {
$checked = 1;
print ' checked'; print ' checked';
} ?> } ?>
<?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) { <?php if ($force_install_noedit == 2 && $force_install_createdatabase !== null) {
@ -456,7 +459,8 @@ if (!empty($force_install_noedit)) {
} ?> } ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("CheckToCreateDatabase"); ?> <td class="comment">
<?php echo $langs->trans("CheckToCreateDatabase"); ?>
</td> </td>
</tr> </tr>
@ -503,7 +507,10 @@ if (!empty($force_install_noedit)) {
<input type="checkbox" <input type="checkbox"
id="db_create_user" id="db_create_user"
name="db_create_user" name="db_create_user"
<?php if (!empty($force_install_createuser)) { <?php
$checked = 0;
if (!empty($force_install_createuser)) {
$checked = 1;
print ' checked'; print ' checked';
} ?> } ?>
<?php if ($force_install_noedit == 2 && $force_install_createuser !== null) { <?php if ($force_install_noedit == 2 && $force_install_createuser !== null) {
@ -511,7 +518,8 @@ if (!empty($force_install_noedit)) {
} ?> } ?>
> >
</td> </td>
<td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?> <td class="comment">
<?php echo $langs->trans("CheckToCreateUser"); ?>
</td> </td>
</tr> </tr>
@ -613,30 +621,13 @@ jQuery(document).ready(function() {
}); });
function init_needroot()
{
console.log("init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
/*alert(jQuery("#db_create_database").prop("checked")); */
if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked"))
{
jQuery(".hideroot").show();
<?php
if (empty($force_install_noedit)) { ?>
jQuery(".needroot").removeAttr('disabled');
<?php } ?>
}
else
{
jQuery(".hideroot").hide();
jQuery(".needroot").prop('disabled', true);
}
}
init_needroot(); init_needroot();
jQuery("#db_create_database").click(function() { jQuery("#db_create_database").click(function() {
console.log("click on db_create_database");
init_needroot(); init_needroot();
}); });
jQuery("#db_create_user").click(function() { jQuery("#db_create_user").click(function() {
console.log("click on db_create_user");
init_needroot(); init_needroot();
}); });
<?php if ($force_install_noedit == 2 && empty($force_install_databasepass)) { ?> <?php if ($force_install_noedit == 2 && empty($force_install_databasepass)) { ?>
@ -644,6 +635,27 @@ jQuery(document).ready(function() {
<?php } ?> <?php } ?>
}); });
function init_needroot()
{
console.log("init_needroot force_install_noedit=<?php echo $force_install_noedit?>");
/*alert(jQuery("#db_create_database").prop("checked")); */
if (jQuery("#db_create_database").is(":checked") || jQuery("#db_create_user").is(":checked"))
{
console.log("init_needroot show root section");
jQuery(".hideroot").show();
<?php
if (empty($force_install_noedit)) { ?>
jQuery(".needroot").removeAttr('disabled');
<?php } ?>
}
else
{
console.log("init_needroot hide root section");
jQuery(".hideroot").hide();
jQuery(".needroot").prop('disabled', true);
}
}
function checkDatabaseName(databasename) { function checkDatabaseName(databasename) {
if (databasename.match(/[;\.]/)) { return false; } if (databasename.match(/[;\.]/)) { return false; }
return true; return true;
@ -651,6 +663,8 @@ function checkDatabaseName(databasename) {
function jscheckparam() function jscheckparam()
{ {
console.log("Click on jscheckparam");
ok=true; ok=true;
if (document.forminstall.main_dir.value == '') if (document.forminstall.main_dir.value == '')
@ -688,12 +702,14 @@ function jscheckparam()
{ {
ok=false; ok=false;
alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>'); alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseSoRootRequired")); ?>');
init_needroot();
} }
// If create user asked // If create user asked
else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == '')) else if (document.forminstall.db_create_user.checked == true && (document.forminstall.db_user_root.value == ''))
{ {
ok=false; ok=false;
alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>'); alert('<?php echo dol_escape_js($langs->transnoentities("YouAskToCreateDatabaseUserSoRootRequired")); ?>');
init_needroot();
} }
return ok; return ok;

View File

@ -530,7 +530,7 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
print '<input type="hidden" name="selectlang" value="'.dol_escape_htmltag($setuplang).'">'; print '<input type="hidden" name="selectlang" value="'.dol_escape_htmltag($setuplang).'">';
} }
print '</form>'."\n"; print '</form><br>'."\n";
// If there is some logs in buffer to show // If there is some logs in buffer to show
if (isset($conf->logbuffer) && count($conf->logbuffer)) { if (isset($conf->logbuffer) && count($conf->logbuffer)) {