SOAP API: do not try to unserialize an invalid filter
[mantis.git] / proj_doc_page.php
blobafa53d5367ca2b14ba5695351acc3444cff5f52f
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 - 2011 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 /**
41 * MantisBT Core API's
43 require_once( 'core.php' );
44 require_api( 'access_api.php' );
45 require_api( 'authentication_api.php' );
46 require_api( 'config_api.php' );
47 require_api( 'constant_inc.php' );
48 require_api( 'database_api.php' );
49 require_api( 'file_api.php' );
50 require_api( 'gpc_api.php' );
51 require_api( 'helper_api.php' );
52 require_api( 'html_api.php' );
53 require_api( 'lang_api.php' );
54 require_api( 'print_api.php' );
55 require_api( 'project_api.php' );
56 require_api( 'string_api.php' );
57 require_api( 'user_api.php' );
59 $f_project_id = gpc_get_int( 'project_id', helper_get_current_project() );
61 # Check if project documentation feature is enabled.
62 if ( OFF == config_get( 'enable_project_documentation' ) || !file_is_uploading_enabled() ) {
63 access_denied();
66 # Override the current page to make sure we get the appropriate project-specific configuration
67 $g_project_override = $f_project_id;
69 $t_user_id = auth_get_current_user_id();
70 $t_project_file_table = db_get_table( 'project_file' );
71 $t_project_table = db_get_table( 'project' );
72 $t_project_user_list_table = db_get_table( 'project_user_list' );
73 $t_user_table = db_get_table( 'user' );
74 $t_pub = VS_PUBLIC;
75 $t_priv = VS_PRIVATE;
76 $t_admin = config_get_global( 'admin_site_threshold' );
78 if ( $f_project_id == ALL_PROJECTS ) {
79 # Select all the projects that the user has access to
80 $t_projects = user_get_accessible_projects( $t_user_id );
81 } else {
82 # Select the specific project
83 $t_projects = array( $f_project_id );
86 $t_projects[] = ALL_PROJECTS; # add "ALL_PROJECTS to the list of projects to fetch
88 $t_reqd_access = config_get( 'view_proj_doc_threshold' );
89 if ( is_array( $t_reqd_access ) ) {
90 if ( 1 == count( $t_reqd_access ) ) {
91 $t_access_clause = "= " . array_shift( $t_reqd_access ) . " ";
92 } else {
93 $t_access_clause = "IN (" . implode( ',', $t_reqd_access ) . ")";
95 } else {
96 $t_access_clause = ">= $t_reqd_access ";
99 $query = "SELECT pft.id, pft.project_id, pft.filename, pft.filesize, pft.title, pft.description, pft.date_added
100 FROM $t_project_file_table pft
101 LEFT JOIN $t_project_table pt ON pft.project_id = pt.id
102 LEFT JOIN $t_project_user_list_table pult
103 ON pft.project_id = pult.project_id AND pult.user_id = $t_user_id
104 LEFT JOIN $t_user_table ut ON ut.id = $t_user_id
105 WHERE pft.project_id in (" . implode( ',', $t_projects ) . ") AND
106 ( ( ( 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
107 ( ( pult.user_id = $t_user_id ) AND ( pult.access_level $t_access_clause ) ) OR
108 ( ut.access_level >= $t_admin ) )
109 ORDER BY pt.name ASC, pft.title ASC";
110 $result = db_query( $query );
111 $num_files = db_num_rows( $result );
113 html_page_top( lang_get( 'docs_link' ) );
115 <br />
116 <div>
117 <table class="width100" cellspacing="1">
118 <tr>
119 <td class="form-title">
120 <?php echo lang_get( 'project_documentation_title' ) ?>
121 </td>
122 <td class="right">
123 <?php print_doc_menu( 'proj_doc_page.php' ) ?>
124 </td>
125 </tr>
126 <?php
127 for ($i=0;$i<$num_files;$i++) {
128 $row = db_fetch_array( $result );
129 extract( $row, EXTR_PREFIX_ALL, 'v' );
130 $v_filesize = number_format( $v_filesize );
131 $v_title = string_display( $v_title );
132 $v_description = string_display_links( $v_description );
133 $v_date_added = date( config_get( 'normal_date_format' ), $v_date_added );
136 <tr <?php echo helper_alternate_class( $i ) ?>>
137 <td>
138 <?php
139 $t_href = '<a href="file_download.php?file_id='.$v_id.'&amp;type=doc">';
140 echo $t_href;
141 print_file_icon( $v_filename );
142 echo '</a>&#160;' . $t_href . $v_title . '</a> (' . $v_filesize . lang_get( 'word_separator' ) . lang_get( 'bytes' ) . ')';
144 <br />
145 <span class="small">
146 <?php
147 if( $v_project_id == ALL_PROJECTS ) {
148 echo lang_get( 'all_projects' ) . '<br/>';
150 else if( $v_project_id != $f_project_id ) {
151 $t_project_name = project_get_name( $v_project_id );
152 echo $t_project_name . '<br/>';
154 echo '(' . $v_date_added . ')';
155 if ( access_has_project_level( config_get( 'upload_project_file_threshold', null, null, $v_project_id ), $v_project_id ) ) {
156 echo '&#160;';
157 print_button( 'proj_doc_edit_page.php?file_id='.$v_id, lang_get( 'edit_link' ) );
158 echo '&#160;';
159 print_button( 'proj_doc_delete.php?file_id=' . $v_id, lang_get( 'delete_link' ) );
162 </span>
163 </td>
164 <td>
165 <?php echo $v_description ?>
166 </td>
167 </tr>
168 <?php
169 } # end for loop
171 </table>
172 </div>
174 <?php
175 html_page_bottom();