Fix hidden/visible admin status

This commit is contained in:
Matteo Gheza 2020-05-29 11:35:41 +02:00
parent 24d5821357
commit afbbf196c8
2 changed files with 5 additions and 4 deletions

View File

@ -219,7 +219,7 @@ if(!is_cli()){
</p>
<?php
} else if ($_POST["step"] == "5") {
initOptions($_POST["user_name"], $_POST["admin_visible"], $_POST["admin_password"], $_POST["admin_email"], $_POST["owner"]);
initOptions($_POST["user_name"], isset($_POST["admin_visible"]), $_POST["admin_password"], $_POST["admin_email"], $_POST["owner"]);
?>
<h1 class="screen-reader-text">Installazione terminata con successo.</h1>
<p>Ottimo lavoro, amico! Hai completato l'installazione. Ora Allerta può funzionare correttamente. Adesso è il momento di…</p>

View File

@ -365,11 +365,12 @@ function initOptions($name, $visible, $password, $report_email, $owner){
$userId = $auth->register($report_email, $password, $name);
$auth->admin()->addRoleForUserById($userId, Role::SUPER_ADMIN);
$prep = $connection->prepare("
INSERT INTO `".$prefix."_profiles` (`id`) VALUES (NULL);
INSERT INTO `".$prefix."_profiles` (`id`, `hidden`) VALUES (NULL, :hidden);
INSERT INTO `".$prefix."_options` (`id`, `name`, `value`, `enabled`, `created_time`, `last_edit`, `user_id`) VALUES ('1', 'report_email', :report_email, '1', current_timestamp(), current_timestamp(), '1');
INSERT INTO `".$prefix."_options` (`id`, `name`, `value`, `enabled`, `created_time`, `last_edit`, `user_id`) VALUES ('2', 'owner', :owner, '1', current_timestamp(), current_timestamp(), '1');");
$prep->bindParam(':report_email', $report_email, PDO::PARAM_STR);
$prep->bindParam(':owner', $owner, PDO::PARAM_STR);
$prep->bindValue(':hidden', ($visible ? 0 : 1), PDO::PARAM_INT);
$prep->bindValue(':report_email', $report_email, PDO::PARAM_STR);
$prep->bindValue(':owner', $owner, PDO::PARAM_STR);
$prep->execute();
} catch (Exception $e) {
if(is_cli()){