diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 5fa6843978e..3ba9e41c670 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -30,7 +30,7 @@ include_once 'inc.php'; $err = 0; $allowinstall = 0; -$allowupgrade = 0; +$allowupgrade = false; $checksok = 1; $setuplang=GETPOST("selectlang",'',3)?GETPOST("selectlang",'',3):$langs->getDefaultLang(); @@ -181,11 +181,11 @@ if (is_readable($conffile) && filesize($conffile) > 8) if ($databaseok) { // Already installed for all parts (config and database). We can propose upgrade. - $allowupgrade=1; + $allowupgrade=true; } else { - $allowupgrade=0; + $allowupgrade=false; } } else @@ -216,7 +216,7 @@ else } // First install, we can't upgrade - $allowupgrade=0; + $allowupgrade=false; } @@ -382,6 +382,7 @@ else $allowupgrade=false; } if (defined("MAIN_NOT_INSTALLED")) $allowupgrade=false; + if (GETPOST('allowupgrade')) $allowupgrade=true; $migrationscript=array( array('from'=>'3.0.0', 'to'=>'3.1.0'), array('from'=>'3.1.0', 'to'=>'3.2.0'), array('from'=>'3.2.0', 'to'=>'3.3.0'), diff --git a/htdocs/install/mysql/tables/llx_accounting_account.key.sql b/htdocs/install/mysql/tables/llx_accounting_account.key.sql index db08831570d..d9f635275b2 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.key.sql @@ -21,6 +21,8 @@ ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_fk_pcg_version (fk_pcg_version); ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_number (account_number); -ALTER TABLE llx_accounting_account ADD CONSTRAINT fk_accounting_account_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accounting_system (pcg_version); +--ALTER TABLE llx_accounting_account ADD CONSTRAINT fk_accounting_account_fk_account_number FOREIGN KEY (fk_account_number) REFERENCES llx_accounting_account (account_number); ---ALTER TABLE llx_accounting_account ADD CONSTRAINT fk_accounting_account_fk_account_number FOREIGN KEY (fk_account_number) REFERENCES llx_accounting_account (account_number); + +-- This keys are created into foreign table after creation of foreign index +--ALTER TABLE llx_accounting_account ADD CONSTRAINT fk_accounting_account_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accounting_system (pcg_version); diff --git a/htdocs/install/mysql/tables/llx_accounting_system.key.sql b/htdocs/install/mysql/tables/llx_accounting_system.key.sql index 4d6034cec93..8365c481d81 100644 --- a/htdocs/install/mysql/tables/llx_accounting_system.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_system.key.sql @@ -20,3 +20,5 @@ ALTER TABLE llx_accounting_system ADD UNIQUE INDEX uk_accounting_system_pcg_version (pcg_version); +-- This key is for another table but created here because must be done after foreign key index is created +ALTER TABLE llx_accounting_account ADD CONSTRAINT fk_accounting_account_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accounting_system (pcg_version); diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 2651c45c05c..f880da8b854 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -167,6 +167,17 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) // Create user include_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; + // Set default encryption to yes if there is no user yet into database + $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + //$sql.= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value + $resql=$db->query($sql); + if ($resql) + { + $numrows=$db->num_rows($resql); + if ($numrows == 0) dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1",'chaine',0,'',$conf->entity); + } + $createuser=new User($db); $createuser->id=0;