'0.704' => '0.76'
);
- protected int $_step;
- private ?string $_mode;
- private ?string $_installed_version = null;
-
- private string $_db_type;
- private string $_db_host;
- private string $_db_port;
- private string $_db_name;
- private string $_db_user;
- private ?string $_db_pass;
- private ?string $_db_prefix = null;
-
- private bool $_db_connected;
+ protected int $step;
+ private ?string $mode;
+ private ?string $installed_version = null;
+
+ private string $db_type;
+ private string $db_host;
+ private string $db_port;
+ private string $db_name;
+ private string $db_user;
+ private ?string $db_pass;
+ private ?string $db_prefix = null;
+
+ private bool $db_connected;
/** @var array<string, string> */
- private array $_report;
+ private array $report;
- private string $_admin_login;
- private string $_admin_pass;
+ private string $admin_login;
+ private string $admin_pass;
- private bool $_error;
+ private bool $error;
/**
* Main constructor
*/
public function __construct()
{
- $this->_step = self::STEP_CHECK;
- $this->_mode = null;
- $this->_db_connected = false;
- $this->_db_prefix = null;
+ $this->step = self::STEP_CHECK;
+ $this->mode = null;
+ $this->db_connected = false;
+ $this->db_prefix = null;
}
/**
public function getStepTitle(): string
{
$step_title = null;
- switch ($this->_step) {
+ switch ($this->step) {
case self::STEP_CHECK:
$step_title = _T("Checks");
break;
/**
* Get current mode
*
- * @return string
+ * @return ?string
*/
public function getMode(): ?string
{
- return $this->_mode;
+ return $this->mode;
}
/**
*/
public function isInstall(): bool
{
- return $this->_mode === self::INSTALL;
+ return $this->mode === self::INSTALL;
}
/**
*/
public function isUpgrade(): bool
{
- return $this->_mode === self::UPDATE;
+ return $this->mode === self::UPDATE;
}
/**
public function setMode(string $mode): self
{
if ($mode === self::INSTALL || $mode === self::UPDATE) {
- $this->_mode = $mode;
+ $this->mode = $mode;
} else {
throw new \UnexpectedValueException('Unknown mode "' . $mode . '"');
}
*/
public function atPreviousStep(): void
{
- if ($this->_step > 0) {
+ if ($this->step > 0) {
if (
- $this->_step - 1 !== self::STEP_DB_INSTALL
- && $this->_step !== self::STEP_END
+ $this->step - 1 !== self::STEP_DB_INSTALL
+ && $this->step !== self::STEP_END
) {
- if ($this->_step === self::STEP_DB_INSTALL) {
- $this->_step = self::STEP_DB_CHECKS;
+ if ($this->step === self::STEP_DB_INSTALL) {
+ $this->step = self::STEP_DB_CHECKS;
} else {
- if ($this->_step === self::STEP_DB_UPGRADE) {
+ if ($this->step === self::STEP_DB_UPGRADE) {
$this->setInstalledVersion(null);
}
- $this->_step = $this->_step - 1;
+ $this->step = $this->step - 1;
}
} else {
$msg = null;
- if ($this->_step === self::STEP_END) {
+ if ($this->step === self::STEP_END) {
$msg = 'Ok man, install is finished already!';
} else {
$msg = 'It is forbidden to rerun database install!';
*/
public function isCheckStep(): bool
{
- return $this->_step === self::STEP_CHECK;
+ return $this->step === self::STEP_CHECK;
}
/**
*/
public function atTypeStep(): void
{
- $this->_step = self::STEP_TYPE;
+ $this->step = self::STEP_TYPE;
}
/**
*/
public function isTypeStep(): bool
{
- return $this->_step === self::STEP_TYPE;
+ return $this->step === self::STEP_TYPE;
}
/**
*/
public function atDbStep(): void
{
- $this->_step = self::STEP_DB;
+ $this->step = self::STEP_DB;
}
/**
*/
public function isDbStep(): bool
{
- return $this->_step === self::STEP_DB;
+ return $this->step === self::STEP_DB;
}
/**
*/
public function postCheckDb(): bool
{
- return $this->_step >= self::STEP_DB_CHECKS;
+ return $this->step >= self::STEP_DB_CHECKS;
}
/**
switch ($type) {
case Db::MYSQL:
case Db::PGSQL:
- $this->_db_type = $type;
+ $this->db_type = $type;
break;
default:
$errs[] = _T("Database type unknown");
*/
public function getDbType(): ?string
{
- return $this->_db_type ?? null;
+ return $this->db_type ?? null;
}
/**
*/
public function setDsn(string $host, string $port, string $name, string $user, ?string $pass): void
{
- $this->_db_host = $host;
- $this->_db_port = $port;
- $this->_db_name = $name;
- $this->_db_user = $user;
- $this->_db_pass = $pass;
+ $this->db_host = $host;
+ $this->db_port = $port;
+ $this->db_name = $name;
+ $this->db_user = $user;
+ $this->db_pass = $pass;
}
/**
*/
public function setTablesPrefix(string $prefix): self
{
- $this->_db_prefix = $prefix;
+ $this->db_prefix = $prefix;
return $this;
}
*/
public function getDbHost(): ?string
{
- return $this->_db_host ?? null;
+ return $this->db_host ?? null;
}
/**
*/
public function getDbPort(): ?string
{
- return $this->_db_port ?? null;
+ return $this->db_port ?? null;
}
/**
*/
public function getDbName(): ?string
{
- return $this->_db_name ?? null;
+ return $this->db_name ?? null;
}
/**
*/
public function getDbUser(): ?string
{
- return $this->_db_user ?? null;
+ return $this->db_user ?? null;
}
/**
*/
public function getDbPass(): string
{
- return $this->_db_pass;
+ return $this->db_pass;
}
/**
*/
public function getTablesPrefix(): ?string
{
- return $this->_db_prefix;
+ return $this->db_prefix;
}
/**
*/
public function atDbCheckStep(): void
{
- $this->_step = self::STEP_DB_CHECKS;
+ $this->step = self::STEP_DB_CHECKS;
}
/**
*/
public function isDbCheckStep(): bool
{
- return $this->_step === self::STEP_DB_CHECKS;
+ return $this->step === self::STEP_DB_CHECKS;
}
/**
public function testDbConnexion(): bool
{
return Db::testConnectivity(
- $this->_db_type,
- $this->_db_user,
- $this->_db_pass,
- $this->_db_host,
- $this->_db_port,
- $this->_db_name
+ $this->db_type,
+ $this->db_user,
+ $this->db_pass,
+ $this->db_host,
+ $this->db_port,
+ $this->db_name
);
}
*/
public function isDbConnected(): bool
{
- return $this->_db_connected;
+ return $this->db_connected;
}
/**
*/
public function atVersionSelection(): void
{
- $this->_step = self::STEP_VERSION;
+ $this->step = self::STEP_VERSION;
}
/**
*/
public function isVersionSelectionStep(): bool
{
- return $this->_step === self::STEP_VERSION;
+ return $this->step === self::STEP_VERSION;
}
/**
*/
public function atDbInstallStep(): void
{
- $this->_step = self::STEP_DB_INSTALL;
+ $this->step = self::STEP_DB_INSTALL;
}
/**
*/
public function isDbinstallStep(): bool
{
- return $this->_step === self::STEP_DB_INSTALL;
+ return $this->step === self::STEP_DB_INSTALL;
}
/**
*/
public function atDbUpgradeStep(): void
{
- $this->_step = self::STEP_DB_UPGRADE;
+ $this->step = self::STEP_DB_UPGRADE;
}
/**
*/
public function isDbUpgradeStep(): bool
{
- return $this->_step === self::STEP_DB_UPGRADE;
+ return $this->step === self::STEP_DB_UPGRADE;
}
if ($this->isUpgrade()) {
$update_scripts = self::getUpdateScripts(
$path,
- $this->_db_type,
- $this->_installed_version
+ $this->db_type,
+ $this->installed_version
);
} else {
- $update_scripts['current'] = $this->_db_type . '.sql';
+ $update_scripts['current'] = $this->db_type . '.sql';
}
return $update_scripts;
{
$fatal_error = false;
$update_scripts = $this->getScripts($spath);
- $this->_report = array();
+ $this->report = array();
$scripts_path = ($spath ?? GALETTE_ROOT . '/install') . '/scripts/';
foreach ($update_scripts as $key => $val) {
if ($updater instanceof \Galette\Updater\AbstractUpdater) {
$updater->run($zdb, $this);
$ret = $updater->getReport();
- $this->_report = array_merge($this->_report, $ret);
+ $this->report = array_merge($this->report, $ret);
} else {
$fatal_error = true;
Analog::log(
_T("%version script has been successfully executed :)")
);
$ret['res'] = true;
- $this->_report[] = $ret;
+ $this->report[] = $ret;
} catch (\RuntimeException $e) {
Analog::log(
$e->getMessage(),
_T("Unable to run %version update script :(")
);
$fatal_error = true;
- $this->_report[] = $ret;
+ $this->report[] = $ret;
}
}
// load in the sql parser
include_once GALETTE_ROOT . 'includes/sql_parse.php';
- $sql_query = preg_replace('/galette_/', $this->_db_prefix, $sql_query);
+ $sql_query = preg_replace('/galette_/', $this->db_prefix, $sql_query);
$sql_query = remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, ';');
}
}
- $this->_report = array_merge($this->_report, $queries_results);
+ $this->report = array_merge($this->report, $queries_results);
return !$fatal_error;
}
*/
public function getDbInstallReport(): array
{
- return $this->_report;
+ return $this->report;
}
/**
*/
public function reinitReport(): void
{
- $this->_report = array();
+ $this->report = array();
}
/**
*/
public function atAdminStep(): void
{
- $this->_step = self::STEP_ADMIN;
+ $this->step = self::STEP_ADMIN;
}
/**
*/
public function isAdminStep(): bool
{
- return $this->_step === self::STEP_ADMIN;
+ return $this->step === self::STEP_ADMIN;
}
/**
*/
public function setAdminInfos(string $login, string $pass): void
{
- $this->_admin_login = $login;
- $this->_admin_pass = password_hash($pass, PASSWORD_BCRYPT);
+ $this->admin_login = $login;
+ $this->admin_pass = password_hash($pass, PASSWORD_BCRYPT);
}
/**
*/
public function getAdminLogin(): string
{
- return $this->_admin_login;
+ return $this->admin_login;
}
/**
*/
public function getAdminPass(): string
{
- return $this->_admin_pass;
+ return $this->admin_pass;
}
/**
*/
public function atTelemetryStep(): void
{
- $this->_step = self::STEP_TELEMETRY;
+ $this->step = self::STEP_TELEMETRY;
}
/**
*/
public function isTelemetryStep(): bool
{
- return $this->_step === self::STEP_TELEMETRY;
+ return $this->step === self::STEP_TELEMETRY;
}
/**
*/
public function atGaletteInitStep(): void
{
- $this->_step = self::STEP_GALETTE_INIT;
+ $this->step = self::STEP_GALETTE_INIT;
}
/**
*/
public function isGaletteInitStep(): bool
{
- return $this->_step === self::STEP_GALETTE_INIT;
+ return $this->step === self::STEP_GALETTE_INIT;
}
/**
if (
isset($existing['db_type'])
- && $existing['db_type'] == $this->_db_type
+ && $existing['db_type'] == $this->db_type
&& isset($existing['db_host'])
- && $existing['db_host'] == $this->_db_host
+ && $existing['db_host'] == $this->db_host
&& isset($existing['db_port'])
- && $existing['db_port'] == $this->_db_port
+ && $existing['db_port'] == $this->db_port
&& isset($existing['db_user'])
- && $existing['db_user'] == $this->_db_user
+ && $existing['db_user'] == $this->db_user
&& isset($existing['pwd_db'])
- && $existing['pwd_db'] == $this->_db_pass
+ && $existing['pwd_db'] == $this->db_pass
&& isset($existing['db_name'])
- && $existing['db_name'] == $this->_db_name
+ && $existing['db_name'] == $this->db_name
&& isset($existing['prefix'])
- && $existing['prefix'] == $this->_db_prefix
+ && $existing['prefix'] == $this->db_prefix
) {
Analog::log(
'Config file is already up-to-date, nothing to do.',
Analog::INFO
);
- $this->_report[] = array(
+ $this->report[] = array(
'message' => _T("Config file already exists and is up to date"),
'res' => true
);
&& $fd = @fopen($conffile, 'w')
) {
$data = "<?php
-define('TYPE_DB', '" . $this->_db_type . "');
-define('HOST_DB', '" . $this->_db_host . "');
-define('PORT_DB', '" . $this->_db_port . "');
-define('USER_DB', '" . $this->_db_user . "');
-define('PWD_DB', '" . $this->_db_pass . "');
-define('NAME_DB', '" . $this->_db_name . "');
-define('PREFIX_DB', '" . $this->_db_prefix . "');
+define('TYPE_DB', '" . $this->db_type . "');
+define('HOST_DB', '" . $this->db_host . "');
+define('PORT_DB', '" . $this->db_port . "');
+define('USER_DB', '" . $this->db_user . "');
+define('PWD_DB', '" . $this->db_pass . "');
+define('NAME_DB', '" . $this->db_name . "');
+define('PREFIX_DB', '" . $this->db_prefix . "');
";
fwrite($fd, $data);
fclose($fd);
$ret['error'] = $str;
$error = true;
}
- $this->_report[] = $ret;
+ $this->report[] = $ret;
return !$error;
}
$models = new \Galette\Repository\PdfModels($zdb, $preferences, $login);
- $this->_error = false;
+ $this->error = false;
//Install preferences
$res = $preferences->installInit(
$res = $models->installInit(false);
$this->proceedReport(_T("PDF models"), $res);
- return !$this->_error;
+ return !$this->error;
} elseif ($this->isUpgrade()) {
$preferences = new Preferences($zdb);
$preferences->store();
if ($res instanceof \Exception) {
$ret['debug'] = $res->getMessage();
- $this->_error = true;
+ $this->error = true;
} else {
$ret['res'] = true;
}
- $this->_report[] = $ret;
+ $this->report[] = $ret;
}
/**
* Retrieve galette initialization report
*/
public function getInitializationReport(): array
{
- return $this->_report;
+ return $this->report;
}
/**
*/
public function atEndStep(): void
{
- $this->_step = self::STEP_END;
+ $this->step = self::STEP_END;
}
/**
*/
public function isEndStep(): bool
{
- return $this->_step === self::STEP_END;
+ return $this->step === self::STEP_END;
}
/**
*/
public function setInstalledVersion(?string $version): void
{
- $this->_installed_version = $version;
+ $this->installed_version = $version;
}
/**
*/
public function isStepPassed($step): bool
{
- return $this->_step > $step;
+ return $this->step > $step;
}
}