| <?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"; |
| |
| if ( (checkpost($_GET['addmilestone'])) ) |
| $Menu->addMenuItem("Show all milestones", "add_bugzilla_milestones.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_MILSTONE"); |
| $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( ) { |
| global $bdbh; |
| global $fdbh; |
| global $evt_log; |
| |
| //check that the 'milestone' is numeric, no letters(other than rc or m) |
| if( !checkpost($_POST['newmilestone']) ) { |
| debug_msg("<h4>You need to specify a milestone.</h4>",0); |
| return; |
| } |
| if( checkpost($_POST['newsortkey']) ) { |
| //check that the sort key is numeric, no letters) |
| if (!is_numeric($_POST['newsortkey']) ){ |
| debug_msg("<h4>The specified sortkey is not valid</h4>",0); |
| return; |
| } |
| } else { //no sort key |
| debug_msg("<h4>You need to specify a sort key</h4>",0); |
| return; |
| } |
| //check that the milestone/sortkey do not already exist |
| //NOTE: this is my(the developer) choice. Bugzilla doesn't seem to give a damn, but I do |
| //if people want to be able go set multiple milestones to the same sortkey, then remover |
| //the query after the union, and the check that follows |
| $bugsquery = "select count(*) from milestones where product_id=\"" . $_SESSION['main_product_id'] ."\""; |
| $bugsquery .= " AND value=\"" . $_POST['newmilestone'] . "\""; |
| $bugsquery .= " UNION ALL select count(*) from milestones where product_id=\"" . $_SESSION['main_product_id'] ."\""; |
| $bugsquery .= " AND sortkey=\"" . $_POST['newsortkey']. "\";"; |
| 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); |
| return; |
| } |
| $count = mysql_fetch_array($bugsresult); |
| //get the number of values(milestones) that match |
| $milestones= $count['count(*)']; |
| //get next row |
| $count = mysql_fetch_array($bugsresult); |
| //get the number of values(milestones) that match |
| $sortkeys= $count['count(*)']; |
| |
| debug_msg("counts(m/s): ". $milestones . "/" . $sortkeys, 4); |
| |
| //if the count is < 0 then there is already a version with that exact syntax |
| if( $milestones != 0 ){ |
| debug_msg("<h4>That milestone already exists!</h4>",0); |
| return; |
| } |
| if( $sortkeys != 0) { |
| debug_msg("<h4>That sort key already exists!</h4>",0); |
| return; |
| } |
| //ok the milestone needs to be added |
| //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']; |
| //check committer edit /pl/pm/pd 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 milestones(value,sortkey,product_id) VALUES('"; |
| $bugsquery .= $_POST['newmilestone'] ."','" . $_POST['newsortkey'] . "','"; |
| $bugsquery .= $_SESSION['main_product_id'] . "');"; |
| //set a key for the logs |
| $evt_log->setPK1($_POST['newmilestone']); |
| //show the query |
| debug_msg($bugsquery,3); |
| //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>Milestone added.</h3>"; |
| } |
| |
| } |
| |
| //Check dbreadonly flag |
| if ( $App->getDBReadOnly() ) { |
| $html = "<h3>The database is currently offline for maintanence. Please try again later</h3>"; |
| } else { |
| //clicked the submit button |
| if( $_POST['submit'] ) { |
| do_postwork( ); |
| $html .="</br><a href=\"add_bugzilla_milestones.php?addmilestone=new\">Add another milestone</a>\n\r"; |
| $html .="</br><a href=\"add_bugzilla_milestones.php\">View all milestones</a>"; |
| }else if( checkpost($_GET['addmilestone']) ){//clicked the add new link |
| |
| showwarning(); |
| |
| $html = "<h3> Add a new milestone </h3></br>\n\r"; |
| $html .= "<p> Fields marked with an <font face=\"Arial\" color=\"#FF0000\">*</font> are required </p>\n\r"; |
| //show the add version form, simple text box |
| $html .= "<form name=\"addmilestone\" method=\"post\" action=\"add_bugzilla_milestones.php\">\n\r"; |
| $html .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n\r"; |
| $html .="<tr><td><font face=\"Arial\" color=\"#FF0000\">*</font> Milestone </td><td><input type=\"text\" name=\"newmilestone\"></td></tr>\n\r"; |
| $html .="<tr><td><font face=\"Arial\" color=\"#FF0000\">*</font> Sortkey </td><td><input type=\"text\" name=\"newsortkey\"></td></tr>\n\r"; |
| $html .="<tr><td></td><td class=\"micro\">The value you enter for the sort key is used to determine<br/ >the order that milestones are listed in. Use integer<br /> values from 0-32767.</td></tr>\n\r"; |
| $html .="</table>\n\r"; |
| $html .="<input type=\"submit\" name=\"submit\" value=\"Add Milestone\">"; |
| $html .="</form>"; |
| |
| $html .="</br><a href=\"add_bugzilla_milestones.php\">View all milestones</a>\n\r"; |
| } else { //main section |
| //get the list of versions for this project |
| $bugsquery="select * from milestones where product_id=\"" . $_SESSION['main_product_id']."\";"; |
| debug_msg($bugsquery,4); |
| $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); |
| } |
| |
| $html = "<h3>Bugzilla milestones for " . $_SESSION['project_name'] ."</h3></br>\n\r"; |
| $html .= "<p>Milestones 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>Milestone</b></td>\n\r<td align=\"left\"><b>Sortkey</b></td>\n\r"; |
| $html .="</tr>\n\r"; |
| $count = 0; |
| while($row = mysql_fetch_array($bugsresult)) { |
| $html .="<tr height=\"". $App->getDefaultRowHeight() ."\" class=\"data". $count % 2 ."\">"; |
| $html .="<td>". $row['value'] ."</td><td>" . $row['sortkey'] ."</td></tr>\n\r"; |
| $count++; |
| } |
| |
| $html .="</table>\n\r"; |
| $html .="</br><a href=\"add_bugzilla_milestones.php?addmilestone=new\">Add a new milestone</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); |
| |
| ?> |