style: auto-fix 1340 phpcs PSR-12 violations via phpcbf; exclude MissingNamespace and SideEffects
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Export Tickets API
|
||||
*
|
||||
@@ -23,7 +24,9 @@ try {
|
||||
require_once dirname(__DIR__) . '/models/AuditLogModel.php';
|
||||
|
||||
// Check authentication via session
|
||||
if (session_status() === PHP_SESSION_NONE) { session_start(); }
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
if (!isset($_SESSION['user']) || !isset($_SESSION['user']['user_id'])) {
|
||||
header('Content-Type: application/json');
|
||||
http_response_code(401);
|
||||
@@ -126,7 +129,6 @@ try {
|
||||
|
||||
fclose($output);
|
||||
exit;
|
||||
|
||||
} elseif ($format === 'json') {
|
||||
// JSON Export
|
||||
header('Content-Type: application/json');
|
||||
@@ -135,7 +137,7 @@ try {
|
||||
echo json_encode([
|
||||
'exported_at' => date('c'),
|
||||
'total_tickets' => count($tickets),
|
||||
'tickets' => array_map(function($t) {
|
||||
'tickets' => array_map(function ($t) {
|
||||
return [
|
||||
'ticket_id' => $t['ticket_id'],
|
||||
'title' => $t['title'],
|
||||
@@ -152,7 +154,6 @@ try {
|
||||
}, $tickets)
|
||||
], JSON_PRETTY_PRINT);
|
||||
exit;
|
||||
|
||||
} elseif ($format === 'full') {
|
||||
// Full single-ticket export: ticket + all comments + audit timeline
|
||||
if (!$singleId) {
|
||||
@@ -177,7 +178,7 @@ try {
|
||||
$rawComments = $commentModel->getCommentsByTicketId($ticket['ticket_id'], false);
|
||||
$timeline = $auditLogModel->getTicketTimeline((string)$ticket['ticket_id']);
|
||||
|
||||
$comments = array_map(function($c) {
|
||||
$comments = array_map(function ($c) {
|
||||
return [
|
||||
'comment_id' => $c['comment_id'],
|
||||
'author' => $c['display_name'] ?? $c['username'] ?? 'Unknown',
|
||||
@@ -188,7 +189,7 @@ try {
|
||||
];
|
||||
}, $rawComments);
|
||||
|
||||
$timelineOut = array_map(function($row) {
|
||||
$timelineOut = array_map(function ($row) {
|
||||
$details = $row['details'];
|
||||
if (is_string($details)) {
|
||||
$details = json_decode($details, true) ?? $details;
|
||||
@@ -228,14 +229,12 @@ try {
|
||||
'timeline' => $timelineOut,
|
||||
], JSON_PRETTY_PRINT);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
header('Content-Type: application/json');
|
||||
http_response_code(400);
|
||||
echo json_encode(['success' => false, 'error' => 'Invalid format. Use csv, json, or full.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Export tickets API error: " . $e->getMessage());
|
||||
header('Content-Type: application/json');
|
||||
|
||||
Reference in New Issue
Block a user