Blame Identity/Webenv/Mantis/1.1.2-1.fc9/proj_doc_page.php

ef5584
ef5584
# Mantis - a php based bugtracking system
ef5584
ef5584
# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
ef5584
# Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
ef5584
ef5584
# Mantis is free software: you can redistribute it and/or modify
ef5584
# it under the terms of the GNU General Public License as published by
ef5584
# the Free Software Foundation, either version 2 of the License, or
ef5584
# (at your option) any later version.
ef5584
#
ef5584
# Mantis is distributed in the hope that it will be useful,
ef5584
# but WITHOUT ANY WARRANTY; without even the implied warranty of
ef5584
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ef5584
# GNU General Public License for more details.
ef5584
#
ef5584
# You should have received a copy of the GNU General Public License
ef5584
# along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
ef5584
ef5584
	# --------------------------------------------------------
ef5584
	# $Id: proj_doc_page.php,v 1.53.2.1 2007-10-13 22:34:24 giallu Exp $
ef5584
	# --------------------------------------------------------
ef5584
ef5584
	require_once( 'core.php' );
ef5584
ef5584
	$t_core_path = config_get( 'core_path' );
ef5584
ef5584
	require_once( $t_core_path.'string_api.php' );
ef5584
	
ef5584
	$f_project_id = gpc_get_int( 'project_id', helper_get_current_project() );
ef5584
ef5584
	# Check if project documentation feature is enabled.
ef5584
	if ( OFF == config_get( 'enable_project_documentation' ) || !file_is_uploading_enabled() ) {
ef5584
		access_denied();
ef5584
	}
ef5584
ef5584
	# Override the current page to make sure we get the appropriate project-specific configuration
ef5584
	$g_project_override = $f_project_id;
ef5584
ef5584
	$t_user_id = auth_get_current_user_id();
ef5584
	$t_project_file_table = config_get( 'mantis_project_file_table' );
ef5584
	$t_project_table = config_get( 'mantis_project_table' );
ef5584
	$t_project_user_list_table = config_get( 'mantis_project_user_list_table' );
ef5584
	$t_user_table = config_get( 'mantis_user_table' );
ef5584
	$t_pub = VS_PUBLIC;
ef5584
	$t_priv = VS_PRIVATE;
ef5584
	$t_admin = ADMINISTRATOR;
ef5584
ef5584
	if ( $f_project_id == ALL_PROJECTS ) {
ef5584
		# Select all the projects that the user has access to
ef5584
		$t_projects = user_get_accessible_projects( $t_user_id );
ef5584
	} else {
ef5584
		# Select the specific project 
ef5584
		$t_projects = array( $f_project_id );
ef5584
	}
ef5584
ef5584
	$t_projects[] = ALL_PROJECTS; # add "ALL_PROJECTS to the list of projects to fetch
ef5584
	
ef5584
	$t_reqd_access = config_get( 'view_proj_doc_threshold' );
ef5584
	if ( is_array( $t_reqd_access ) ) {
ef5584
		if ( 1 == count( $t_reqd_access ) ) {
ef5584
			$t_access_clause = "= " . array_shift( $t_reqd_access ) . " ";
ef5584
		} else {
ef5584
			$t_access_clause = "IN (" . implode( ',', $t_reqd_access ) . ")";
ef5584
		}
ef5584
	} else {
ef5584
		$t_access_clause = ">= $t_reqd_access ";
ef5584
	}			
ef5584
ef5584
	$query = "SELECT pft.id, pft.project_id, pft.filename, pft.filesize, pft.title, pft.description, pft.date_added
ef5584
				FROM $t_project_file_table pft
ef5584
					LEFT JOIN $t_project_table pt ON pft.project_id = pt.id
ef5584
					LEFT JOIN $t_project_user_list_table pult 
ef5584
						ON pft.project_id = pult.project_id AND pult.user_id = $t_user_id
ef5584
					LEFT JOIN $t_user_table ut ON ut.id = $t_user_id
ef5584
				WHERE pft.project_id in (" . implode( ',', $t_projects ) . ") AND
ef5584
					( ( ( pt.view_state = $t_pub OR pt.view_state is null ) AND pult.user_id is null AND ut.access_level $t_access_clause ) OR
ef5584
						( ( pult.user_id = $t_user_id ) AND ( pult.access_level $t_access_clause ) ) OR
ef5584
						( ut.access_level = $t_admin ) )
ef5584
				ORDER BY pt.name ASC, pft.title ASC";
ef5584
	$result = db_query( $query );
ef5584
	$num_files = db_num_rows( $result );
ef5584
ef5584
	html_page_top1( lang_get( 'docs_link' ) );
ef5584
	html_page_top2();
ef5584
?>
ef5584

ef5584
ef5584
ef5584
ef5584
	
ef5584
		
ef5584
	
ef5584
	
ef5584
		
ef5584
	
ef5584
ef5584
ef5584
	for ($i=0;$i<$num_files;$i++) {
ef5584
		$row = db_fetch_array( $result );
ef5584
		extract( $row, EXTR_PREFIX_ALL, 'v' );
ef5584
		$v_filesize = number_format( $v_filesize );
ef5584
		$v_title = string_display( $v_title );
ef5584
		$v_description = string_display_links( $v_description );
ef5584
		$v_date_added = date( config_get( 'normal_date_format' ), db_unixtimestamp( $v_date_added ) );
ef5584
ef5584
?>
ef5584
>
ef5584
	
ef5584
ef5584
		$t_href = '';
ef5584
		echo $t_href;
ef5584
		print_file_icon( $v_filename );
ef5584
		echo ' ' . $t_href . $v_title . ' ('.$v_filesize.' bytes)';
ef5584
?>
ef5584
	
ef5584
	
ef5584
ef5584
		if( $v_project_id == ALL_PROJECTS ) {
ef5584
			echo lang_get( 'all_projects' ) . '
';
ef5584
		}
ef5584
		elseif( $v_project_id != $f_project_id ) {
ef5584
			$t_project_name = project_get_name( $v_project_id );
ef5584
			echo $t_project_name . '
';
ef5584
		}
ef5584
		echo '(' . $v_date_added . ')';
ef5584
		if ( access_has_project_level( config_get( 'manage_project_threshold', null, null, $v_project_id ), $v_project_id ) ) {
ef5584
			echo ' ';
ef5584
			print_button( 'proj_doc_edit_page.php?file_id='.$v_id, lang_get( 'edit_link' ) );
ef5584
			echo ' ';
ef5584
			print_button( 'proj_doc_delete.php?file_id=' . $v_id, lang_get( 'delete_link' ) );
ef5584
		}
ef5584
?>
ef5584
	
ef5584
	
ef5584
	
ef5584
		
ef5584
	
ef5584
ef5584
ef5584
	} # end for loop
ef5584
?>
ef5584
ef5584
ef5584
ef5584