| <?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("Select another project", "bugz_manager.php", "_self"); |
| |
| $Session = $App->useSession(true); |
| $pageTitle = "Bugzilla Manager"; |
| $pageKeywords = ""; |
| $pageAuthor = "Eclipse Foundation, Inc."; |
| |
| # Begin buffered output |
| ob_start(); |
| |
| ?> |
| <div id="maincontent" style="padding:8px;"> |
| <h1 style="padding-top:10px; padding-bottom:20px;"><?= $pageTitle ?></h1> |
| <link rel="stylesheet" type="text/css" href="../css/stylesheet.css" /> |
| |
| <?php |
| include "details.html"; |
| //turn on/off verbose debuging |
| define("DEBUG",0); |
| //turn on(1) or off(0) actual inserts7 |
| define("do_inserts",1); |
| |
| $Required_Fields = array('project_desc','votes_per_user','max_votes_per_bug','votes_to_confirm','default_milestone'); |
| |
| |
| //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("EDIT_PROJECTDETAILS"); |
| $evt_log->setuid($_SESSION['uid']); |
| $evt_log->setPK2($_SESSION['project']); |
| |
| debug_msg("</br>Session project:" . $_SESSION['project'] ." ", 1 ); |
| |
| //Special arrays for holding 'special'(my sister sarah is special) projects ADD TO THS AND THINGS |
| // SHOULD BE FINE. |
| $specialproject = array("tptp","tptp.test","tptp.platform","tptp.performance","tptp.monitoring",""); |
| |
| /**************************** |
| * |
| * Name: do_specialcheck |
| * Function: does a search for a string(the Session project) within another string(from the special array) |
| * |
| * I/O: pointer to the array, returns TRUE is stristr is true. |
| * |
| * By: M. Ward |
| * Date: Feb 2/07 |
| * Comment: I'm sure there is a better way to do this, but I can't think of one |
| * |
| *******************************/ |
| function do_specialcheck( &$specialarray) { |
| |
| $steps = count( $specialarray ); |
| debug_msg("In specialcheck there will be: " . $steps . " steps" , 3); |
| //auto decrement the steps since all arrays start at 0! |
| $steps--; |
| |
| while( $steps >= 0 ){ |
| debug_msg("Specialcheck while loop. Looking for: " . $specialarray[$steps] . " in " . $_SESSION['project'] . " step: " . $steps,3); |
| debug_msg("strlen return: " . strlen(stristr($_SESSION['project'], $specialarray[$steps])),4); |
| if( strlen(stristr($_SESSION['project'], $specialarray[$steps])) > 1 ){ |
| debug_msg("strlen returned 1 or more",4); |
| return 1; |
| } else { |
| $steps--; |
| } |
| } |
| debug_msg("About to return 0 from specialcheck",3); |
| return 0; |
| } |
| |
| /***************************** |
| * |
| * 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; |
| |
| debug_msg("In post section",2); |
| //change up the project settings, in case this is a special project |
| if( checkpost($_SESSION['projisclass'] ) ) { |
| $workingproject = $_SESSION['projisclass']; |
| } else { |
| $workingproject = $_SESSION['project']; |
| } |
| //check that the user is associated with this project |
| $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) { |
| debug_msg("Checking milestone",2); |
| //first need to check that hte default milestone exists in the milestones list, or else it will cause 'A legal target milestone was not set' error |
| //build query |
| debug_msg("POSTED milestone was: " . $_POST['default_milestone'],3); |
| $query = "select count(*) from milestones where value=\"" . $_POST['default_milestone'] . "\" "; |
| $query .= " AND product_id=\"" . $_SESSION['main_product_id'] ."\";"; |
| debug_msg($query,3); |
| $result = mysql_query($query, $bdbh); |
| 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['count(*)'] == 0) { |
| debug_msg("You have specified a default milestone that has not been defined. Please define the milestone first and then change the default.",0); |
| return; |
| } |
| |
| debug_msg("updating bugzilla",2); |
| //build the insert command |
| $bugsquery = "update products "; |
| $bugsquery .= "set description=\"" . $_POST['project_description'] ."\","; |
| //make sure that the votes can't be negative(no idea what this would do to bugzilla |
| if ( $_POST['votes_per_user'] < 0 ) |
| $bugsquery .= " votesperuser=0,"; |
| else |
| $bugsquery .= " votesperuser=\"" . $_POST['votes_per_user'] ."\","; |
| //make sure that the votes can't be negative(no idea what this would do to bugzilla |
| if ( $_POST['max_votes_per_bug'] < 0 ) |
| $bugsquery .= " maxvotesperbug=0,"; |
| else |
| $bugsquery .= " maxvotesperbug=\"" . $_POST['max_votes_per_bug'] . "\","; |
| $bugsquery .= " defaultmilestone=\"" . $_POST['default_milestone'] . "\" "; |
| $bugsquery .= "where name=\"" . $_SESSION['bugsname'] ."\""; |
| $bugsquery .= " AND id=\"" . $_SESSION['main_product_id'] ."\";"; |
| debug_msg($bugsquery,3); |
| //set a key for the logs |
| $evt_log->setPK1($_POST['bugname']); |
| if( do_inserts == 1) { |
| $result = mysql_query($bugsquery,$bdbh); |
| //check for error |
| if($result == FALSE) { |
| debug_msg(mysql_error(), 0); |
| debug_msg("Please contact the Webmaster about this error. Thank you.",0); |
| return; |
| } |
| //log the event, regardless of wether or not it failed. |
| $evt_log->insertModLog($_SESSION['uid']); |
| } |
| } |
| } |
| |
| if ( $App->getDBReadOnly() ) { |
| print("<h3>The database is currently offline for maintanence. Please try again later</h3>"); |
| } else { |
| //Store the project in the global session cookie |
| if( checkpost($_POST['cmonprojects']) ){ |
| debug_msg("setting session project as " . $_POST['cmonprojects'] , 2); |
| $_SESSION['project'] = $_POST['cmonprojects']; |
| debug_msg("Set Session project:" . $_SESSION['project'] ." ", 2); |
| } |
| |
| //check to see if this page is being called due to an internal post command. |
| if( isset($_POST['Submit']) ){ |
| do_postwork(); |
| } |
| |
| debug_msg("projisclass contains:" . $_SESSION['projisclass'],4); |
| //wrap to prevent special project lookups |
| if ( checkpost($_SESSION['projisclass']) == 0 ) { |
| debug_msg("Initial run on a project",3); |
| //query to get the bugzilla product name |
| $query = "select BugsName from Projects where ProjectID = '" . $_SESSION['project'] . "';"; |
| 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); |
| } |
| $data = mysql_fetch_array($result); |
| debug_msg("BugsName: " . $data['BugsName'], 3); |
| |
| } else if( ( checkpost($_GET['issp']) == 0 ) && ( checkpost($_SESSION['projisclass']) == 1 ) && ( checkpost($_POST['Submit']) == 0 ) && (checkpost($_POST['cmonprojects']) == 0) ) { |
| debug_msg("Special project found in Project IS Classification!",3); |
| $data['BugsName'] = $_SESSION['projisclass']; |
| $_SESSION['project'] = $_SESSION['projisclass']; |
| } else { |
| $data['BugsName'] = $_SESSION['project']; |
| } |
| |
| debug_msg("Data[bugsname] is: " . $data['BugsName'],3); |
| if ( $data['BugsName'] != "" ) { |
| |
| //Now that TPTP has re-organized itself, the standard bugzilla project layout(unlike say eclipse.platform |
| //tptp now has multiple sub-products that are all still part of the parent project so tptp.tptpsomeproduct is part of |
| //tptp) that I was relying on is fraked. Now we have do a little extra processing for 1 exception, so |
| //let's check if this page was posted with the 'tptp' project and in that case generate a list of 'product' |
| //links that call this page (again) with the correct thing to edit |
| if ( in_array($_SESSION['project'],$specialproject) ) { |
| |
| debug_msg("In special projects section",2); |
| |
| //this check makes sure that the project classification is only updated if this is a 'special' project 1st time request |
| //to the page. All other calls to the page with sub-products, wont cause this to update and so will be found |
| //with the correct wildcard classification |
| //if ( strlen(stristr($_SESSION['project'], ".")) > 1 ) { |
| // debug_msg("In projisclass test", 4); |
| //insert this project into the session. Name is contraction of 'project is classification(in bugzilla)' |
| // $_SESSION['projisclass'] = substr($_SESSION['project'],0,strpos($_SESSION['project'],".") ); |
| //} |
| $_SESSION['projisclass'] = strtolower($data['BugsName']); |
| |
| |
| //break out the name, which is one of our keys |
| $bugzillaname = $data['BugsName']; |
| $_SESSION['bugsname'] = $bugzillaname; |
| //get the info from the bugs database |
| $bugsquery = "select * from products where name like \"" . $bugzillaname ."%\";"; |
| debug_msg($bugsquery,3); |
| $result = mysql_query($bugsquery, $bdbh); |
| if( $result === FALSE){ |
| debug_msg(mysql_error(), 0); |
| debug_msg("Please contact the Webmaster about this error. Thank you.",0); |
| } |
| debug_msg("Num rows: " . mysql_num_rows($result), 2); |
| if( mysql_num_rows($result) != 0 ) { |
| $html = "</br><h3>You need to select a product to edit</h3></br>"; |
| $html .= "<form name=\"editproducts\" method=\"post\" action=\"edit_bugzilla_project.php\">\n\r"; |
| $html .= "<select name=\"cmonprojects\"> \n\r"; |
| while ($myrow = mysql_fetch_array($result)) { |
| $html .= "<option>" . $myrow["name"] ."</option> \n\r"; |
| } |
| $html .= "</select>"; |
| $html .= "<input type=\"submit\" name=\"Product\" value=\"Edit\">"; |
| $html .= "</form></br>"; |
| } |
| |
| } else { |
| //break out the name, which is one of our keys |
| $bugzillaname = $data['BugsName']; |
| $_SESSION['bugsname'] = $bugzillaname; |
| //get the info from the bugs database |
| $bugsquery = "select * from products where name = \"" . $bugzillaname ."\";"; |
| debug_msg($bugsquery,3); |
| $result = mysql_query($bugsquery, $bdbh); |
| if( $result == FALSE){ |
| debug_msg(mysql_error(), 0); |
| debug_msg("Please contact the Webmaster about this error. Thank you.",0); |
| } |
| |
| $data = mysql_fetch_array($result); |
| //error check for out of date bugsname |
| if( $data === FALSE ){ |
| debug_msg("It looks like there was an issue in resolving your Project->Bugzilla mapping.",0); |
| debug_msg("Please contact the Webmaster about this error. Thank you.",0); |
| } |
| |
| //Store usefull data |
| $_SESSION['main_product_id'] = $data['id']; |
| debug_msg("Project ID is: " .$_SESSION['main_product_id'], 3 ); |
| $project_name = $data['name']; |
| $_SESSION['project_name'] = $data['name']; |
| debug_msg("Project Name is: " . $project_name, 3); |
| $project_desc = $data['description']; |
| debug_msg("Project Desc is: " . $project_desc, 3); |
| $new_bugs = $data['isactive']; |
| debug_msg("Project new bugs is: " . $new_bugs, 3); |
| $votes_per_user = $data['votesperuser']; |
| debug_msg("Project votes per is: " . $votes_per_user, 3); |
| $max_votes_per_bug = $data['maxvotesperbug']; |
| debug_msg("Project max votes is: " . $max_votes_per_bug, 3); |
| $default_milestone = $data['defaultmilestone']; |
| debug_msg("Project default milestone is: " . $default_milestone, 3); |
| |
| //now build the html |
| $html = "<h3>Overall bugzilla settings for " . $project_name . " </h3></br>\n\r"; |
| |
| //this is just to let the user know if the project will accept bugs(has not been archived) |
| if( $new_bugs == "0" ) |
| $html .= "<h4>NOTE: This project has been closed to new bugs</h4>"; |
| |
| //build the form |
| $html .= "<form name=\"project_details\" method=\"post\" action=\"edit_bugzilla_project.php\" >\n\r"; |
| $html .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >\n\r"; |
| $html .= "<tr><td>Description </td><td><textarea rows=\"5\" cols=\"40\" name=\"project_description\">" . $project_desc ."</textarea></td></tr>\n\r"; |
| $html .= "<tr><td>Max votes per user </td><td><input type=\"text\" name=\"votes_per_user\" value=\"" . $votes_per_user ."\"></td></tr>\n\r"; |
| $html .= "<tr><td>Max votes per bug </td><td><input type=\"text\" name=\"max_votes_per_bug\" value=\"" . $max_votes_per_bug ."\"></td></tr>\n\r"; |
| $html .= "<tr><td>Default milestone </td><td><select name=\"default_milestone\" >"; |
| //get all available milestones and fill the select box |
| $query="select value from milestones where product_id=\"" . $_SESSION['main_product_id']."\";"; |
| debug_msg($query,4); |
| $result = mysql_query($query,$bdbh); |
| if ( $result == FALSE ) { |
| debug_msg(mysql_error(),0); |
| debug_msg("Please contact the Webmaster about this error. Thank you.",0); |
| } |
| while ( $myrow = mysql_fetch_array($result) ) { |
| if ( $default_milestone == $myrow["value"] ) |
| $html .= "<option selected>" . $myrow["value"] . "\r\n"; |
| else |
| $html .= "<option>" . $myrow["value"] . "\r\n"; |
| } |
| $html .= "</select></td></tr>\n\r"; |
| $html .= "</table>\n\r<input type=\"submit\" name=\"Submit\" value=\"Make Changes\" >\n\r"; |
| $html .= "<input type=\"hidden\" name=\"bugname\" value=\"" . $bugzillaname . "\">"; |
| $html .= "</form>\n\r"; |
| |
| //links to the other sections: components,versions and milestones |
| $html .="</br></br>"; |
| $html .="<a href=\"edit_bugzilla_components.php\">Edit bugzilla components for " . $project_name . "</a>\n\r</br>"; |
| $html .="<a href=\"add_bugzilla_versions.php\">Add bugzilla versions for " . $project_name . "</a>\n\r</br>"; |
| $html .="<a href=\"add_bugzilla_milestones.php\">Add bugzilla milestones for " . $project_name . "</a>\n\r</br>"; |
| |
| //add a link for the 'other products' |
| if( checkpost($_SESSION['projisclass'] ) == 1 ){ |
| $html .= "<a href=\"edit_bugzilla_project.php\">Select another product</a></br>"; |
| } |
| } |
| } else { |
| $html = "<h3>Unable to determine the correct bugzilla component. Please send a mesage to the webmaster indicating which project produced this error.</h3></br>\n\r"; |
| } //end special projects section |
| |
| |
| |
| //return the the main page |
| $html .="<a href=\"bugz_manager.php\">Select another project</a>"; |
| } |
| |
| echo $html; |
| |
| |
| echo "</div>"; |
| |
| $html = ob_get_contents(); |
| ob_end_clean(); |
| |
| $App->generatePage($theme, $Menu, null, $pageAuthor, $pageKeywords, $pageTitle, $html); |
| |
| ?> |