Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / proj_doc_page.php
blobdcae3936961a8226e5fd2098e5419761db3e266d
1 <?php
2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
23 * @uses core.php
24 * @uses access_api.php
25 * @uses authentication_api.php
26 * @uses config_api.php
27 * @uses constant_inc.php
28 * @uses database_api.php
29 * @uses file_api.php
30 * @uses gpc_api.php
31 * @uses helper_api.php
32 * @uses html_api.php
33 * @uses lang_api.php
34 * @uses print_api.php
35 * @uses project_api.php
36 * @uses string_api.php
37 * @uses user_api.php
40 require_once( 'core.php' );
41 require_api( 'access_api.php' );
42 require_api( 'authentication_api.php' );
43 require_api( 'config_api.php' );
44 require_api( 'constant_inc.php' );
45 require_api( 'database_api.php' );
46 require_api( 'file_api.php' );
47 require_api( 'gpc_api.php' );
48 require_api( 'helper_api.php' );
49 require_api( 'html_api.php' );
50 require_api( 'lang_api.php' );
51 require_api( 'print_api.php' );
52 require_api( 'project_api.php' );
53 require_api( 'string_api.php' );
54 require_api( 'user_api.php' );
56 $f_project_id = gpc_get_int( 'project_id', helper_get_current_project() );
58 # Check if project documentation feature is enabled.
59 if ( OFF == config_get( 'enable_project_documentation' ) || !file_is_uploading_enabled() ) {
60 access_denied();
63 # Override the current page to make sure we get the appropriate project-specific configuration
64 $g_project_override = $f_project_id;
66 $t_user_id = auth_get_current_user_id();
67 $t_project_file_table = db_get_table( 'project_file' );
68 $t_project_table = db_get_table( 'project' );
69 $t_project_user_list_table = db_get_table( 'project_user_list' );
70 $t_user_table = db_get_table( 'user' );
71 $t_pub = VS_PUBLIC;
72 $t_priv = VS_PRIVATE;
73 $t_admin = config_get_global( 'admin_site_threshold' );
75 if ( $f_project_id == ALL_PROJECTS ) {
76 # Select all the projects that the user has access to
77 $t_projects = user_get_accessible_projects( $t_user_id );
78 } else {
79 # Select the specific project
80 $t_projects = array( $f_project_id );
83 $t_projects[] = ALL_PROJECTS; # add "ALL_PROJECTS to the list of projects to fetch
85 $t_reqd_access = config_get( 'view_proj_doc_threshold' );
86 if ( is_array( $t_reqd_access ) ) {
87 if ( 1 == count( $t_reqd_access ) ) {
88 $t_access_clause = "= " . array_shift( $t_reqd_access ) . " ";
89 } else {
90 $t_access_clause = "IN (" . implode( ',', $t_reqd_access ) . ")";
92 } else {
93 $t_access_clause = ">= $t_reqd_access ";
96 $query = "SELECT pft.id, pft.project_id, pft.filename, pft.filesize, pft.title, pft.description, pft.date_added
97 FROM $t_project_file_table pft
98 LEFT JOIN $t_project_table pt ON pft.project_id = pt.id
99 LEFT JOIN $t_project_user_list_table pult
100 ON pft.project_id = pult.project_id AND pult.user_id = $t_user_id
101 LEFT JOIN $t_user_table ut ON ut.id = $t_user_id
102 WHERE pft.project_id in (" . implode( ',', $t_projects ) . ") AND
103 ( ( ( 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
104 ( ( pult.user_id = $t_user_id ) AND ( pult.access_level $t_access_clause ) ) OR
105 ( ut.access_level >= $t_admin ) )
106 ORDER BY pt.name ASC, pft.title ASC";
107 $result = db_query( $query );
108 $num_files = db_num_rows( $result );
110 html_page_top( lang_get( 'docs_link' ) );
112 <br />
113 <div align="center">
114 <table class="width100" cellspacing="1">
115 <tr>
116 <td class="form-title">
117 <?php echo lang_get( 'project_documentation_title' ) ?>
118 </td>
119 <td class="right">
120 <?php print_doc_menu( 'proj_doc_page.php' ) ?>
121 </td>
122 </tr>
123 <?php
124 for ($i=0;$i<$num_files;$i++) {
125 $row = db_fetch_array( $result );
126 extract( $row, EXTR_PREFIX_ALL, 'v' );
127 $v_filesize = number_format( $v_filesize );
128 $v_title = string_display( $v_title );
129 $v_description = string_display_links( $v_description );
130 $v_date_added = date( config_get( 'normal_date_format' ), $v_date_added );
133 <tr valign="top" <?php echo helper_alternate_class( $i ) ?>>
134 <td>
135 <?php
136 $t_href = '<a href="file_download.php?file_id='.$v_id.'&amp;type=doc">';
137 echo $t_href;
138 print_file_icon( $v_filename );
139 echo '</a>&nbsp;' . $t_href . $v_title . '</a> (' . $v_filesize . lang_get( 'word_separator' ) . lang_get( 'bytes' ) . ')';
141 <br />
142 <span class="small">
143 <?php
144 if( $v_project_id == ALL_PROJECTS ) {
145 echo lang_get( 'all_projects' ) . '<br/>';
147 else if( $v_project_id != $f_project_id ) {
148 $t_project_name = project_get_name( $v_project_id );
149 echo $t_project_name . '<br/>';
151 echo '(' . $v_date_added . ')';
152 if ( access_has_project_level( config_get( 'upload_project_file_threshold', null, null, $v_project_id ), $v_project_id ) ) {
153 echo '&nbsp;';
154 print_button( 'proj_doc_edit_page.php?file_id='.$v_id, lang_get( 'edit_link' ) );
155 echo '&nbsp;';
156 print_button( 'proj_doc_delete.php?file_id=' . $v_id, lang_get( 'delete_link' ) );
159 </span>
160 </td>
161 <td>
162 <?php echo $v_description ?>
163 </td>
164 </tr>
165 <?php
166 } # end for loop
168 </table>
169 </div>
171 <?php
172 html_page_bottom();