Blame Extras/Mantis/1.1.2-1.fc9/proj_doc_page.php

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

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