-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete_deploy.php
More file actions
35 lines (29 loc) · 1.37 KB
/
Copy pathcomplete_deploy.php
File metadata and controls
35 lines (29 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['project'])) {
require_once 'config.php';
$project = $_POST['project'];
$user_id = $_SESSION['user_id'];
$stmt = $db->prepare("SELECT status, last_user FROM deploy_status WHERE project = :project");
$stmt->bindParam(':project', $project);
$stmt->execute();
$status = $stmt->fetch(PDO::FETCH_ASSOC);
if ($status['last_user'] === $user_id) {
// Atualizar o status do projeto para "completed" no banco de dados
$updateStmt = $db->prepare("UPDATE deploy_status SET status = 'completed', last_user = 0 WHERE project = :project");
$updateStmt->bindParam(':project', $project);
$updateStmt->execute();
// Registrar a alteração no quadro de auditoria
$auditStmt = $db->prepare("INSERT INTO audit_log (project, status, user_id) VALUES (:project, :status, :user_id)");
$auditStmt->bindParam(':project', $project);
$auditStmt->bindValue(':status', 'Deploy concluído');
$auditStmt->bindParam(':user_id', $user_id);
$auditStmt->execute();
echo json_encode(['success' => true]);
} else {
echo json_encode(['success' => false, 'message' => 'Você não iniciou este deploy.']);
}
} else {
echo json_encode(['success' => false, 'message' => 'Requisição inválida.']);
}
?>