Files
itflow/api/v1/ticket_ccs/read.php

35 lines
1.1 KiB
PHP

<?php
/*
* API - Ticket CCs - Read
* GET /api/v1/ticket_ccs/read.php
*
* A ticket's CCs - the people copied in on every email about it, whose replies
* count as the client's - as they were added, or one CC.
*
* ticket_id This ticket's CCs - this or ticket_cc_id is needed
* ticket_cc_id Just this CC
* client_id optional - Only if the ticket is this client's
*/
require_once '../validate_api_key.php';
require_once '../require_get_method.php';
$ticket_id = intval($_GET['ticket_id'] ?? 0);
$cc_id = intval($_GET['ticket_cc_id'] ?? 0);
if (!$ticket_id && !$cc_id) {
http_response_code(400);
$return_arr['success'] = "False";
$return_arr['message'] = "ticket_ccs/read.php needs ticket_id or ticket_cc_id.";
echo json_encode($return_arr);
exit();
}
$sql = mysqli_query($mysqli, "SELECT ticket_ccs.*, ticket_prefix, ticket_number, ticket_client_id
FROM ticket_ccs JOIN tickets ON ticket_id = ticket_cc_ticket_id
WHERE " . ($cc_id ? "ticket_cc_id = $cc_id" : "ticket_cc_ticket_id = $ticket_id") . " " . apiClientScopeSql('ticket_client_id') . "
ORDER BY ticket_cc_id");
// Output
require_once "../read_output.php";