| <?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_workaround.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("Select another project", "bugz_manager.php", "_self"); |
| |
| //connect to the foundation db in |
| $fdbc = new FoundationDBConnectionRW(); |
| $fdbh = $fdbc->connect(); |
| |
| //set the global log options |
| $evt_log = new EvtLog(); |
| $evt_log->setLogTable("__bugs"); |
| $evt_log->setLogAction("ADD_PROJECTCOMMITTER"); |
| $evt_log->setuid($_SESSION['uid']); |
| $evt_log->setPK2($_SESSION['project']); |
| |
| debug_msg("</br>Session project:" . $_SESSION['project'] ." ", 1 ); |
| |
| /***************************** |
| * |
| * 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); |
| //check the creds of the person requesting the post, via the session cookie |
| if( $_SESSION['ispl'] >= 1){ |
| debug_msg("Confirming PL/PM/PD", 2); |
| //check that the user id *is* pl,pm,pd(I know this has already been done but lets be careful) |
| //of course this does presume that someone hasn't borked the session file |
| //the inactive date should either be NULL(default)or set(to something else). |
| //So if we check for an inactive date >= than the curent date we're ok, less and they shouldn't be here |
| $query = "SELECT count(*) ProjectID FROM Projects WHERE ( ProjectID IN (SELECT ProjectID FROM PeopleProjects WHERE PersonID ='" . $_SESSION['uid'] . "' AND"; |
| $query .= " Relation IN ('PM','PD','PL' ) AND ProjectID='" . $_SESSION['project'] . "' 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='" . $_SESSION['project'] . "' ) ) 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; |
| } |
| $pldata = mysql_fetch_array($result); |
| if ( $pldata == FALSE ) |
| debug_msg("Fetch Array returned FALSE. Someone should look into this.",3); |
| //if the person has one or more entries via a pl/m, then in theory the person has the authority for this |
| debug_msg("PL COUNT is: " . $pldata["ProjectID"], 3); |
| if($pldata["ProjectID"] >= 1) { |
| debug_msg("PL/PM/PD Status verifed", 2); |
| $query = "select DISTINCT PP.PersonID,Peep.FName,Peep.LName from PeopleProjects AS PP left join People as Peep on PP.PersonID = Peep.PersonID where PP.ProjectID = '" . $_SESSION['project'] . "' AND (InactiveDate is NULL OR InactiveDate >= CURRENT_DATE() );"; |
| 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; |
| } |
| //now sort through all of the distinct people on the project, since their userids |
| //are the key values for the post form below |
| while($myrow = mysql_fetch_array($result)) { |
| //check that the value is set |
| if ( checkpost($_POST[$myrow['PersonID']]) ) { |
| // update query |
| debug_msg("updating: " . $myrow['PersonID'] . " " . $_POST[$myrow['PersonID']] ."</br>\n\r", 3); |
| $query = "update PeopleProjects set EditBugs =\"" .$_POST[$myrow['PersonID']]; |
| $query .= "\" where PersonID = \"" .$myrow['PersonID'] . "\" AND ProjectID =\""; |
| $query .= $_SESSION['project'] ."\"; "; |
| debug_msg($query,3); |
| if( do_inserts == 1) { |
| $update_result = mysql_query($query,$fdbh); |
| if( $update_result == FALSE ) { |
| debug_msg(mysql_error(), 0); |
| debug_msg("Please contact the Webmaster about this error. Thank you.",0); |
| return; |
| } |
| } |
| } else { |
| debug_msg("Tried to check: ".$myrow['PersonID'],3); |
| debug_msg("Failed to confirm the POST value for someone", 2); |
| debug_msg("Unable to update " . $myrow['PersonID'] . " because of a php failure. Please contact the Webmaster.",0); |
| } |
| } |
| //only log this once, instead of for each pass through the list |
| $evt_log->setPK1($_SESSION['uid']); |
| //log the event |
| $evt_log->insertModLog($_SESSION['uid']); |
| } else {//close pl query |
| debug_msg("Failed DB PL check", 2); |
| return; |
| } |
| } else //close bugs pl check |
| debug_msg("Failed PL check", 2); |
| } |
| |
| |
| //check to see if the db is in readonly mode |
| if ( $App->getDBReadOnly() ) { |
| $html = "<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['plonprojects']) ){ |
| debug_msg("setting session project", 2); |
| $_SESSION['project'] = $_POST['plonprojects']; |
| debug_msg("Set Session project:" . $_SESSION['project'] ." ", 2); |
| } |
| |
| //This is to print out the contents of the post array, so it's useful for extended debug info |
| if( defined('DEBUG') && DEBUG > 3 ) { |
| foreach( $_POST as $key => $post) { |
| debug_msg("POST key/val: " . $key . "/" . $post, 3); |
| } |
| debug_msg("PL:".$_SESSION['ispl']."/UID:".$_SESSION['uid']." ", 3); |
| } |
| |
| //check to see if this page is being called due to an internal post command. |
| if( checkpost($_POST['Submit']) ){ |
| do_postwork(); |
| } |
| |
| debug_msg("bypassing post section", 2); |
| //query to get the list of CM's |
| $query = "select DISTINCT PP.PersonID,Peep.FName,Peep.LName,PP.EditBugs from PeopleProjects AS PP left join People as Peep on PP.PersonID = Peep.PersonID where PP.ProjectID = '" . $_SESSION['project'] . "'"; |
| $query .= "AND (PP.InactiveDate is NULL OR PP.InactiveDate >= CURRENT_DATE() ) ;"; |
| 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); |
| } |
| |
| ?> |
| |
| Click on a user's name to add/remove them from the bugzilla access for the <?= $_SESSION['project'] ?> |
| project.</br> When you are done click the submit button to commit your changes.</br> |
| <form name="committers" method="post" action="add_bugzilla_committer.php" > |
| <table width="100%" cellpadding="0" cellspacing="0" border="0" class="normal"> |
| <tr class="list_column_header" height=" <?= $App->getDefaultRowHeight() ?>"> |
| <td align="left"><b>Name</b></td> |
| <td align="left"><b>Can Edit Bugzilla</b></td> |
| </tr> |
| <?php |
| $count = 0; |
| while($myrow = mysql_fetch_array($result)) { |
| $fullname = $myrow['FName'] . $myrow['LName']; |
| //clear out apostrophees from names. |
| $fullname = preg_replace('[\']','', $fullname); |
| ?> |
| <tr height="<?= $App->getDefaultRowHeight() ?>" class="data<?= $count % 2 ?>"> |
| <td><a href="javascript:switchCheck('<?= $fullname ?>','<?= $myrow['PersonID'] ?>')"><?= $myrow['FName'] ?> <?= $myrow['LName'] ?> </a></td> |
| <td><input type="hidden" name="<?= $myrow['PersonID'] ?>" value ="<?= $myrow['EditBugs'] ?>" /><div id ="<?= $fullname ?>" class=" |
| <?php |
| if( $myrow['EditBugs'] != 0) |
| $state = "contenton"; |
| else |
| $state = "contentoff"; |
| ?> |
| <?= $state ?>"><img src="../images/check.gif" border=0 /> </div></td></tr> |
| <?php |
| $count++; |
| } |
| ?> |
| </table> |
| <input type="hidden" name="Users" value="true" > |
| <input type="submit" name="Submit" value="Submit"> |
| </form> |
| </br><a href="bugz_manager.php">Return to projects</a> |
| |
| <?php |
| } |
| |
| |
| echo $html; |
| |
| |
| echo "</div>"; |
| |
| $html = ob_get_contents(); |
| ob_end_clean(); |
| |
| $App->generatePage($theme, $Menu, null, $pageAuthor, $pageKeywords, $pageTitle, $html); |
| |
| ?> |