<?php
/**
 * FusionForge Projects Redirector
 *
 * Copyright 1999-2001 (c) VA Linux Systems
 * Copyright 2002-2004 (c) GForge Team
 * Copyright 2010 (c) FusionForge Team
 * http://fusionforge.org/
 *
 * This file is part of FusionForge. FusionForge is free software;
 * you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the Licence, or (at your option)
 * any later version.
 *
 * FusionForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

require_once 'env.inc.php';
require_once $gfcommon.'include/pre.php';

//
//	IMPORTANT NOTE!!
//	Setting up the $project object is all being
//	handled in the logger now
//	This was done so the logger would accurately record these pages
//

//
//	test to see if the logger was successful in setting up the objects
//

$default_content_type = 'text/html';
$script='project_home';
$content_type = util_negociate_alternate_content_types($script, $default_content_type);

if (!$group_id || !$project) {
	exit_no_group();
} else {
	$subpage = getStringFromRequest('subpage');

	if ($subpage == "admin") {
		session_redirect(util_make_url("/project/admin/?group_id=$group_id"));
	} else if ($subpage == "files" || $subpage == "download" || $subpage == "dl") {
		if (getStringFromRequest('subpage2') == "release") {
			session_redirect(util_make_url("/frs/admin/qrs.php?group_id=$group_id"));
		} else {
			session_redirect(util_make_url("/frs/?group_id=$group_id"));
		}
	} else if ($subpage == "cvs") {
		header("Location: ".account_group_cvsweb_url($project->getUnixName()));
		exit();
	} else {
		// if a custom content-type is selected, then redirect to plugin's rendering
		if($content_type != $default_content_type) {
			$hook_params = array();
			$hook_params['groupname'] = $project->getUnixName();
			$hook_params['accept'] = $content_type;
			$hook_params['return'] = '';
			$hook_params['content_type'] = '';
			$hook_params['group_id'] = $project->getID();
			plugin_hook_by_reference('content_negociated_project_home', $hook_params);
			if($hook_params['content_type'] != ''){
				header('Content-type: '. $hook_params['content_type']);
				echo $hook_params['content'];
			}
			else {
				header('HTTP/1.1 406 Not Acceptable',true,406);
				exit(0);
			}
		} else {
			//show the project summary page
			include $gfwww.'include/project_home.php';
		}
	}
}

// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:

?>
