blob: f2282656a24a6568991a2128972419d5af92c3da [file] [log] [blame]
<?php
/*******************************************************************************
* Copyright (c) 2006-2013 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:
* Matt Ward (Eclipse Foundation) - initial API and implementation
* Denis Roy (Eclipse Foundation) - 2013 update
*******************************************************************************/
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");
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/evt_log.class.php");
# Add'l requires for Bugzilla
require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection.class.php";
require_once("/home/data/httpd/eclipse-php-classes/system/dbconnection_bugs_rw.class.php");
require_once("/home/data/httpd/eclipse-php-classes/system/dbconnection_foundation_ro.class.php");
$App = new App(); $Menu = new Menu();
$App->runStdWebAppCacheable();
include("_projectCommon.php");
$Menu->addMenuItem("Return to project overview", "edit_bugzilla_project.php", "_self");
//turn on/off verbose debuging
define("DEBUG",0);
//turn on(1) or off(0) actual inserts
define("do_inserts",1);
$Session = $App->useSession(true);
$pageTitle = "Bugzilla Manager";
$pageKeywords = "";
$pageAuthor = "Eclipse Foundation, Inc.";
# Begin buffered output
ob_start();
?>
<link rel="stylesheet" type="text/css" href="../css/stylesheet.css" />
<div id="maincontent" style="padding:8px;">
<h1 style="padding-top:10px; padding-bottom:20px;"><?= $pageTitle ?></h1>
<?php
include "details.html";
$Menu->addMenuItem("Return to project overview", "edit_bugzilla_project.php", "_self");
if ( (checkpost($App->getHTTPParameter('addversion'))) )
$Menu->addMenuItem("Show all versions", "add_bugzilla_versions.php", "_self");
//connect to the foundation db in
$fdbc = new DBConnectionFoundation();
$fdbh = $fdbc->connect();
$bdbc = new DBConnectionBugsRW();
$bdbh = $bdbc->connect();
//set the global log options
$evt_log = new EvtLog();
$evt_log->setLogTable("__bugs");
$evt_log->setLogAction("ADD_VERSION");
$evt_log->setuid($_SESSION['uid']);
$evt_log->setPK2($_SESSION['project']);
/*****************************
*
* Name: do_postwork
* Function: does the checks and data inserts. Putting this stuff here lets me use the return function without screwing up the page.
*
* I/O: needs to be passed the db handle.
*
* By: M. Ward
* Date: Feb 22/06
*
******************************/
function do_postwork( $bdbh, $fdbh ) {
global $bdbh;
global $fdbh;
global $evt_log;
debug_msg("In Add version",4);
//check that the version does not already exist
$bugsquery = "select count(*) from versions where product_id=\"" . $_SESSION['main_product_id'] ."\"";
$bugsquery .= " AND value=\"" . $_POST['newversion'] . "\";";
$bugsresult = mysql_query($bugsquery,$bdbh);
if( $bugsresult == FALSE ) {
debug_msg( mysql_error(), 0);
debug_msg("Please contact the Webmaster about this error. Thank you.",0);
return;
}
$count = mysql_fetch_array($bugsresult);
//if the count is < 0 then there is already a version with that exact syntax
if( $count['COUNT(*)'] < 0 ){
debug_msg("<h4>That version already exists!</h4>",0);
return;
}
debug_msg("Sorting out special project",4);
//change up the project settings, in case this is a special project
if( checkpost($_SESSION['projisclass'] ) ) {
$workingproject = $_SESSION['projisclass'];
$query = "SELECT count(*) ProjectID FROM Projects WHERE ( ProjectID IN (SELECT ProjectID FROM PeopleProjects WHERE PersonID ='" . $_SESSION['uid'] . "' AND";
$query .= " ( Relation IN ('PM','PD','PL' ) OR ( Relation='CM' AND EditBugs=1 ) ) AND ProjectID like '" . $workingproject . "%' AND (InactiveDate is NULL OR InactiveDate >= CURRENT_DATE()) ) OR ";
$query .= " ( ParentProjectID IN (SELECT ProjectID FROM PeopleProjects WHERE PersonID = '" . $_SESSION['uid'] . "' AND Relation IN ('PM','PD') AND ";
$query .= " (InactiveDate is NULL OR InactiveDate >= CURRENT_DATE())) AND ProjectID like '" . $workingproject . "%' ) ) AND BugsName IS NOT NULL; ";
} else {
$workingproject = $_SESSION['project'];
//ok the version needs to be added
//check committer edit pl/pd/pm status
$query = "SELECT count(*) ProjectID FROM Projects WHERE ( ProjectID IN (SELECT ProjectID FROM PeopleProjects WHERE PersonID ='" . $_SESSION['uid'] . "' AND";
$query .= " ( Relation IN ('PM','PD','PL' ) OR ( Relation='CM' AND EditBugs=1 ) ) AND ProjectID='" . $workingproject . "' AND (InactiveDate is NULL OR InactiveDate >= CURRENT_DATE()) ) OR ";
$query .= " ( ParentProjectID IN (SELECT ProjectID FROM PeopleProjects WHERE PersonID = '" . $_SESSION['uid'] . "' AND Relation IN ('PM','PD') AND ";
$query .= " (InactiveDate is NULL OR InactiveDate >= CURRENT_DATE())) AND ProjectID='" . $workingproject . "' ) ) AND BugsName IS NOT NULL; ";
}
debug_msg($query,3);
$result = mysql_query($query, $fdbh);
if( $result == FALSE ) {
debug_msg(mysql_error(), 0);
debug_msg("Please contact the Webmaster about this error. Thank you.",0);
return;
}
$data = mysql_fetch_array($result);
if( $data['ProjectID'] >= 1) {
//write the insert statement
$bugsquery = "insert into versions(value,product_id) VALUES('";
$bugsquery .= $_POST['newversion'] ."','" . $_SESSION['main_product_id'] . "');";
debug_msg($bugsquery,3);
//set a key for the logs
$evt_log->setPK1($_POST['newversion']);
//allows the inserts to be turned off for testing
if( do_inserts == 1) {
$bugsresult = mysql_query($bugsquery,$bdbh);
if ( $bugsresult == FALSE ) {
debug_msg(mysql_error(),0);
debug_msg("Please contact the Webmaster about this error. Thank you.",0);
return;
}
//log the event
$evt_log->insertModLog($_SESSION['uid']);
}
//tell the committer that everything went ok
$html = "<h3>Version added.</h3>";
}
}
if ( $App->getDBReadOnly() ) {
$html = "<h3>The database is currently offline for maintanence. Please try again later</h3>";
} else {
//clicked the submit button
if( checkpost( $App->getHTTPParameter('newversion')) && $App->getHTTPParameter('submit') ) {
do_postwork( );
$html .="</br><a href=\"add_bugzilla_versions.php?addversion=new\">Add another version</a>";
$html .="</br><a href=\"add_bugzilla_versions.php\">View all versions</a>";
}else if( checkpost($App->getHTTPParameter('addversion')) ){//clicked the add new link
showwarning();
$html = "<h3>Add a new version </h3>";
//show the add version form, simple text box
$html .= "<form name=\"addversion\" method=\"post\" action=\"add_bugzilla_versions.php\">\n\r";
$html .= "<table>\n\r";
$html .="<tr><td>Version</td><td><input type=\"text\" name=\"newversion\"></td></tr>\n\r";
$html .="<tr><td><input type=\"submit\" name=\"submit\" value=\"Add Version\"></td></tr>";
$html .="</table>\n\r</form>\n\r";
} else { //main section
//get the list of versions for this project
$bugsquery="select * from versions where product_id=\"" . $_SESSION['main_product_id']."\";";
debug_msg($bugsquery,3);
$bugsresult = mysql_query($bugsquery,$bdbh);
if ( $bugsresult == FALSE ) {
debug_msg(mysql_error(),0);
debug_msg("Please contact the Webmaster about this error. Thank you.",0);
}
//if everything went well, build the list.
$html = "<h3>Bugzilla versions for " . $_SESSION['project_name'] ."</h3></br>\n\r";
$html .= "<p>Versions cannot be deleted or edited from this interface. Please <a href='https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Community&component=Bugzilla&short_desc=Please%20edit%20versions%20for%20my%20project'>file a bug to webmaster</a> for this.</p>";
$html .="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"normal\">\n\r";
$html .="<tr class=\"list_column_header\" height=\"" . $App->getDefaultRowHeight() . "\">\n\r";
$html .="<td align=\"left\"><b>Version</b></td>\n\r</tr>\n\r";
$count = 0;
while($row = mysql_fetch_array($bugsresult)) {
$html .="<tr height=\"" . $App->getDefaultRowHeight() ."\" class=\"data". $count % 2 ."\">\n\r";
$html .="<td>" . $row['value'] . "</td></tr>\n\r";
$count++;
}
$html .="</table>\n\r";
$html .="</br><a href=\"add_bugzilla_versions.php?addversion=new\">Add a new version</a>\n\r";
} //end of default section
//add a link for the 'other products'
if( checkpost($_SESSION['projisclass'] ) == 1 ){
$html .="</br><a href=\"edit_bugzilla_project.php?issp=1\">Return to product overview</a>";
$html .="</br><a href=\"edit_bugzilla_project.php\">Select another product</a>";
} else {
$html .="</br><a href=\"edit_bugzilla_project.php?issp=1\">Return to project overview</a>";
}
}
echo $html;
echo "</div>";
$html = ob_get_contents();
ob_end_clean();
$App->generatePage($theme, $Menu, null, $pageAuthor, $pageKeywords, $pageTitle, $html);
?>