blob: ab4295e4011c0cee89debb241d699c0e104a28ee [file]
<?php
/**
* This REST page, returns the XML representation of a list of bug for a given project. This information used by the client class
* counterpart <code>common/project-bugs.class.php</code>
*
* I takes the <b>project key</b> as <i>required</i> parameter. Optionally you can pass the <b>type</b> to get one of the two
* different types of lists avaliable:<br>
* <ol>
* <li><b>type = 1</b>, for Most Hated Bugs. This is the default</li>
* <li><b>type = 2</b>, for Most Wanted Enhancements</li>
* </ol>
*
* The list includes only NEW bugs, unless you add <b>overall</b>, in which case it will return NEW, CLOSED and RESOLVED bugs.
* <br><br>
* for example: <br>
* <samp>
* http://eclipse.org/projects/web-api/project-bug.php?project=birt
* </samp><br/>
* Will return Most Hated NEW bugs.<br><br>
* <samp>
* http://eclipse.org/projects/web-api/project-bug.php?project=eclipse&type=2
* </samp><br/>
* Will return Most Wanted Enhancements.<br><br>
* <samp>
* http://eclipse.org/projects/web-api/project-bug.php?project=eclipse&type=1&overall
* </samp><br/>
* Will return ALL (NEW, CLOSED and RESOLVED) Most Hated bugs.<br><br>
* in case of *invalid* <var>project</var> it will return an empty list.
*
* @package rest-api
* @license http://www.eclipse.org/legal/epl-v10.html Eclipse Public License - v 1.0
* @author Eduardo A. Romero
*/
/**
* THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (http://www.eclipse.org/legal/epl-v10.html).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
*
*/
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/common/server/project_bugs-server.class.php");
header("Content-type: text/xml");
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
$tainted_key = $_REQUEST['project'];
if( strlen($tainted_key) > 0 && preg_match( "/^([\w\.]*)$/", $tainted_key, $matches ) > 0)
{
$key = $matches[1];
$type_of_query = 1;
if(isset($_REQUEST['type']) && is_numeric($_REQUEST['type']) && ($_REQUEST['type'] == 1 || $_REQUEST['type'] == 2))
$type_of_query = $_REQUEST['type'];
$overall = false;
if(isset($_REQUEST['overall']) && strlen($_REQUEST['overal']) > 0 && $_REQUEST['overall'] != "false")
$overall = true;
$project_bugs = new ProjectBugs_Server( $key, $type_of_query, $overall );
?><project-bugs>
<type><?= ( $type_of_query == 2 ) ? "enhancements" : "bugs" ?></type><?php
for($b = 0; $b < $project_bugs->hasBugs(); $b++)
{
$bug = $project_bugs->getBug($b);
$bug_id = $bug->getBugId();
?>
<bug><?= $bug_id ?></bug>
<?
}
?></project-bugs><?
}
else
{
?>
<project-bugs>
<error>Invalid project key: <?= urlencode($temp) ?></error>
</project-bugs>
<?
}
?>