diff --git a/includes/admin_edit_user_report.inc.php b/includes/admin_edit_user_report.inc.php new file mode 100644 index 0000000..d75558c --- /dev/null +++ b/includes/admin_edit_user_report.inc.php @@ -0,0 +1,30 @@ +getMessage()); + } +} else { + header('Location: ../index.php'); + die(); +} diff --git a/models/reports.inc.php b/models/reports.inc.php index 62f9486..3e26d7c 100644 --- a/models/reports.inc.php +++ b/models/reports.inc.php @@ -34,6 +34,15 @@ function get_all_video_reports(object $pdo): array $stmt->execute(); return $stmt->fetchAll(); } +// get all user reports +function get_all_user_reports(object $pdo): array +{ + // user_reports has fields: user_report_id, target_user_id, user_id, reason, reported_at, updated_at, status, target_user_id is foreign key to users table, user_id is foreign key to users table + $query = "SELECT user_reports.user_report_id, user_reports.target_user_id, user_reports.user_id, user_reports.reason, user_reports.reported_at, user_reports.updated_at, user_reports.status, users.username, target_user.username AS target_username FROM user_reports JOIN users ON user_reports.user_id = users.user_id JOIN users AS target_user ON user_reports.target_user_id = target_user.user_id"; + $stmt = $pdo->prepare($query); + $stmt->execute(); + return $stmt->fetchAll(); +} // update video report as admin function update_video_report(object $pdo, int $video_report_id, string $status): void @@ -44,3 +53,13 @@ function update_video_report(object $pdo, int $video_report_id, string $status): $stmt->bindParam(":video_report_id", $video_report_id, PDO::PARAM_INT); $stmt->execute(); } + +// update user report as admin +function update_user_report(object $pdo, int $user_report_id, string $status): void +{ + $query = "UPDATE user_reports SET status = :status, updated_at = CURRENT_TIMESTAMP WHERE user_report_id = :user_report_id"; + $stmt = $pdo->prepare($query); + $stmt->bindParam(":status", $status, PDO::PARAM_STR); + $stmt->bindParam(":user_report_id", $user_report_id, PDO::PARAM_INT); + $stmt->execute(); +} diff --git a/models/users.inc.php b/models/users.inc.php index c69e66e..0b2ef2c 100644 --- a/models/users.inc.php +++ b/models/users.inc.php @@ -44,3 +44,11 @@ function does_user_exist(object $pdo, int $user_id): bool $stmt->execute(['user_id' => $user_id]); return $stmt->fetch(PDO::FETCH_ASSOC) ? true : false; } + +// update user status +function update_user_status(object $pdo, int $user_id, string $updated_status): void +{ + $query = "UPDATE users SET is_active = :updated_status, updated_at = CURRENT_TIMESTAMP WHERE user_id = :user_id"; + $stmt = $pdo->prepare($query); + $stmt->execute(['updated_status' => $updated_status, 'user_id' => $user_id]); +} diff --git a/pages/admin_edit_user_report.php b/pages/admin_edit_user_report.php new file mode 100644 index 0000000..56a2f9a --- /dev/null +++ b/pages/admin_edit_user_report.php @@ -0,0 +1,96 @@ + + + + + +
+ + +Report ID | +Target User ID | +User ID | +Reason | +Reported At | +Updated At | +Status | +User | +Target User | +Actions | +
---|---|---|---|---|---|---|---|---|---|
No reports found | +|||||||||
= $report['user_report_id'] ?> | += $report['target_user_id'] ?> | += $report['user_id'] ?> | += $report['reason'] ?> | += $report['reported_at'] ?> | += $report['updated_at'] ?> | += $report['status'] ?> | += $report['username'] ?> | += $report['target_username'] ?> | ++ " class="btn btn-primary btn-sm update-btn"> + + | +