3 * FusionForge Projects Redirector
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * Copyright 2010 (c) FusionForge Team
8 * http://fusionforge.org/
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * This script provides support for some REST-like paths in the form /projects/PROJNAME/...
30 require_once 'env.inc.php';
31 require_once $gfcommon.'include/pre.php';
34 * Call hooks for content-negociated display
35 * @param string $hook_name - the hook to be invoked
36 * @param array $hook_params - its params
37 * @param string $accepted_type - the Accept type that is expected
38 * @param string $forced_content_type - a forced content-type for debugging purposes
40 function display_content_negociated_hook($hook_name, $hook_params, $accepted_type, $forced_content_type = false)
43 // The hook probably needs other params but take for granted these need an 'accept' param
44 $hook_params['accept'] = $accepted_type;
46 plugin_hook_by_reference($hook_name, $hook_params);
48 $content_type = $hook_params['content_type'];
50 // If the hooks return a content-type
51 if($content_type != ''){
53 // The returned content-type may be overriden
54 if($forced_content_type) {
55 $content_type = $forced_content_type;
58 header('Content-type: '. $content_type);
59 echo $hook_params['content'];
62 header('HTTP/1.1 406 Not Acceptable',true,406);
63 exit_error('HTTP/1.1 406 Not Acceptable - Not possible to display as : ' . $accepted_type);
67 $default_content_type = 'text/html';
69 // It may be invoked with
70 // http://fusionforge.example.com/projects/PROJNAME?forced_accept=application/rdf%2Bxml&forced_content_type=text/html (urlencoded) for instance
72 // Instead of content-negociating with an Accept: header, potentially use the forced_accept arg
73 $forced_accept = getStringFromRequest('forced_accept', false);
75 // Instead of displaying the default rendering for the content-type, may force it with forced_content_type arg (text/plain for instance instead of XML)
76 $forced_content_type = getStringFromRequest('forced_content_type', false);
81 // Setting up the $RESTPATH_PROJECTS_GROUP_ID and $RESTPATH_PROJECTS_PROJECT object is all being
82 // handled in the logger now (see logger.php)
83 // This was done so the logger would accurately record these pages
85 // A valid project name gives a valid group_id and project object, whereas both unset means /projects
86 // A group_id set to -1 means an unknown project
88 global $RESTPATH_PROJECTS_GROUP_ID;
89 $group_id = $RESTPATH_PROJECTS_GROUP_ID;
90 global $RESTPATH_PROJECTS_PROJECT;
91 $project = $RESTPATH_PROJECTS_PROJECT;
93 if (!isset($group_id) && !isset($project)) {
95 $script = 'projects_list';
97 // Check for an acceptable content-type
98 $accepted_type = util_negociate_alternate_content_types($script, $default_content_type, $forced_accept);
100 if($accepted_type != $default_content_type) {
102 $hook_params = array();
103 $hook_params['return'] = '';
104 $hook_params['content_type'] = '';
106 display_content_negociated_hook('content_negociated_projects_list', $hook_params, $accepted_type, $forced_content_type);
109 // '/projects' in HTML redirects to the softwaremap
110 session_redirect(util_make_uri('/softwaremap/'));
115 if (isset($group_id) && isset($project)) {
116 // reuse vars from logger.php too if not specified explicitely ?
117 global $RESTPATH_PROJECTS_SUBPAGE;
118 $subpage = getStringFromRequest('subpage');
119 $subpage = isset($subpage)?$subpage:$RESTPATH_PROJECTS_SUBPAGE;
120 global $RESTPATH_PROJECTS_SUBPAGE2;
121 $subpage2 = getStringFromRequest('subpage2');
122 $subpage2 = isset($subpage2)?$subpage2:$RESTPATH_PROJECTS_SUBPAGE2;
124 if ($subpage == "admin") {
126 session_redirect("/project/admin/?group_id=$group_id");
128 } else if ($subpage == "files" || $subpage == "download" || $subpage == "dl") {
130 if ($subpage2 == "release") {
131 session_redirect("/frs/admin/qrs.php?group_id=$group_id");
133 session_redirect("/frs/?group_id=$group_id");
136 } else if ($subpage == "cvs") {
137 header("Location: ".account_group_cvsweb_url($project->getUnixName()));
142 $script='project_home';
144 $accepted_type = util_negociate_alternate_content_types($script, $default_content_type, $forced_accept);
146 // if a custom content-type is selected, then use plugin's/hooks rendering
147 if($accepted_type != $default_content_type) {
149 $hook_params = array();
150 $hook_params['groupname'] = $project->getUnixName();
151 $hook_params['group_id'] = $project->getID();
152 $hook_params['return'] = '';
153 $hook_params['content_type'] = '';
155 display_content_negociated_hook('content_negociated_project_home', $hook_params, $accepted_type, $forced_content_type);
158 // show the project summary page for HTML display
159 include $gfwww.'include/project_home.php';
164 header('HTTP/1.1 404 Not Found',true,404);
165 exit_error('HTTP/1.1 404 Not Found');
171 // c-file-style: "bsd"