| <?php | |
| /******************************************************************************* | |
| * Copyright (c) 2013, 2017 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 | |
| *******************************************************************************/ | |
| require_once dirname(__FILE__) . '/classes/Forge.class.inc'; | |
| require_once dirname(__FILE__) . '/classes/common.php'; | |
| require_once dirname(__FILE__) . '/classes/debug.php'; | |
| $actions = array( | |
| array('name' => 'Project Information', 'code' => 'pmi', 'resource' => ''), | |
| array('name' => 'Nominate a Committer', 'code' => 'cm', 'resource' => '/nominate/CM'), | |
| array('name' => 'Nominate a Project Lead', 'code' => 'pl', 'resource' => '/nominate/PL'), | |
| array('name' => 'Create a CQ', 'code' => 'cq', 'resource' => '/cq/create'), | |
| array('name' => 'Generate IP Log', 'code' => 'iplog', 'resource' => '/generate-iplog'), | |
| ); | |
| if (isset($_GET['id'])) $id = $_GET['id']; | |
| else if (isset($_GET['projectid'])) $id = $_GET['projectid']; | |
| function getAction($code) { | |
| global $actions; | |
| foreach($actions as $action) { | |
| if ($code == $action['code']) return $action['resource']; | |
| } | |
| return ''; | |
| } | |
| // If we've been passed a valid project id, then jump to | |
| // that project. If we've been passed an action code, then | |
| // qualify the target URL appropriately. | |
| if (isValidProjectId($id)) { | |
| if ($forge = Forge::getForgeForProjectId($id)) { | |
| $url = $forge->getUrl(); | |
| $id = $forge->getLocalProjectId($id); | |
| $action = getAction(@$_GET['action']); | |
| header("Location:$url/projects/{$id}{$action}"); | |
| return; | |
| } | |
| } | |
| // We don't have a valid project id, so we need | |
| // to be more clever. | |
| require_once dirname(__FILE__) . '/classes/Project.class.php'; | |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php"); | |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/friends/friend.class.php"); | |
| $App = new App(); | |
| function getUserId() { | |
| global $App; | |
| // This call will exit() if there's no logged in user, but check anyway | |
| // because sometimes APIs change. | |
| if (!$Session = $App->useSession(TRUE)) return null; | |
| if (!$Friend = $Session->getFriend()) return null; | |
| if (!$userId = $Friend->getLDAPUID()) return null; | |
| return $userId; | |
| } | |
| function getProjectsForUser() { | |
| if (!$userId = getUserId()) return array(); | |
| return Project::getProjectsForCommitter($userId); | |
| } | |
| // If we cannot figure out any projects for which the user is | |
| // a committer, then bail out. Depending on how the required | |
| // session stuff works, this may never actually happen. | |
| if (!$projects = getProjectsForUser()) { | |
| // There's nothing that we can do for an unauthenticated user. | |
| header("Location:index.php"); | |
| exit(); | |
| } | |
| // If the user is a committer on exactly one project, then | |
| // just jump to that project. Note that we use a recursive | |
| // redirect to this file that should not result in repeated | |
| // recursion given that we're pulling out what will very certainly | |
| // be a valid project id. | |
| if (count($projects) == 1) { | |
| $project = $projects[0]; | |
| $parameters = array('id=' . $project->getId()); | |
| if (isset($_GET['action'])) $parameters[] = 'action=' . $_GET['action']; | |
| $url = 'project.php?' . implode('&', $parameters); | |
| header("Location:$url"); | |
| exit(); | |
| } | |
| // The user is associated with more than one project, render | |
| // a page with a list of projects and links to the sorts of things | |
| // they can do. | |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php"); | |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php"); | |
| $Nav = new Nav(); | |
| $Menu = new Menu(); | |
| $App->preventCaching(); | |
| include($App->getProjectCommon()); | |
| $pageTitle = "Eclipse Projects"; | |
| $pageAuthor = ""; | |
| $pageKeywords = ""; | |
| ob_start(); | |
| ?> | |
| <div class='homeitem'> | |
| <h3>Pick a Project</h3> | |
| <p>Our records show that you are a committer on the following projects: | |
| <?php | |
| foreach($projects as $project) { | |
| $name = $project->getFormalName(); | |
| $id = $project->getId(); | |
| $url = $project->getUrl(); | |
| echo "<h3>$name</h3>"; | |
| echo "<p>"; | |
| foreach($actions as $action) { | |
| $title = $action['name']; | |
| $code = $action['code']; | |
| $resource = $action['resource']; | |
| echo " <a href=\"{$url}{$resource}\"><img width=\"75px\" alt=\"$title\" src=\"images/{$code}.png\"/></a>"; | |
| } | |
| echo "</p>"; | |
| } | |
| ?> | |
| </div> | |
| <?php | |
| $html = ob_get_contents(); | |
| ob_end_clean(); | |
| $App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords, $pageTitle, $html); | |
| ?> |