| <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php"); require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php"); require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php"); $App = new App(); $Nav = new Nav(); $Menu = new Menu(); include($App->getProjectCommon()); # All on the same line to unclutter the user's desktop' | |
| /******************************************************************************* | |
| * Copyright (c) 2009 Eclipse Foundation and others. | |
| * All rights reserved. This program and the accompanying materials | |
| * are made available under the terms of the Eclipse Public License v1.0 | |
| * which accompanies this distribution, and is available at | |
| * http://www.eclipse.org/legal/epl-v10.html | |
| * | |
| * Contributors: | |
| * Eclipse Foundation- initial API and implementation | |
| *******************************************************************************/ | |
| require_once(dirname(__FILE__) . "/../classes/debug.php"); | |
| require_once(dirname(__FILE__) . "/../classes/CQ.class.php"); | |
| function dump_project_cqs(&$projectIds) { | |
| $cqs = find_cqs(); | |
| foreach($cqs as $cq) { | |
| if (!in_array($cq->project, $projectIds)) continue; | |
| if ($cq->isContribution()) continue; | |
| if (!$cq->isThirdParty()) continue; | |
| if ($cq->isUnused()) dump_cq($cq, 'unused'); | |
| else if ($cq->isActive()) dump_cq($cq, 'active'); | |
| else if ($cq->isPrereq()) dump_cq($cq, 'prereq'); | |
| else if ($cq->isPending()) dump_cq($cq, 'pending'); | |
| } | |
| } | |
| function dump_cq(&$cq, $state) { | |
| $id = $cq->getId(); | |
| $description = htmlentities($cq->getDescription(), ENT_COMPAT | ENT_XML1); | |
| $license = htmlentities($cq->getLicense(), ENT_COMPAT | ENT_XML1); | |
| $use = implode(' ', getKeywordsForCq($cq)); | |
| echo "<iplog:cq id=\"$id\" description=\"$description\" license=\"$license\" use=\"$use\" state=\"$state\"/>\n"; | |
| } | |
| /** | |
| * @param CQ $cq | |
| */ | |
| function getKeywordsForCq($cq) { | |
| if ($cq->isWorksWith()) return array('workswith'); | |
| if ($cq->isExemptPrereq()) return array('exempt_prereq'); | |
| $keywords = array(); | |
| if ($cq->isModified()) $keywords[] = 'modified'; | |
| else if ($cq->isUnmodified()) $keywords[] = 'unmodified'; | |
| if ($cq->isSource()) $keywords[] = 'source'; | |
| else if ($cq->isBinary()) $keywords[] = 'binary'; | |
| else if ($cq->isSourceAndBinary()) $keywords[] = 'source&binary'; | |
| return $keywords; | |
| } | |
| /* | |
| function dump_project_cqs(&$projectids) { | |
| global $App; | |
| $componentids = find_ipzilla_components($projectids); | |
| if (!$componentids) return; | |
| $cqs = find_cqs($componentids); | |
| categorize_cqs($cqs); | |
| collect_keywords($cqs); | |
| move_unused_cqs($cqs); | |
| foreach ($cqs as &$cq) dump_cq($cq); | |
| } | |
| function find_cqs(&$componentids) { | |
| global $App; | |
| $sql = "SELECT * FROM bugs WHERE component_id IN (" . implode( ',', $componentids ) . ")"; | |
| log_query($sql); | |
| $result = $App->ipzilla_sql( $sql ); | |
| log_message(mysql_error()); | |
| $cqs = array(); | |
| while ($row = mysql_fetch_assoc($result)) { | |
| $cqs[$row['bug_id']] = $row; | |
| } | |
| $count = count($cqs); | |
| log_message("Found $count potential CQs."); | |
| return $cqs; | |
| } | |
| function categorize_cqs(&$cqs) { | |
| foreach($cqs as &$cq) { | |
| // log_message(get_array_pp($cq)); | |
| switch( $cq['bug_severity'] ) { | |
| case 'approved_all_projects': | |
| case 'approved_one_project': | |
| case 'approved': | |
| case 'reuse': | |
| $cq['state'] = "active"; | |
| break; | |
| case 'exempt_prereq': | |
| case 'workswith': | |
| case 'prereq': | |
| $cq['state'] = "prereq"; | |
| break; | |
| case 'awaiting_analysis': | |
| case 'awaiting_committer': | |
| case 'awaiting_emo': | |
| case 'awaiting_pmc': | |
| case 'awaiting_project': | |
| case 'awaiting_triage': | |
| case 'new': | |
| case 'under_review': | |
| if( ($cq['bug_status'] == 'RESOLVED' | |
| || $cq['bug_status'] == 'CLOSED') | |
| && $$cq['resolution'] == 'FIXED' ) { | |
| $cq['state'] = active; | |
| } else if( $cq['bug_status'] == 'RESOLVED' | |
| || $cq['bug_status'] == 'CLOSED') { | |
| $cq['state'] = "closed"; | |
| } else { | |
| $cq['state'] = "pending"; | |
| } | |
| break; | |
| case 'closed': | |
| case 'rejected': | |
| case 'withdrawn': | |
| $cq['state'] = "closed"; | |
| break; | |
| default: | |
| $cq['state'] = "pending"; | |
| break; | |
| } | |
| } | |
| } | |
| function collect_keywords(&$cqs) { | |
| global $App; | |
| if (!$cqs) return; | |
| $keywords = array( 'modified', 'unmodified', 'source', 'binary', 'sourceandbinary', | |
| 'obsolete', 'unused', 'withdrawn', 'nonepl' ); | |
| foreach( $keywords as $key ) $cq["keyword_$key"] = 0; | |
| $bugids = array(); | |
| foreach($cqs as $id => $cq) $bugids[] = $id; | |
| $sql = "SELECT bug_id, name FROM keywords | |
| LEFT JOIN keyworddefs ON keywordid = id | |
| WHERE name in ( 'modified', 'unmodified', 'source', 'binary', 'sourceandbinary', | |
| 'obsolete', 'unused', 'withdrawn', 'nonepl' ) | |
| AND bug_id IN ( " . implode( ",", $bugids ) . " ) | |
| "; | |
| log_query($sql); | |
| $result = $App->ipzilla_sql( $sql ); | |
| while( $row = mysql_fetch_assoc($result) ) { | |
| $cqs[$row['bug_id']]["keyword_" . $row['name']] = 1; | |
| } | |
| } | |
| function move_unused_cqs(&$cqs) { | |
| foreach( $cqs as &$cq ) { | |
| if ($cq['keyword_obsolete'] || $cq['keyword_unused'] || $cq['keyword_withdrawn']) | |
| $cq['state'] = "unused"; | |
| } | |
| } | |
| function get_combined_quoted(&$values) { | |
| return '"' . implode("\",\"", $values) . '"'; | |
| } | |
| function get_array_pp(&$values) { | |
| $string = 'dg'; | |
| foreach($values as $key => $value) { | |
| $string .= "$key => $value; "; | |
| } | |
| return $string; | |
| } | |
| function find_ipzilla_components(&$projectids) { | |
| global $App; | |
| $componentids = array(); | |
| $sql = "SELECT id, name FROM components WHERE name in (" . get_combined_quoted($projectids) . ")"; | |
| log_query($sql); | |
| $result = $App->ipzilla_sql( $sql ); | |
| while ($row = mysql_fetch_array($result)) { | |
| $id = $row[0]; | |
| $name = $row[1]; | |
| $componentids[] = $id; | |
| log_message("ipzilla-component '$name' has id '$id'"); | |
| } | |
| log_message("Done fetching IPZilla components."); | |
| return $componentids; | |
| } | |
| function html_for_keywords( $row ) { | |
| return ($row['keyword_modified'] ? 'modified ' : '') . | |
| ($row['keyword_unmodified'] ? 'unmodified ' : '') . | |
| ($row['keyword_source'] ? 'source ' : '') . | |
| ($row['keyword_binary'] ? 'binary ' : '') . | |
| ($row['keyword_sourceandbinary'] ? 'source&binary' : ''); | |
| } | |
| function dump_cq(&$cq) { | |
| if ($cq['state'] == "closed") return; | |
| $id = $cq['bug_id']; | |
| $description = htmlspecialchars($cq['short_desc']); | |
| $license = htmlspecialchars($cq['cf_license']); | |
| $use = html_for_keywords($cq); | |
| $state = $cq['state']; | |
| echo "<iplog:cq id=\"$id\" description=\"$description\" license=\"$license\" use=\"$use\" state=\"$state\"/>\n"; | |
| } | |
| */ | |
| ?> |