| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 # MantisBT - A PHP based bugtracking system 3 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. 8 # 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. 13 # 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/>. 16 17 /** 18 * CALLERS 19 * This page is called from: 20 * - print_menu() 21 * - print_account_menu() 22 * 23 * EXPECTED BEHAVIOUR 24 * - Display the user's current sponsorships 25 * - Allow the user to edit the payment flag 26 * 27 * CALLS 28 * This page calls the following pages: 29 * - account_sponsor_update.php (to save changes) 30 * 31 * RESTRICTIONS & PERMISSIONS 32 * - User must be authenticated, and not anonymous 33 * - sponsorship must be enabled 34 * 35 * @package MantisBT 36 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 37 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net 38 * @link http://www.mantisbt.org 39 * 40 * @uses core.php 41 * @uses access_api.php 42 * @uses authentication_api.php 43 * @uses bug_api.php 44 * @uses config_api.php 45 * @uses constant_inc.php 46 * @uses current_user_api.php 47 * @uses database_api.php 48 * @uses form_api.php 49 * @uses gpc_api.php 50 * @uses helper_api.php 51 * @uses html_api.php 52 * @uses lang_api.php 53 * @uses print_api.php 54 * @uses project_api.php 55 * @uses sponsorship_api.php 56 * @uses string_api.php 57 * @uses version_api.php 58 */ 59 60 /** 61 * MantisBT Core API's 62 */ 63 require_once ( 'core.php' ); 64 require_api( 'access_api.php' ); 65 require_api( 'authentication_api.php' ); 66 require_api( 'bug_api.php' ); 67 require_api( 'config_api.php' ); 68 require_api( 'constant_inc.php' ); 69 require_api( 'current_user_api.php' ); 70 require_api( 'database_api.php' ); 71 require_api( 'form_api.php' ); 72 require_api( 'gpc_api.php' ); 73 require_api( 'helper_api.php' ); 74 require_api( 'html_api.php' ); 75 require_api( 'lang_api.php' ); 76 require_api( 'print_api.php' ); 77 require_api( 'project_api.php' ); 78 require_api( 'sponsorship_api.php' ); 79 require_api( 'string_api.php' ); 80 require_api( 'version_api.php' ); 81 82 require_css( 'status_config.php' ); 83 84 if ( !config_get( 'enable_sponsorship' ) ) { 85 trigger_error( ERROR_SPONSORSHIP_NOT_ENABLED, ERROR ); 86 } 87 88 # anonymous users are not allowed to sponsor issues 89 if ( current_user_is_anonymous() ) { 90 access_denied(); 91 } 92 93 $t_show_all = gpc_get_bool( 'show_all', false ); 94 95 # start the page 96 html_page_top( lang_get( 'my_sponsorship' ) ); 97 98 $t_project = helper_get_current_project(); 99 ?> 100 <br /> 101 <table class="width100" cellspacing="1"> 102 <tr> 103 <td class="form-title"> 104 <?php echo lang_get( 'my_sponsorship' ) ?> 105 </td> 106 <td class="right"> 107 <?php print_account_menu( 'account_sponsor_page.php' ) ?> 108 </td> 109 </tr> 110 </table> 111 <?php 112 # get issues user has sponsored 113 $t_user = auth_get_current_user_id(); 114 $t_resolved = config_get( 'bug_resolved_status_threshold' ); 115 $t_bug_table = db_get_table( 'bug' ); 116 $t_sponsor_table = db_get_table( 'sponsorship' ); 117 $t_payment = config_get( 'payment_enable', 0 ); 118 119 $t_project_clause = helper_project_specific_where( $t_project ); 120 121 $query = "SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status 122 FROM $t_bug_table b, $t_sponsor_table s 123 WHERE s.user_id=" . db_param() . " AND s.bug_id = b.id " . 124 ( $t_show_all ? '' : 'AND ( b.status < ' . db_param() . ' OR s.paid < ' . SPONSORSHIP_PAID . ')' ) . " 125 AND $t_project_clause 126 ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC"; 127 128 $result = db_query_bound( $query, $t_show_all ? Array( $t_user ) : Array( $t_user , $t_resolved ) ); 129 130 $t_sponsors = db_num_rows( $result ); 131 if ( 0 == $t_sponsors ) { 132 echo '<p>' . lang_get( 'no_own_sponsored' ) . '</p>'; 133 } else { 134 ?> 135 136 <!-- # Edit own sponsorship Form BEGIN --> 137 <br /> 138 <div> 139 <table class="width100" cellspacing="1"> 140 141 <!-- Headings --> 142 <tr> 143 <td class="form-title" colspan="9"> 144 <?php echo lang_get( 'own_sponsored' ) ?> 145 </td> 146 </tr> 147 <tr> 148 <td class="form-title" width="10%"><?php echo lang_get( 'email_bug' ) ?></td> 149 <td class="form-title" width="8%"><?php echo lang_get( 'email_project' ) ?></td> 150 <td class="form-title" width="7%"><?php echo lang_get( 'fixed_in_version' ) ?></td> 151 <td class="form-title" width="10%"><?php echo lang_get( 'email_status' ) ?></td> 152 <td class="form-title" width="10%"><?php echo lang_get( 'email_handler' ) ?></td> 153 <td class="form-title" width="30%"><?php echo lang_get( 'email_summary' ) ?></td> 154 <td class="form-title" width="8%"><?php echo lang_get( 'amount' ) ?></td> 155 <td class="form-title" width="7%"><?php echo lang_get( 'status' ) ?></td> 156 <td class="form-title" width="10%"> </td> 157 </tr> 158 <?php 159 $t_total_owing = 0; 160 $t_total_paid = 0; 161 for ( $i=0; $i < $t_sponsors; ++$i ) { 162 $row = db_fetch_array( $result ); 163 $t_bug = bug_get( $row['bug'] ); 164 $t_sponsor = sponsorship_get( $row['sponsor'] ); 165 166 # describe bug 167 $t_status = string_attribute( get_enum_element( 'status', $t_bug->status ) ); 168 $t_resolution = string_attribute( get_enum_element( 'resolution', $t_bug->resolution ) ); 169 $t_version_id = version_get_id( $t_bug->fixed_in_version, $t_project ); 170 if ( ( false !== $t_version_id ) && ( VERSION_RELEASED == version_get_field( $t_version_id, 'released' ) ) ) { 171 $t_released_label = '<a title="' . lang_get( 'released' ) . '">' . $t_bug->fixed_in_version . '</a>'; 172 } else { 173 $t_released_label = $t_bug->fixed_in_version; 174 } 175 176 # choose color based on status 177 $status_label = html_get_status_css_class( $t_bug->status ); 178 179 echo '<tr class="' . $status_label . '">'; 180 echo '<td><a href="' . string_get_bug_view_url( $row['bug'] ) . '">' . bug_format_id( $row['bug'] ) . '</a></td>'; 181 echo '<td>' . project_get_field( $t_bug->project_id, 'name' ) . ' </td>'; 182 echo '<td class="right">' . $t_released_label . ' </td>'; 183 echo '<td><span class="issue-status" title="' . $t_resolution . '">' . $t_status . '</span></td>'; 184 echo '<td>'; 185 print_user( $t_bug->handler_id ); 186 echo '</td>'; 187 188 # summary 189 echo '<td>' . string_display_line( $t_bug->summary ); 190 if ( VS_PRIVATE == $t_bug->view_state ) { 191 printf( ' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get( 'private' ), lang_get( 'private' ) ); 192 } 193 echo '</td>'; 194 195 # describe sponsorship amount 196 echo '<td class="right">' . sponsorship_format_amount( $t_sponsor->amount ) . '</td>'; 197 echo '<td>' . get_enum_element( 'sponsorship', $t_sponsor->paid ) . '</td>'; 198 199 if ( SPONSORSHIP_PAID == $t_sponsor->paid ) { 200 $t_total_paid += $t_sponsor->amount; 201 } else { 202 $t_total_owing += $t_sponsor->amount; 203 } 204 205 echo '<td>'; 206 if ( $t_payment ) { 207 echo '(paypal button)'; 208 } else { 209 echo ' '; 210 } 211 echo '</td>'; 212 echo '</tr>'; 213 } 214 ?> 215 <!-- Totals --> 216 <tr> 217 <td colspan="5"></td> 218 <td><?php echo lang_get( 'total_owing' ) ?></td> 219 <td class="right"><?php echo sponsorship_format_amount( $t_total_owing ) ?></td> 220 <td colspan="2"></td> 221 </tr> 222 <tr> 223 <td colspan="5"></td> 224 <td><?php echo lang_get( 'total_paid' ) ?></td> 225 <td class="right"><?php echo sponsorship_format_amount( $t_total_paid ) ?></td> 226 <td colspan="2"></td> 227 </tr> 228 </table> 229 </div> 230 <?php } # end sponsored issues 231 232 $query = "SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status 233 FROM $t_bug_table b, $t_sponsor_table s 234 WHERE b.handler_id=" . db_param() . " AND s.bug_id = b.id " . 235 ( $t_show_all ? '' : 'AND ( b.status < ' . db_param() . ' OR s.paid < ' . SPONSORSHIP_PAID . ')' ) . " 236 AND $t_project_clause 237 ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC"; 238 239 $result = db_query_bound( $query, $t_show_all ? Array( $t_user ) : Array( $t_user , $t_resolved ) ); 240 $t_sponsors = db_num_rows( $result ); 241 if ( 0 == $t_sponsors ) { 242 echo '<p>' . lang_get( 'no_sponsored' ) . '</p>'; 243 } else { 244 ?> 245 246 <!-- # Edit sponsorship Form BEGIN --> 247 <br /> 248 <div> 249 <form method="post" action="account_sponsor_update.php"> 250 <?php echo form_security_field( 'account_sponsor_update' ) ?> 251 <table class="width100" cellspacing="1"> 252 253 <!-- Headings --> 254 <tr> 255 <td class="form-title" colspan="8"> 256 <?php echo lang_get( 'issues_handled' ) ?> 257 </td> 258 </tr> 259 <tr> 260 <td class="form-title" width="10%"><?php echo lang_get( 'email_bug' ) ?></td> 261 <td class="form-title" width="8%"><?php echo lang_get( 'email_project' ) ?></td> 262 <td class="form-title" width="7%"><?php echo lang_get( 'fixed_in_version' ) ?></td> 263 <td class="form-title" width="10%"><?php echo lang_get( 'email_status' ) ?></td> 264 <td class="form-title" width="35%"><?php echo lang_get( 'email_summary' ) ?></td> 265 <td class="form-title" width="10%"><?php echo lang_get( 'sponsor' ) ?></td> 266 <td class="form-title" width="10%"><?php echo lang_get( 'amount' ) ?></td> 267 <td class="form-title" width="10%"><?php echo lang_get( 'status' ) ?></td> 268 </tr> 269 <?php 270 $t_bug_list = array(); 271 $t_total_owing = 0; 272 $t_total_paid = 0; 273 for ( $i=0; $i < $t_sponsors; ++$i ) { 274 $row = db_fetch_array( $result ); 275 $t_bug = bug_get( $row['bug'] ); 276 $t_sponsor = sponsorship_get( $row['sponsor'] ); 277 $t_buglist[] = $row['bug'] . ':' . $row['sponsor']; 278 279 # describe bug 280 $t_status = string_attribute( get_enum_element( 'status', $t_bug->status ) ); 281 $t_resolution = string_attribute( get_enum_element( 'resolution', $t_bug->resolution ) ); 282 $t_version_id = version_get_id( $t_bug->fixed_in_version, $t_project ); 283 if ( ( false !== $t_version_id ) && ( VERSION_RELEASED == version_get_field( $t_version_id, 'released' ) ) ) { 284 $t_released_label = '<a title="' . lang_get( 'released' ) . '">' . $t_bug->fixed_in_version . '</a>'; 285 } else { 286 $t_released_label = $t_bug->fixed_in_version; 287 } 288 289 # choose color based on status 290 $status_label = html_get_status_css_class( $t_bug->status ); 291 292 echo '<tr class="' . $status_label . '">'; 293 echo '<td><a href="' . string_get_bug_view_url( $row['bug'] ) . '">' . bug_format_id( $row['bug'] ) . '</a></td>'; 294 echo '<td>' . project_get_field( $t_bug->project_id, 'name' ) . ' </td>'; 295 echo '<td class="right">' . $t_released_label . ' </td>'; 296 echo '<td><a title="' . $t_resolution . '"><span class="underline">' . $t_status . '</span> </a></td>'; 297 298 # summary 299 echo '<td>' . string_display_line( $t_bug->summary ); 300 if ( VS_PRIVATE == $t_bug->view_state ) { 301 printf( ' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get( 'private' ), lang_get( 'private' ) ); 302 } 303 echo '</td>'; 304 305 # describe sponsorship amount 306 echo '<td>'; 307 print_user( $t_sponsor->user_id ); 308 echo '</td>'; 309 echo '<td class="right">' . sponsorship_format_amount( $t_sponsor->amount ) . '</td>'; 310 echo '<td><select name="sponsor_' . $row['bug'] . '_' . $t_sponsor->id . '">'; 311 print_enum_string_option_list( 'sponsorship', $t_sponsor->paid ); 312 echo '</select></td>'; 313 314 echo '</tr>'; 315 if ( SPONSORSHIP_PAID == $t_sponsor->paid ) { 316 $t_total_paid += $t_sponsor->amount; 317 } else { 318 $t_total_owing += $t_sponsor->amount; 319 } 320 321 } 322 $t_hidden_bug_list = implode( ',', $t_buglist ); 323 ?> 324 <!-- Totals --> 325 <tr> 326 <td colspan="5"></td> 327 <td><?php echo lang_get( 'total_owing' ) ?></td> 328 <td class="right"><?php echo sponsorship_format_amount( $t_total_owing ) ?></td> 329 <td></td> 330 </tr> 331 <tr> 332 <td colspan="5"></td> 333 <td><?php echo lang_get( 'total_paid' ) ?></td> 334 <td class="right"><?php echo sponsorship_format_amount( $t_total_paid ) ?></td> 335 <td></td> 336 </tr> 337 <input type="hidden" name="buglist" value="<?php echo $t_hidden_bug_list ?>" /> 338 <!-- BUTTONS --> 339 <tr> 340 <td colspan="5"> </td> 341 <!-- Update Button --> 342 <td colspan="2"> 343 <input type="submit" class="button" value="<?php echo lang_get( 'update_sponsorship_button' ) ?>" /> 344 </td> 345 </tr> 346 </table> 347 </form> 348 </div> 349 <?php } # end sponsored issues ?> 350 351 <br /> 352 <div> 353 <?php 354 html_button ( 'account_sponsor_page.php', 355 lang_get( ( $t_show_all ? 'sponsor_hide' : 'sponsor_show' ) ), 356 array( 'show_all' => ( $t_show_all ? 0 : 1 ) ) ); 357 ?> 358 </div> 359 360 <?php 361 html_page_bottom();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |