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/>.
19 * This page is called from:
21 * - print_account_menu()
24 * - Display the user's current sponsorships
25 * - Allow the user to edit the payment flag
28 * This page calls the following pages:
29 * - account_sponsor_update.php (to save changes)
31 * RESTRICTIONS & PERMISSIONS
32 * - User must be authenticated, and not anonymous
33 * - sponsorship must be enabled
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
41 * @uses access_api.php
42 * @uses authentication_api.php
44 * @uses config_api.php
45 * @uses constant_inc.php
46 * @uses current_user_api.php
47 * @uses database_api.php
50 * @uses helper_api.php
54 * @uses project_api.php
55 * @uses sponsorship_api.php
56 * @uses string_api.php
57 * @uses version_api.php
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' );
82 require_css( 'status_config.php' );
84 if ( !config_get( 'enable_sponsorship' ) ) {
85 trigger_error( ERROR_SPONSORSHIP_NOT_ENABLED
, ERROR
);
88 # anonymous users are not allowed to sponsor issues
89 if ( current_user_is_anonymous() ) {
93 $t_show_all = gpc_get_bool( 'show_all', false );
96 html_page_top( lang_get( 'my_sponsorship' ) );
98 $t_project = helper_get_current_project();
101 <table
class="width100" cellspacing
="1">
103 <td
class="form-title">
104 <?php
echo lang_get( 'my_sponsorship' ) ?
>
107 <?php
print_account_menu( 'account_sponsor_page.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 );
119 $t_project_clause = helper_project_specific_where( $t_project );
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";
128 $result = db_query_bound( $query, $t_show_all ?
Array( $t_user ) : Array( $t_user , $t_resolved ) );
130 $t_sponsors = db_num_rows( $result );
131 if ( 0 == $t_sponsors ) {
132 echo '<p>' . lang_get( 'no_own_sponsored' ) . '</p>';
136 <!-- # Edit own sponsorship Form BEGIN -->
139 <table
class="width100" cellspacing
="1">
143 <td
class="form-title" colspan
="9">
144 <?php
echo lang_get( 'own_sponsored' ) ?
>
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>
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'] );
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>';
173 $t_released_label = $t_bug->fixed_in_version
;
176 # choose color based on status
177 $status_label = html_get_status_css_class( $t_bug->status
);
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>';
185 print_user( $t_bug->handler_id
);
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' ) );
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>';
199 if ( SPONSORSHIP_PAID
== $t_sponsor->paid
) {
200 $t_total_paid +
= $t_sponsor->amount
;
202 $t_total_owing +
= $t_sponsor->amount
;
207 echo '(paypal button)';
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
>
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
>
230 <?php
} # end sponsored issues
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";
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>';
246 <!-- # Edit sponsorship Form BEGIN -->
249 <form method
="post" action
="account_sponsor_update.php">
250 <?php
echo form_security_field( 'account_sponsor_update' ) ?
>
251 <table
class="width100" cellspacing
="1">
255 <td
class="form-title" colspan
="8">
256 <?php
echo lang_get( 'issues_handled' ) ?
>
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
>
270 $t_bug_list = array();
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'];
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>';
286 $t_released_label = $t_bug->fixed_in_version
;
289 # choose color based on status
290 $status_label = html_get_status_css_class( $t_bug->status
);
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>';
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' ) );
305 # describe sponsorship amount
307 print_user( $t_sponsor->user_id
);
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>';
315 if ( SPONSORSHIP_PAID
== $t_sponsor->paid
) {
316 $t_total_paid +
= $t_sponsor->amount
;
318 $t_total_owing +
= $t_sponsor->amount
;
322 $t_hidden_bug_list = implode( ',', $t_buglist );
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
>
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
>
337 <input type
="hidden" name
="buglist" value
="<?php echo $t_hidden_bug_list ?>" />
340 <td colspan
="5"> </td>
341 <!-- Update Button
-->
343 <input type
="submit" class="button" value
="<?php echo lang_get( 'update_sponsorship_button' ) ?>" />
349 <?php
} # end sponsored issues ?>
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 ) ) );