| <?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"); |
| |
| # 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"); |
| |
| $Session = $App->useSession(true); |
| $pageTitle = "Bugzilla Manager"; |
| $pageKeywords = ""; |
| $pageAuthor = "Eclipse Foundation, Inc."; |
| |
| # Begin buffered output |
| ob_start(); |
| |
| //set the default debug level nice and low |
| define('DEBUG',0); |
| |
| |
| //connect to the foundation db in ro mode, once we know if the uid is a PL/PMC/PD we can open the db in rw mode |
| $fdbc = new DBConnectionFoundation(); |
| $fdbh = $fdbc->connect(); |
| |
| # Incoming parameters |
| $_STATE = $App->getHTTPParameter("state"); |
| |
| |
| ?> |
| |
| <div id="maincontent" style="padding:8px;"> |
| <h1 style="padding-top:10px; padding-bottom:20px;"><?= $pageTitle ?></h1> |
| |
| <?php |
| include "details.html"; |
| |
| if ( $App->getDBReadOnly() ) { |
| print("<h3>The database is currently offline for maintanence. Please try again later</h3>"); |
| } |
| else { |
| $Friend=$Session->getFriend(); |
| $uid = $_SESSION['uid'] = $Friend->getUID(); |
| |
| //clear the projisclass session variable. |
| $_SESSION['projisclass'] = ''; |
| debug_msg("PROJECT IS CLASS STATUS: " . $_SESSION['projisclass'], 3 ); |
| |
| //get the pl/m status from the db for this user id |
| $query = "select COUNT(*) from PeopleProjects where PersonID = '" . $_SESSION['uid'] . "' AND Relation IN ( 'PL','PM','PD' ) 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); |
| } |
| |
| $pl = mysql_fetch_array($result); |
| |
| $_SESSION['ispl'] = $pl["COUNT(*)"]; |
| print "<h2>Bugzilla permissions delegation</h2>"; |
| if( $_SESSION['ispl'] >= 1 ) {//person is a pl,pm or pd(on more than on project) |
| print("<br /><p>As a Project Lead or PMC member you can grant access to committers to edit bugzilla components, versions and milestones for your project(s)</p>"); |
| //build a drop box of projects for which we are a pl,pm or pd |
| //100306 $query = "select DISTINCT ProjectID from PeopleProjects where PersonID = '". $_SESSION['uid'] ."' AND Relation IN ( 'PL','PM','PD' ) AND (InactiveDate is NULL OR InactiveDate >= CURRENT_DATE() );"; |
| //Note that PM/PD memebers will see all sub projects of the toplevel project, not just the single toplevel. |
| $query = "SELECT ProjectID FROM Projects WHERE ( ProjectID IN (SELECT ProjectID FROM PeopleProjects WHERE PersonID ='". $_SESSION['uid'] ."' "; |
| $query .= " AND Relation IN ('PM','PD','PL') AND (InactiveDate is NULL OR InactiveDate >= CURRENT_DATE() ) ) OR ParentProjectID IN (SELECT "; |
| $query .= "ProjectID FROM PeopleProjects WHERE PersonID = '". $_SESSION['uid'] ."' AND Relation IN ('PM','PD' ) AND (InactiveDate is NULL OR "; |
| $query .= "InactiveDate >= CURRENT_DATE() )) ) AND IsActive=1 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); |
| } |
| |
| print("<form name=\"addcommiter\" method=\"post\" action=\"add_bugzilla_committer.php\">"); |
| print("<select name=\"plonprojects\">"); |
| while ($myrow = mysql_fetch_array($result)) { |
| echo "<option>" . $myrow["ProjectID"] ."</option>"; |
| } |
| print("</select> "); |
| print("<input type=\"submit\" name=\"User\" value=\" Edit permissions ... \">"); |
| } |
| else { |
| print "<p>Only Project Leads and PMC members can delegate permissions to committers.</p>"; |
| } |
| print("</form>"); |
| |
| //check to see if this person has any projects the can edit. |
| $query = "select COUNT(*) ProjectID from PeopleProjects where PersonID = '" . $_SESSION['uid'] . "';"; |
| 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); |
| } |
| |
| $projects = mysql_fetch_array($result); |
| |
| debug_msg("count is:" . $projects['ProjectID'] , 2); |
| if( $projects['ProjectID'] >= 1) { |
| debug_msg("you're a committer!",1); |
| //now determine what projects you have access to |
| $query = "SELECT ProjectID FROM Projects WHERE ( ProjectID IN (SELECT ProjectID FROM PeopleProjects WHERE PersonID ='". $_SESSION['uid'] ."' "; |
| $query .= " AND ( Relation IN ('PM','PD','PL' ) OR ( Relation='CM' AND EditBugs=1 ) ) AND (InactiveDate is NULL OR InactiveDate >= CURRENT_DATE() ) ) OR ParentProjectID IN (SELECT "; |
| $query .= "ProjectID FROM PeopleProjects WHERE PersonID = '". $_SESSION['uid'] ."' AND Relation IN ('PM','PD' ) AND (InactiveDate is NULL OR "; |
| $query .= "InactiveDate >= CURRENT_DATE() )) ) AND IsActive=1 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); |
| } |
| //check that you actually have access to something |
| debug_msg("Num rows: " . mysql_num_rows($result), 2); |
| print "<br /><br /><h2>Bugzilla management</h2>"; |
| print("<br /><p>Use this interface to edit bugzilla components, add versions and add milestones for your project(s)</p>"); |
| |
| if( mysql_num_rows($result) != 0 ) { |
| print("<form name=\"editbugs\" method=\"post\" action=\"edit_bugzilla_project.php\">"); |
| print("<select name=\"cmonprojects\">"); |
| while ($myrow = mysql_fetch_array($result)) { |
| echo "<option>" . $myrow["ProjectID"] ."</option>"; |
| } |
| print("</select> "); |
| print('<input type="submit" name="Project" value=" Edit ... ">'); |
| print("</form>"); |
| //Add a message just in case people think they should see somthing and don't. |
| $text = "<br /><p>If you don't see a project you think you should have access to, please talk to the projects lead or PMC member to have them grant you edit permission.</p>\n\r"; |
| print($text); |
| } else { |
| $text = "<p>It looks like you don't have access to edit any bugzilla components.</br>"; |
| $text .= " Talk to the PL or PMC of your project(s)</p>\n\r"; |
| print($text); |
| } |
| } else { //Default "you have no access message" |
| |
| $text = "<p>You don't have access to edit any bugzilla components. Please refer to your Project Lead or PMC for access.</p>\n\r"; |
| print($text); |
| |
| } |
| } |
| $fdbc->disconnect(); |
| |
| echo "</div>"; |
| |
| $html = ob_get_contents(); |
| ob_end_clean(); |
| |
| $App->generatePage($theme, $Menu, null, $pageAuthor, $pageKeywords, $pageTitle, $html); |
| |
| ?> |