fixed bug where you can't change the station which a station account belongs to

This commit is contained in:
Grisu
2022-09-15 10:32:13 +02:00
parent 83c62d0015
commit 506982f1b1
2 changed files with 18 additions and 1 deletions

View File

@@ -23,13 +23,19 @@
} }
if($user['user_group'] != $user_group) { if($user['user_group'] != $user_group) {
if($_POST['user_group'] == "station") { if($user_group == "station") {
change_user_group($con, $id, $user_group, $bind_station); change_user_group($con, $id, $user_group, $bind_station);
} else { } else {
change_user_group($con, $id, $user_group, NULL); change_user_group($con, $id, $user_group, NULL);
} }
} }
if($user['s_id'] != $bind_station) {
if ($user_group == "station") {
change_s_id($con, $id, $bind_station);
}
}
if(!empty($password)) { if(!empty($password)) {
$phash = generate_password_hash($password, $user['salt']); $phash = generate_password_hash($password, $user['salt']);
change_password($con, $id, $phash); change_password($con, $id, $phash);

View File

@@ -260,6 +260,17 @@ function change_password($con, $id, $password) {
} }
} }
function change_s_id($con, $id, $s_id) {
try {
$stmt = $con->prepare("UPDATE users SET s_id = ? WHERE id= ?");
$stmt->bindParam(1, $s_id, PDO::PARAM_INT);
$stmt->bindParam(2, $id, PDO::PARAM_STR);
$stmt->execute();
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
function get_result($con, $m_id, $s_id) { function get_result($con, $m_id, $s_id) {
try { try {
$stmt = $con->prepare("SELECT P.*, M.name as name, M.feuerwehr as feuerwehr FROM Punkte P, Mannschaft M WHERE M.m_id = P.m_id AND P.m_id = ? AND P.s_id = ?"); $stmt = $con->prepare("SELECT P.*, M.name as name, M.feuerwehr as feuerwehr FROM Punkte P, Mannschaft M WHERE M.m_id = P.m_id AND P.m_id = ? AND P.s_id = ?");