Blame Identity/Models/Html/Mantis/1.1.2-1.fc9/proj_doc_page.php

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

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