| <?php |
| /******************************************************************************* |
| * Copyright (c) 2008, 2016 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 |
| *******************************************************************************/ |
| |
| /* |
| * This file is deprecated. Calls to this file will redirect to the |
| * corresponding functionality in the PMI when a valid project |
| * id is provided, or to the project root otherwise. |
| * |
| * The PMI has its own links directly to the generator. |
| */ |
| |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php"); |
| $App = new App(); |
| |
| require_once dirname(__FILE__) . "/classes/Project.class.php"; |
| require_once dirname(__FILE__) . "/classes/common.php"; |
| require_once dirname(__FILE__) . "/classes/debug.php"; |
| |
| /** |
| * Iterate through the list of project ids provided and |
| * keep only those ids that map to actual existing projects. |
| */ |
| function getProjectIdsFromRequest() { |
| if (!$params = split(',', getRawProjectIdsFromRequest())) return null; |
| $ids = array(); |
| foreach($params as $id) { |
| if (isValidProjectId($id)) $ids[] = $id; |
| } |
| return $ids; |
| } |
| |
| /** |
| * The ids of the projects that we're going to work with can |
| * be specified in either the 'id' or 'projectid' parameters. |
| * Regardless of which parameter is used, we expect a |
| * comma-separated list of project ids. |
| */ |
| function getRawProjectIdsFromRequest() { |
| if (isset($_REQUEST['id'])) return $_REQUEST['id']; |
| if (isset($_REQUEST['projectid'])) return $_REQUEST['projectid']; |
| return array(); |
| } |
| |
| /** |
| * Answer the top-most project hierarchically in the list of project ids. |
| * Most of the time, this will be exactly one project, but in some cases |
| * (e.g. the Eclipse Project) multiples are provided. |
| */ |
| function getRootProjectId() { |
| $ids = getProjectIdsFromRequest(); |
| if (count($ids) == 1) return $ids[0]; |
| |
| /** |
| * Keep things very simple. Sort the list so that the |
| * entry with the smallest number of segments (separated by |
| * dots) is the first thing in the list. Assume that the |
| * first entry after sorting is the top-most project |
| * hierarchically. |
| * |
| * FIXME Determine how to deal with top-most siblings. |
| * |
| * This is pretty inefficient since we'll end up recomputing |
| * values repeatedly. However, this script isn't called |
| * very often, the check for a single value will bail us |
| * out before we get to this point most of the time, and |
| * the inefficiency really isn't that bad given that the |
| * size of the array will always be pretty small. |
| */ |
| usort($ids, function($a, $b) { |
| $oa = count(preg_split('/./', $a)); |
| $ob = count(preg_split('/./', $b)); |
| |
| return $oa == $ob ? 0 : ($oa > $ob ? 1 : -1); |
| }); |
| |
| return $ids[0]; |
| } |
| |
| /* |
| * Search for the top-most project in the list of project ids. |
| * If there is one, then redirect to the PMI instance for IP Log |
| * generation. |
| * |
| * Note that we try to find the next release and generate the |
| * IP Log based on that (releases may include subprojects and |
| * we need to include them). If there is no next release, then |
| * just open the IP Log generator on the project itself. |
| */ |
| $url = "/projects"; |
| if ($parent = getRootProjectId()) { |
| if ($project = get_project_from_pmi($parent)) { |
| if ($release = $project->getNextRelease()) { |
| $url = $release->getUrl(); |
| } else { |
| $url = $project->getUrl(); |
| } |
| $url = "$url/iplog/preview"; |
| } |
| } |
| |
| header("Location: $url"); |
| exit(); |
| |
| ?> |