blob: ece3835c093f9f653030d28b64cd4b2a62238690 [file] [log] [blame]
<?php
/**
* 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("/home/data/httpd/eclipse-php-classes/system/dbconnection_bugs_ro.class.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/stats/hostname.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/common/buglist.class.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/common/project-info.class.php");
/**
* Top Ten Bugs of a Project
*
* This Class gets the Top Ten bugs or enhancements of an Eclipse Project, given its project key.
*
* @license http://www.eclipse.org/legal/epl-v10.html Eclipse Public License - v 1.0
* @example examples/project_bugs.php Example of <b>project_bugs.class.php</b>, using the Eclipse Visual Style, CSS and Layout
* @link /projects/common/doc/examples/project_bugs.php Example of this class working
* @author Eduardo A. Romero Gomez
*/
Class ProjectBugs extends BugList {
/**
* Returns the Top Ten most voted bugs on the Eclipse Bugzilla bug tracking system
*
* @param string $project The Project's key as in the Foundation Database
* @param int $type_of_bugs, if set to 1 this list will include only BUGS, if set to 2 it will only include ENHANCEMENTS, defaults to only bugs.
* @param boolean $overall If set to <em>true</em> the top ten list will include NEW, RESOLVED and CLOSED bugs, otherwise it will return only the NEW bug.
*/
function ProjectBugs($project, $type_of_bugs = 1, $overall = false)
{
$project = new ProjectInfo($project);
$num_products = $project->hasBugzillaProducts();
if($num_products > 0)
{
/* Get the products from the ProjectInfo object */
$products_clause = "WHERE ";
$first = true;
for($p = 0; $p < $num_products; $p++)
{
if($first)
{
$products_clause .= "name = '". $project->getBugzillaProduct($p) . "' ";
$first = false;
}
else
$products_clause .= "OR name = '". $project->getBugzillaProduct($p) . "' ";
}
$dbc = new DBConnectionBugs();
$dbh = $dbc->connect();
/* Get the product's id from the database */
$sql = "SELECT name, id FROM products " . $products_clause;
$result = mysql_query($sql, $dbh);
$products_clause = " ";
$first = true;
while($myrow = mysql_fetch_array($result))
{
if($first)
{
$products_clause .= "products.id ='" . $myrow["id"]."'";
$first = false;
}
else
$products_clause .= " OR products.id ='" . $myrow["id"]."'";
}
$result = null;
$myrow = null;
$_status = " AND NOT (
bugs.bug_status = \"RESOLVED\"
OR bugs.bug_status = \"VERIFIED\"
OR bugs.bug_status = \"CLOSED\"
) ";
$ToB = " AND NOT (bug_severity = 'enchancement') ";
if($type_of_bugs == 2)
$ToB = " AND (bug_severity = 'enchancement') ";
elseif($type_of_bugs == 1)
$ToB = " AND NOT (bug_severity = 'enchancement') ";
if ($overall)
{
$sql = "SELECT votes.bug_id, count(votes.vote_count) as total " .
"FROM `votes`, `products`,`bugs`" .
"WHERE products.id = bugs.product_id AND (".$products_clause .") $ToB ".
"GROUP BY bug_id " .
"ORDER BY total DESC " .
"LIMIT 0, 10";
}
else
{
$sql = "SELECT count(votes.vote_count) as total, votes.bug_id, bugs.bug_status " .
"FROM votes, bugs, products WHERE products.id = bugs.product_id AND bugs.bug_id = votes.bug_id " .
"AND (".$products_clause .")".
$_status. $ToB.
"GROUP BY bug_id " .
"ORDER BY total " .
"DESC LIMIT 0,10";
}
$result = mysql_query($sql, $dbh);
while($myrow = mysql_fetch_array($result))
{
$bug = new Bug($myrow["bug_id"]);
$bug->setVotes ($myrow["total"]);
$this->add($bug);
}
$dbh = null;
$dbc = null;
$result = null;
$myrow = null;
}
}
}
?>