247 lines
6.1 KiB
PHP
247 lines
6.1 KiB
PHP
<?php
|
|
|
|
ini_set('soap.wsdl_cache_enabled', 0);
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
|
|
class mantisWsdlClient
|
|
{
|
|
private $mtSrvClient;
|
|
private $mtSrvUser='';
|
|
private $mtSrvPass='';
|
|
|
|
public function __construct($mtSrvWsdlUrl, $mtSrvUser, $mtSrvPass)
|
|
{
|
|
$this->mtSrvUser=$mtSrvUser;
|
|
$this->mtSrvPass=$mtSrvPass;
|
|
try {
|
|
$this->mtSrvClient = new soapclient($mtSrvWsdlUrl);
|
|
} catch(Soapfault $e) {
|
|
echo "Erreur : URL Soap WSDL Mantis invalide";
|
|
exit();
|
|
}
|
|
}
|
|
|
|
/** Ajout d'une note
|
|
* @param unknown_type $issue_id
|
|
* @param unknown_type $reporter_id
|
|
* @param unknown_type $notes
|
|
*/
|
|
public function add_issue_note($issue_id,$reporter_id,$notes)
|
|
{
|
|
$view_state = new StdClass;
|
|
$view_state->id =1;
|
|
|
|
$note = new StdClass;
|
|
$note->id =$issue_id;
|
|
|
|
$note->reporter =$reporter_id;
|
|
$note->text =$notes;
|
|
$note->view_state=$view_state;
|
|
$note->date_submitted =date('d-m-Y');
|
|
$note->last_modified =date('d-m-Y');
|
|
|
|
try{
|
|
$this->mtSrvClient->mc_issue_note_add($this->mtSrvUser,$this->mtSrvPass,$issue_id,$note);
|
|
} catch (SoapFault $exception) {
|
|
// handle the fault
|
|
print_r($exception);
|
|
//var_dump(libxml_get_last_error());
|
|
echo "Problem occured when adding issue for the planner title: ".$summary."<br>";
|
|
}
|
|
}
|
|
|
|
// Add issue function
|
|
// parameter @projectid
|
|
public function addissue($projecId,$reporterid,$summary,$description,$priority=0)
|
|
{
|
|
//$client = new soapclient(WSDL_URL);
|
|
$issue = new StdClass;
|
|
|
|
$project = new StdClass;
|
|
$project->id =$projecId;// 15;
|
|
|
|
$reporter = new StdClass;
|
|
$reporter->id =$reporterid;// 24;
|
|
|
|
/*$handler = new StdClass;
|
|
if(trim($handlerid)=="" or trim($handlerid)=="0" )
|
|
$handler->id =$reporterid;// 24;
|
|
else
|
|
$handler->id =$handlerid;// 24;
|
|
|
|
// echo "HAND: ".$handler->id."<br><br>";
|
|
*/
|
|
$issue->project = $project;
|
|
$issue->reporter = $reporter;
|
|
//$issue->handler = $handler;
|
|
$issue->summary = $summary;//"testiing subject";
|
|
$issue->description =$description;//"testiing";
|
|
|
|
if($priority*1==0)
|
|
$issue->priority = 30;
|
|
else
|
|
$issue->priority = $prority;
|
|
|
|
/*if($eta=="" or $eta=="0" )
|
|
$issue->eta = 10;
|
|
else
|
|
$issue->eta = $eta;
|
|
*/
|
|
$issue->severity = 50;
|
|
$issue->status = 10;
|
|
$issue->reproducibility = 70;//10;
|
|
|
|
//$issue->resolution = 10;
|
|
|
|
$issue->projection = 10;
|
|
|
|
$issue->view_state = 10;
|
|
$issue->category = "";
|
|
|
|
$issue->additional_information =date('d-m-Y: H:i:s');
|
|
|
|
try {
|
|
$response_issue_id=$this->mtSrvClient->mc_issue_add($this->mtSrvUser,$this->mtSrvPass,$issue); // add Task
|
|
return $response_issue_id;
|
|
} catch (SoapFault $exception) {
|
|
// handle the fault
|
|
print_r($exception);
|
|
//var_dump(libxml_get_last_error());
|
|
echo "Problem occured when adding issue for the planner title: ".$summary."<br>";
|
|
}
|
|
/*POSTDATA =
|
|
name="bug_report_token"
|
|
name="m_id" 0
|
|
name="project_id" 37
|
|
name="category"
|
|
name="reproducibility" 70
|
|
name="severity" 50
|
|
name="priority" 30
|
|
name="profile_id"
|
|
name="platform"
|
|
name="os"
|
|
name="os_build"
|
|
name="build"
|
|
name="handler_id" 0
|
|
name="summary" Siren 450175179 Bilan du 31/12/2009
|
|
name="description" Poste DO non saisit
|
|
name="steps_to_reproduce"
|
|
name="additional_info"
|
|
name="max_file_size" 2000000
|
|
name="file"; filename="" Content-Type: application/octet-stream
|
|
name="view_state" 10
|
|
*/
|
|
}
|
|
|
|
function getProjectIssues($projecId) {
|
|
if ($this->checkProjectid($projecId)) {
|
|
try {
|
|
$resfound=$this->mtSrvClient->mc_project_get_issues($this->mtSrvUser,$this->mtSrvPass,$projecId);
|
|
} catch(Exception $e) {
|
|
echo "<br>Invalid Login credentials (wsdl_config.php) or ProjectID .<br>";
|
|
return false;
|
|
}
|
|
return $resfound;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//Function accpets username as argument and returns userid if exists
|
|
/*
|
|
public function checkUserid($username)
|
|
|
|
{
|
|
|
|
$result = mysql_query("SELECT * FROM mantis_user_table where username='".$username."'") or die(mysql_error());
|
|
|
|
$row = mysql_fetch_array( $result );
|
|
|
|
// Print out the contents of the entry
|
|
|
|
if(sizeof($row>0))
|
|
|
|
return $row['id'];
|
|
|
|
else
|
|
|
|
return 0;
|
|
}*/
|
|
|
|
//insert custom fields startdate,finsihdate,percentage complete
|
|
/*
|
|
public function mantis_insert_customfield($field_id,$bug_id,$value)
|
|
{
|
|
$sql="insert into mantis_custom_field_string_table (field_id,bug_id,value) values ('".$field_id."','".$bug_id."','".$value."')";
|
|
mysql_query($sql);
|
|
}
|
|
*/
|
|
|
|
|
|
//update ETA field
|
|
/*
|
|
public function mantis_update_bugfield($bug_id,$bugfield,$bugvalue)
|
|
{
|
|
$sql="update mantis_bug_table set ".$bugfield."='".$bugvalue."' where id=".$bug_id;
|
|
//echo $sql;
|
|
mysql_query($sql);
|
|
}
|
|
*/
|
|
|
|
/** Le projet existe t il dans Mantis ?
|
|
**
|
|
** @param $projecId
|
|
**/
|
|
public function checkProjectid($projecId)
|
|
{
|
|
try {
|
|
$resfound=$this->mtSrvClient->mc_project_get_categories($this->mtSrvUser,$this->mtSrvPass, $projecId );
|
|
}
|
|
catch(Exception $e)
|
|
{
|
|
echo "<br>Invalid Login credentials (wsdl_config.php) or ProjectID .<br>";
|
|
return false;
|
|
}
|
|
// print_r($resfound);
|
|
return true;
|
|
}
|
|
|
|
public function addirelationship($relationType,$issue_id,$target_id)
|
|
{
|
|
//relation object class---------------START
|
|
$relation = new StdClass;
|
|
|
|
if($relationType=="p")
|
|
{
|
|
//parent of
|
|
$relation->id = 2;
|
|
$relation->name = "parent of";
|
|
}
|
|
else
|
|
{
|
|
//child of
|
|
$relation->id = 3;
|
|
$relation->name = "child of";
|
|
}
|
|
|
|
//relation object class---------------END
|
|
//relationship object class-----------------------START
|
|
$relationship = new StdClass;
|
|
$relationship->id= 3;
|
|
$relationship->type=$relation;
|
|
$relationship->target_id= $target_id;
|
|
//relationship object class-----------------------END
|
|
|
|
//$response_issue_id=56;
|
|
try{
|
|
$response=$this->mtSrvClient->mc_issue_relationship_add($this->mtSrvUser,$this->mtSrvPass,$issue_id,$relationship); // add relationshiip
|
|
} catch (SoapFault $exception) {
|
|
//print_r($exception);
|
|
// handle the fault
|
|
//echo "Problem occured when configuring relationship for the Ticket id: ".$issue_id."<br>";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
?>
|