CSS fixes: - Fix [ ] brackets appearing below button text by replacing display:inline-flex with display:inline-block + white-space:nowrap on .btn — removes cross-browser flex pseudo-element inconsistency as root cause - Remove conflicting .btn::before ripple block (position:absolute was overriding bracket content positioning) - Remove overflow:hidden from .btn which was clipping bracket content - Fix body::after duplicate rule causing GPU layer blink (second position:fixed rule re-created compositor layer, overriding display:none suppression) - Replace all transition:all with scoped property transitions in dashboard.css, ticket.css, base.css (prevents full CSS property evaluation on every hover) - Convert pulse-warning/pulse-critical keyframes from box-shadow to opacity animation (GPU-composited, eliminates CPU repaints at 60fps) - Fix mobile *::before/*::after blanket content:none rule — now targets only decorative frame glyphs, preserving button brackets and status indicators - Remove --terminal-green-dim override that broke .lt-btn hover backgrounds JS fixes: - Fix all lt.lt.toast.* double-prefix instances in dashboard.js - Add null guard before .appendChild() on bulkAssignUser select - Replace all remaining emoji with terminal bracket notation (dashboard.js, ticket.js, markdown.js) - Migrate all toast.*() shim calls to lt.toast.* across all JS files View fixes: - Remove hardcoded [ ] brackets from .btn buttons (CSS now adds them) - Replace all emoji with terminal bracket notation in all views and admin views - Add missing CSP nonces to AuditLogView.php and UserActivityView.php script tags - Bump CSS version strings to ?v=20260319b for cache busting Security fixes: - update_ticket.php: add authorization check (non-admins can only edit their own or assigned tickets) - add_comment.php: validate and cast ticket_id to integer with 400 response - clone_ticket.php: fix unconditional session_start(), add ticket ID validation, add internal ticket access check - bulk_operation.php: add HTTP 401/403 status codes on auth failures - upload_attachment.php: fix missing $conn arg in AttachmentModel constructor - assign_ticket.php: add ticket existence check and permission verification Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
124 lines
3.7 KiB
PHP
124 lines
3.7 KiB
PHP
<?php
|
|
// Apply rate limiting
|
|
require_once dirname(__DIR__) . '/middleware/RateLimitMiddleware.php';
|
|
RateLimitMiddleware::apply('api');
|
|
|
|
session_start();
|
|
require_once dirname(__DIR__) . '/config/config.php';
|
|
require_once dirname(__DIR__) . '/helpers/Database.php';
|
|
require_once dirname(__DIR__) . '/models/BulkOperationsModel.php';
|
|
require_once dirname(__DIR__) . '/models/TicketModel.php';
|
|
require_once dirname(__DIR__) . '/models/AuditLogModel.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
// Check authentication
|
|
if (!isset($_SESSION['user']) || !isset($_SESSION['user']['user_id'])) {
|
|
http_response_code(401);
|
|
echo json_encode(['success' => false, 'error' => 'Not authenticated']);
|
|
exit;
|
|
}
|
|
|
|
// CSRF Protection
|
|
require_once dirname(__DIR__) . '/middleware/CsrfMiddleware.php';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$csrfToken = $_SERVER['HTTP_X_CSRF_TOKEN'] ?? '';
|
|
if (!CsrfMiddleware::validateToken($csrfToken)) {
|
|
http_response_code(403);
|
|
echo json_encode(['success' => false, 'error' => 'Invalid CSRF token']);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// Check admin status - bulk operations are admin-only
|
|
$isAdmin = $_SESSION['user']['is_admin'] ?? false;
|
|
if (!$isAdmin) {
|
|
http_response_code(403);
|
|
echo json_encode(['success' => false, 'error' => 'Admin access required']);
|
|
exit;
|
|
}
|
|
|
|
// Get request data
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
$operationType = $data['operation_type'] ?? null;
|
|
$ticketIds = $data['ticket_ids'] ?? [];
|
|
$parameters = $data['parameters'] ?? null;
|
|
|
|
// Validate input
|
|
if (!$operationType || empty($ticketIds)) {
|
|
echo json_encode(['success' => false, 'error' => 'Operation type and ticket IDs required']);
|
|
exit;
|
|
}
|
|
|
|
// Validate ticket IDs are integers
|
|
foreach ($ticketIds as $ticketId) {
|
|
if (!is_numeric($ticketId)) {
|
|
echo json_encode(['success' => false, 'error' => 'Invalid ticket ID format']);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// Use centralized database connection
|
|
$conn = Database::getConnection();
|
|
|
|
$bulkOpsModel = new BulkOperationsModel($conn);
|
|
$ticketModel = new TicketModel($conn);
|
|
|
|
// Verify user can access all tickets in the bulk operation
|
|
// (Admins can access all, but this is defense-in-depth)
|
|
$accessibleTicketIds = [];
|
|
$inaccessibleCount = 0;
|
|
$tickets = $ticketModel->getTicketsByIds($ticketIds);
|
|
|
|
foreach ($ticketIds as $ticketId) {
|
|
$ticketId = trim($ticketId);
|
|
$ticket = $tickets[$ticketId] ?? null;
|
|
|
|
if ($ticket && $ticketModel->canUserAccessTicket($ticket, $_SESSION['user'])) {
|
|
$accessibleTicketIds[] = $ticketId;
|
|
} else {
|
|
$inaccessibleCount++;
|
|
}
|
|
}
|
|
|
|
if (empty($accessibleTicketIds)) {
|
|
echo json_encode(['success' => false, 'error' => 'No accessible tickets in selection']);
|
|
exit;
|
|
}
|
|
|
|
// Use only accessible ticket IDs
|
|
$ticketIds = $accessibleTicketIds;
|
|
|
|
// Create bulk operation record
|
|
$operationId = $bulkOpsModel->createBulkOperation($operationType, $ticketIds, $_SESSION['user']['user_id'], $parameters);
|
|
|
|
if (!$operationId) {
|
|
echo json_encode(['success' => false, 'error' => 'Failed to create bulk operation']);
|
|
exit;
|
|
}
|
|
|
|
// Process the bulk operation
|
|
$result = $bulkOpsModel->processBulkOperation($operationId);
|
|
|
|
$conn->close();
|
|
|
|
if (isset($result['error'])) {
|
|
echo json_encode([
|
|
'success' => false,
|
|
'error' => $result['error']
|
|
]);
|
|
} else {
|
|
$message = "Bulk operation completed: {$result['processed']} succeeded, {$result['failed']} failed";
|
|
if ($inaccessibleCount > 0) {
|
|
$message .= " ($inaccessibleCount skipped - no access)";
|
|
}
|
|
echo json_encode([
|
|
'success' => true,
|
|
'operation_id' => $operationId,
|
|
'processed' => $result['processed'],
|
|
'failed' => $result['failed'],
|
|
'skipped' => $inaccessibleCount,
|
|
'message' => $message
|
|
]);
|
|
}
|