Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / bug_revision_view_page.php
blob330b1d5b20ea80814f5386ed9cd832399244413d
1 <?php
2 # Mantis - a php based bugtracking system
4 # Mantis 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 # Mantis 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 Mantis. 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 bug_api.php
26 * @uses bugnote_api.php
27 * @uses bug_revision_api.php
28 * @uses config_api.php
29 * @uses constant_inc.php
30 * @uses form_api.php
31 * @uses gpc_api.php
32 * @uses helper_api.php
33 * @uses html_api.php
34 * @uses lang_api.php
35 * @uses print_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( 'bug_api.php' );
43 require_api( 'bugnote_api.php' );
44 require_api( 'bug_revision_api.php' );
45 require_api( 'config_api.php' );
46 require_api( 'constant_inc.php' );
47 require_api( 'form_api.php' );
48 require_api( 'gpc_api.php' );
49 require_api( 'helper_api.php' );
50 require_api( 'html_api.php' );
51 require_api( 'lang_api.php' );
52 require_api( 'print_api.php' );
53 require_api( 'string_api.php' );
54 require_api( 'user_api.php' );
56 $f_bug_id = gpc_get_int( 'bug_id', 0 );
57 $f_bugnote_id = gpc_get_int( 'bugnote_id', 0 );
58 $f_rev_id = gpc_get_int( 'rev_id', 0 );
60 $t_title = '';
62 if ( $f_bug_id ) {
63 $t_bug_id = $f_bug_id;
64 $t_bug_data = bug_get( $t_bug_id, true );
65 $t_bug_revisions = array_reverse( bug_revision_list( $t_bug_id ), true );
67 $t_title = lang_get( 'issue_id' ) . $t_bug_id;
69 } else if ( $f_bugnote_id ) {
70 $t_bug_id = bugnote_get_field( $f_bugnote_id, 'bug_id' );
71 $t_bug_data = bug_get( $t_bug_id, true );
73 $t_bug_revisions = array_reverse( bug_revision_list( $t_bug_id, REV_ANY, $f_bugnote_id ), true );
75 $t_title = lang_get( 'bugnote' ) . ' ' . $f_bugnote_id;
77 } else if ( $f_rev_id ) {
78 $t_bug_revisions = array_reverse( bug_revision_like( $f_rev_id ), true );
80 if ( count( $t_bug_revisions ) < 1 ) {
81 trigger_error( ERROR_GENERIC, ERROR );
84 $t_bug_id = $t_bug_revisions[$f_rev_id]['bug_id'];
85 $t_bug_data = bug_get( $t_bug_id, true );
87 $t_title = lang_get( 'issue_id' ) . $t_bug_id;
89 } else {
90 trigger_error( ERROR_GENERIC, ERROR );
93 function show_revision( $t_revision ) {
94 static $s_can_drop = null;
95 static $s_drop_token = null;
96 static $s_user_access = null;
98 if ( is_null( $s_can_drop ) ) {
99 $s_can_drop = access_has_bug_level( config_get( 'bug_revision_drop_threshold' ), $t_revision['bug_id'] );
100 $s_drop_token = form_security_param( 'bug_revision_drop' );
103 switch( $t_revision['type'] ) {
104 case REV_DESCRIPTION:
105 $t_label = lang_get( 'description' );
106 break;
107 case REV_STEPS_TO_REPRODUCE:
108 $t_label = lang_get( 'steps_to_reproduce' );
109 break;
110 case REV_ADDITIONAL_INFO:
111 $t_label = lang_get( 'additional_information' );
112 break;
114 case REV_BUGNOTE:
115 if ( is_null( $s_user_access ) ) {
116 $s_user_access = access_has_bug_level( config_get( 'private_bugnote_threshold' ), $t_revision['bug_id'] );
119 if ( !$s_user_access ) {
120 return null;
123 $t_label = lang_get( 'bugnote' );
124 break;
126 default:
127 $t_label = '';
130 $t_by_string = sprintf( lang_get( 'revision_by' ), string_display_line( date( config_get( 'normal_date_format' ), $t_revision['timestamp'] ) ), string_display_line( user_get_name( $t_revision['user_id'] ) ) );
133 <tr class="spacer"><td><a name="r<?php echo $t_revision['id'] ?>"></a></td></tr>
135 <tr <?php echo helper_alternate_class() ?>>
136 <td class="category"><?php echo lang_get( 'revision' ) ?></td>
137 <td colspan="2"><?php echo $t_by_string ?></td>
138 <td class="center" width="5%">
139 <?php if ( $s_can_drop ) {
140 print_bracket_link( 'bug_revision_drop.php?id=' . $t_revision['id'] . $s_drop_token, lang_get( 'revision_drop' ) );
141 } ?>
142 </tr>
144 <tr <?php echo helper_alternate_class() ?>>
145 <td class="category"><?php echo $t_label ?></td>
146 <td colspan="3"><?php echo string_display_links( $t_revision['value'] ) ?></td>
147 </tr>
149 <?php
152 html_page_top( bug_format_summary( $t_bug_id, SUMMARY_CAPTION ) );
154 print_recently_visited();
158 <br/>
159 <table class="width100" cellspacing="1">
161 <tr>
162 <td class="form-title" colspan="2"><?php echo lang_get( 'view_revisions' ), ': ', $t_title ?></td>
163 <td class="right" colspan="2">
164 <?php
165 if ( !$f_bug_id && !$f_bugnote_id ) { print_bracket_link( '?bug_id=' . $t_bug_id, lang_get( 'all_revisions' ) ); }
166 print_bracket_link( 'view.php?id=' . $t_bug_id, lang_get( 'back_to_issue' ) );
168 </td>
169 </tr>
171 <tr <?php echo helper_alternate_class() ?>>
172 <td class="category" width="15%"><?php echo lang_get( 'summary' ) ?></td>
173 <td colspan="3"><?php echo bug_format_summary( $t_bug_id, SUMMARY_FIELD ) ?></td>
174 </tr>
176 <?php foreach( $t_bug_revisions as $t_rev ) {
177 show_revision( $t_rev );
178 } ?>
180 </table>
182 <?php
183 html_page_bottom();