I am in desperate need of creating a plugin that would enable me and my users to create tickets and adding comments to them via JSON@POST.
In other words. I want to be able to send a POST request containing a JSON to plugin page. I want this page to create a ticket/bug and necessary comments.
I made a upload.php that is available from my plugin dir. It contains:
Code: Select all
<?php
if(isset($_POST['ticket'])) {
$ticket = json_decode($_POST['ticket']);
if($ticket) {
$insert = "insert into " . plugin_table( "alerts" );
$insert .= " set ";
...
makeTicket($ticket);
Code: Select all
function makeTicket($ticket) {
$a_alarm = 37;
$a_adm = 31;
$a_awaria = 40;
$alarmy = new Alarmy();
if(in_array($ticket->typAlarmu,$alarmy->low)) {
$now = date("Y-m-d H:i:s");
$summary = 'Raport dzienny, alarmy niskie, ' . $now;
$bug = myBug($a_alarm,$summary);
$bugId = $bug->create();
$f_private = false;
$f_time_tracking = '0:00';
$f_bugnote_text = 'stuff';
$noteId = bugnote_add( $bugId, $f_bugnote_text, $f_time_tracking, $f_private, 0 );
}
}
Code: Select all
function myBug($category, $summary) {
$bug = new BugData;
$bug->build = '';
$bug->platform = '';
$bug->os = '';
$bug->os_build = '';
$bug->version = '';
$bug->profile_id = 0;
$bug->handler_id = 0;
$bug->view_state = 10; //gpc_get_int( 'view_state', config_get( 'default_bug_view_status' ) );//10;
$bug->project_id = 2;
$bug->reporter_id = 1;
$bug->duplicate_id = 0;
$bug->sponsorship_total = 0;
$bug->sticky = 0;
$bug->category_id = $category;
$bug->reproducibility = 70; //gpc_get_int( 'reproducibility', config_get( 'default_bug_reproducibility' ) );//70;
$bug->severity = 50; //gpc_get_int( 'severity', config_get( 'default_bug_severity' ) );//50;
$bug->priority = 30; //gpc_get_int( 'priority', config_get( 'default_bug_priority' ) );//30;
$bug->projection = 10; //gpc_get_int( 'projection', config_get( 'default_bug_projection' ) );//10;
$bug->eta = 10; //gpc_get_int( 'eta', config_get( 'default_bug_eta' ) );//10;
$bug->resolution = 10; //config_get( 'default_bug_resolution' );//10;
$bug->status = 10; //config_get( 'bug_submit_status' );//10;
$bug->summary = $summary; //'Alarm średni, ' . $ticket->nazwaAlarmu . ', #(' . $ticket->identyfikator . ')' ;
$bug->description = $summary; //'Alarm średni, ' . $ticket->nazwaAlarmu . ', #(' . $ticket->identyfikator . ')' ;
$bug->steps_to_reproduce = '';
$bug->additional_information = '';
$bug->due_date = 1;
return $bug;
}
Can this be completed in another way ? i.e. Is there some kind of API for creating a bug?