Skip to content

Instantly share code, notes, and snippets.

@kurokikaze
Created March 21, 2011 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurokikaze/35722fd505f112facc01 to your computer and use it in GitHub Desktop.
Save kurokikaze/35722fd505f112facc01 to your computer and use it in GitHub Desktop.
Отрисовка графа зависимостей для багов из Mantis
<?php
error_reporting(E_ALL);
require_once('nusoap-0.9.5/lib/nusoap.php');
$WSDL_POINT = "https://mantis.example.com/api/soap/mantisconnect.php";
$username = 'username';
$password = 'password';
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$useCURL = isset($_POST['usecurl']) ? $_POST['usecurl'] : '0';
$client = new nusoap_client($WSDL_POINT, false,
$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
echo 'err1 [label="' . $client->getDebug() . '"];';
exit();
}
$client->setUseCurl($useCURL);
$params = array(
'username' => $username,
'password' => $password,
'project_id' => 42, // id проекта
'filter_id' => 987, // id фильтра
'page_number' => 1,
'per_page' => 400 // everything
);
$result = $client->call('mc_filter_get_issues', $params, 'https://mantis.example.com/api/soap/mantisconnect.php', 'http://soap.amazon.com');
echo 'digraph issues {' . "\n";
echo ' rankdir=LR' . "\n";
foreach ($result as $num => $issue) {
echo ' ' . $issue['id'] . ' [label="' . $issue['id'] . ': ' . $issue['summary'] . '"]' . ";\n";
echo ' ' . $issue['id'] . ' [shape="box"]' . ";\n";
// Assigned to QA
if (array_key_exists('handler', $issue) && ($issue['handler']['name'] == 'qa1' || $issue['handler']['name'] == 'qa2' || $issue['handler']['name'] == 'qa3')) {
echo ' ' . $issue['id'] . ' [style="dotted"]' . ";\n";
}
// Priority
switch ($issue['priority']['name']) {
case 'urgent':
echo ' ' . $issue['id'] . ' [color="red"]' . ";\n";
break;
case 'high':
echo ' ' . $issue['id'] . ' [color="yellow"]' . ";\n";
break;
case 'normal':
echo ' ' . $issue['id'] . ' [color="green"]' . ";\n";
break;
case 'low':
echo ' ' . $issue['id'] . ' [color="gray"]' . ";\n";
break;
}
// Связи
if (!empty($issue['relationships'])) {
foreach ($issue['relationships'] as $relationship) {
switch ($relationship['type']['name']) {
case 'child of':
echo ' ' . $relationship['target_id'] . ' -> ' . $issue['id'] . ";\n";
break;
case 'parent of':
echo ' ' . $issue['id'] . ' -> ' . $relationship['target_id'] . ";\n";
break;
default:
echo ' ' . $issue['id'] . ' -> ' . $relationship['target_id'] . ";\n";
break;
}
}
}
}
echo '}';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment