20/06
2018
a library used for control The Trac Project
ticket, (*1)
The Trac Project
1.0.* ~ 1.2.* ( >= 1.3 not tested)Trac XML-RPC Plugin
(https://trac-hacks.org/wiki/XmlRpcPlugin)<?php use Comoco\TracClientPhp\Client as TracClient; $api_url = "http://trac.local/login/jsonrpc"; $username = '<your username>'; $password = '<your password>'; $tracClient = new TracClient($api_url, $username, $password); $ticket_id = $tracClient->createTicket('my first ticket', 'ticket content', [ 'owner' => 'bob', 'cc' => 'alice, web', 'priority' => 'minor' ]); $tracClient->uploadAttachment($ticket_id, 'example.xml', 'is a example file', "/tmp/example.xml"); $tracClient->addComment($ticket_id, 'It is great!'); $tracClient->resolveTicket($ticket_id, 'ok', 'fixed')
get user own ticket ids, (*2)
$statuses
avaliable status could not same on different trac system (based on system setting)$ticket_ids = $tracClient->getUserTicketIds('bob', ['accepted', 'assigned'], 50);
get ticket information, (*3)
return data
could not same on different trac system (based on installed module)$ticket_id = 1; $ticket_info = $tracClient->getTicketInfo($ticket_id);
$attributes
could not same on different trac system (based on installed module)$ticket_id = $tracClient->createTicket('my first ticket', 'it is a example ticket', [ 'owner' => 'bob', 'cc' => 'alice, jack', 'priority' => 'minor' ]);
update ticket information, (*4)
$attributes
could not same on different trac system (based on installed module)$ticket_id = 1; $tracClient->updateTicket($ticket_id, 'change ticket content', [ 'summary' => 'my first ticket v2', 'description' => 'it is a example ticket v2', 'cc' => 'alice, jack, ellen' ]);
accept the ticket, (*5)
$ticket_id = 1; $tracClient->acceptTicket($ticket_id, 'accept the ticket');
reassign ticket to the user, (*6)
$ticket_id = 1; $tracClient->reassignUser($ticket_id, 'alice', 'assign ticket to alice');
resolve the ticket, (*7)
$option
avaliable option could not same on different trac system (it is different based on trac setting)$ticket_id = 1; $tracClient->resolveTicket($ticket_id, 'close ticket', 'fixed');
reopen the ticket, (*8)
$ticket_id = 1; $tracClient->reopenTicket($ticket_id, 'reopen the ticket');
delete the ticket, (*9)
$ticket_id = 1; $tracClient->deleteTicket($ticket_id);
add comment, (*10)
$ticket_id = 1; $tracClient->addComment($ticket_id, 'it is great');
get comments, (*11)
$ticket_id = 1; $comments = $tracClient->getComments($ticket_id);
list the ticket's attachments, (*12)
$ticket_id = 1; $attachments = $tracClient->listAttachments($ticket_id);
upload a attachment to the ticket, (*13)
$ticket_id = 1; $filename = 'example.xml'; $description = 'demo xml'; $file_path = '/tmp/example.xml'; $tracClient->uploadAttachment($ticket_id, $filename, $description, $file_path)
download the attachment from the ticket, (*14)
$ticket_id = 1; $filename = 'example.xml'; $save_path = '/tmp/example.xml'; $tracClient->downloadAttachment($ticket_id, $filename, $save_path)
delete the attachment from ticket, (*15)
$ticket_id = 1; $filename = 'example.xml'; $tracClient->deleteAttachment($ticket_id, $filename)