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 - 2010 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
60 require_once( 'core.php' );
61 require_api( 'access_api.php' );
62 require_api( 'authentication_api.php' );
63 require_api( 'bug_api.php' );
64 require_api( 'config_api.php' );
65 require_api( 'constant_inc.php' );
66 require_api( 'current_user_api.php' );
67 require_api( 'database_api.php' );
68 require_api( 'form_api.php' );
69 require_api( 'gpc_api.php' );
70 require_api( 'helper_api.php' );
71 require_api( 'html_api.php' );
72 require_api( 'lang_api.php' );
73 require_api( 'print_api.php' );
74 require_api( 'project_api.php' );
75 require_api( 'sponsorship_api.php' );
76 require_api( 'string_api.php' );
77 require_api( 'version_api.php' );
79 if ( config_get( 'enable_sponsorship' ) == OFF
) {
80 trigger_error( ERROR_SPONSORSHIP_NOT_ENABLED
, ERROR
);
83 # anonymous users are not allowed to sponsor issues
84 if ( current_user_is_anonymous() ) {
88 $t_show_all = gpc_get_bool( 'show_all', false );
91 html_page_top( lang_get( 'my_sponsorship' ) );
93 $t_project = helper_get_current_project();
96 <table
class="width100" cellspacing
="1">
98 <td
class="form-title">
99 <?php
echo lang_get( 'my_sponsorship' ) ?
>
102 <?php
print_account_menu( 'account_sponsor_page.php' ) ?
>
107 # get issues user has sponsored
108 $t_user = auth_get_current_user_id();
109 $t_resolved = config_get( 'bug_resolved_status_threshold' );
110 $t_bug_table = db_get_table( 'bug' );
111 $t_sponsor_table = db_get_table( 'sponsorship' );
112 $t_payment = config_get( 'payment_enable', 0 );
114 $t_project_clause = helper_project_specific_where( $t_project );
116 $query = "SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status
117 FROM $t_bug_table b, $t_sponsor_table s
118 WHERE s.user_id=" . db_param() . " AND s.bug_id = b.id " .
119 ( $t_show_all ?
'' : 'AND ( b.status < ' . db_param() . ' OR s.paid < ' . SPONSORSHIP_PAID
. ')' ) . "
120 AND $t_project_clause
121 ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC";
123 $result = db_query_bound( $query, $t_show_all ?
Array( $t_user ) : Array( $t_user , $t_resolved ) );
125 $t_sponsors = db_num_rows( $result );
126 if ( 0 == $t_sponsors ) {
127 echo '<p>' . lang_get( 'no_own_sponsored' ) . '</p>';
131 <!-- # Edit own sponsorship Form BEGIN -->
134 <table
class="width100" cellspacing
="1">
138 <td
class="form-title" colspan
="9">
139 <?php
echo lang_get( 'own_sponsored' ) ?
>
143 <td
class="form-title" width
="10%"><?php
echo lang_get( 'email_bug' ) ?
></td
>
144 <td
class="form-title" width
="8%"><?php
echo lang_get( 'email_project' ) ?
></td
>
145 <td
class="form-title" width
="7%"><?php
echo lang_get( 'fixed_in_version' ) ?
></td
>
146 <td
class="form-title" width
="10%"><?php
echo lang_get( 'email_status' ) ?
></td
>
147 <td
class="form-title" width
="10%"><?php
echo lang_get( 'email_handler' ) ?
></td
>
148 <td
class="form-title" width
="30%"><?php
echo lang_get( 'email_summary' ) ?
></td
>
149 <td
class="form-title" width
="8%"><?php
echo lang_get( 'amount' ) ?
></td
>
150 <td
class="form-title" width
="7%"><?php
echo lang_get( 'status' ) ?
></td
>
151 <td
class="form-title" width
="10%"> 
;</td
>
156 for ( $i=0; $i < $t_sponsors; ++
$i ) {
157 $row = db_fetch_array( $result );
158 $t_bug = bug_get( $row['bug'] );
159 $t_sponsor = sponsorship_get( $row['sponsor'] );
162 $t_status = string_attribute( get_enum_element( 'status', $t_bug->status
) );
163 $t_resolution = string_attribute( get_enum_element( 'resolution', $t_bug->resolution
) );
164 $t_version_id = version_get_id( $t_bug->fixed_in_version
, $t_project );
165 if ( ( false !== $t_version_id ) && ( VERSION_RELEASED
== version_get_field( $t_version_id, 'released' ) ) ) {
166 $t_released_label = '<a title="' . lang_get( 'released' ) . '">' . $t_bug->fixed_in_version
. '</a>';
168 $t_released_label = $t_bug->fixed_in_version
;
171 echo '<tr bgcolor="' . get_status_color( $t_bug->status
) . '">';
172 echo '<td><a href="' . string_get_bug_view_url( $row['bug'] ) . '">' . bug_format_id( $row['bug'] ) . '</a></td>';
173 echo '<td>' . project_get_field( $t_bug->project_id
, 'name' ) . ' </td>';
174 echo '<td class="right">' . $t_released_label . ' </td>';
175 echo '<td><span class="issue-status" title="' . $t_resolution . '">' . $t_status . '</span></td>';
177 print_user( $t_bug->handler_id
);
181 echo '<td>' . string_display_line( $t_bug->summary
);
182 if ( VS_PRIVATE
== $t_bug->view_state
) {
183 printf( ' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get( 'private' ), lang_get( 'private' ) );
187 # describe sponsorship amount
188 echo '<td class="right">' . sponsorship_format_amount( $t_sponsor->amount
) . '</td>';
189 echo '<td>' . get_enum_element( 'sponsorship', $t_sponsor->paid
) . '</td>';
191 if ( SPONSORSHIP_PAID
== $t_sponsor->paid
) {
192 $t_total_paid +
= $t_sponsor->amount
;
194 $t_total_owing +
= $t_sponsor->amount
;
199 echo '(paypal button)';
209 <td colspan
="5"></td
>
210 <td
><?php
echo lang_get( 'total_owing' ) ?
></td
>
211 <td
class="right"><?php
echo sponsorship_format_amount( $t_total_owing ) ?
></td
>
212 <td colspan
="2"></td
>
215 <td colspan
="5"></td
>
216 <td
><?php
echo lang_get( 'total_paid' ) ?
></td
>
217 <td
class="right"><?php
echo sponsorship_format_amount( $t_total_paid ) ?
></td
>
218 <td colspan
="2"></td
>
222 <?php
} # end sponsored issues
224 $query = "SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status
225 FROM $t_bug_table b, $t_sponsor_table s
226 WHERE b.handler_id=" . db_param() . " AND s.bug_id = b.id " .
227 ( $t_show_all ?
'' : 'AND ( b.status < ' . db_param() . ' OR s.paid < ' . SPONSORSHIP_PAID
. ')' ) . "
228 AND $t_project_clause
229 ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC";
231 $result = db_query_bound( $query, $t_show_all ?
Array( $t_user ) : Array( $t_user , $t_resolved ) );
232 $t_sponsors = db_num_rows( $result );
233 if ( 0 == $t_sponsors ) {
234 echo '<p>' . lang_get( 'no_sponsored' ) . '</p>';
238 <!-- # Edit sponsorship Form BEGIN -->
241 <form method
="post" action
="account_sponsor_update.php">
242 <?php
echo form_security_field( 'account_sponsor_update' ) ?
>
243 <table
class="width100" cellspacing
="1">
247 <td
class="form-title" colspan
="8">
248 <?php
echo lang_get( 'issues_handled' ) ?
>
252 <td
class="form-title" width
="10%"><?php
echo lang_get( 'email_bug' ) ?
></td
>
253 <td
class="form-title" width
="8%"><?php
echo lang_get( 'email_project' ) ?
></td
>
254 <td
class="form-title" width
="7%"><?php
echo lang_get( 'fixed_in_version' ) ?
></td
>
255 <td
class="form-title" width
="10%"><?php
echo lang_get( 'email_status' ) ?
></td
>
256 <td
class="form-title" width
="35%"><?php
echo lang_get( 'email_summary' ) ?
></td
>
257 <td
class="form-title" width
="10%"><?php
echo lang_get( 'sponsor' ) ?
></td
>
258 <td
class="form-title" width
="10%"><?php
echo lang_get( 'amount' ) ?
></td
>
259 <td
class="form-title" width
="10%"><?php
echo lang_get( 'status' ) ?
></td
>
262 $t_bug_list = array();
265 for ( $i=0; $i < $t_sponsors; ++
$i ) {
266 $row = db_fetch_array( $result );
267 $t_bug = bug_get( $row['bug'] );
268 $t_sponsor = sponsorship_get( $row['sponsor'] );
269 $t_buglist[] = $row['bug'] . ':' . $row['sponsor'];
272 $t_status = string_attribute( get_enum_element( 'status', $t_bug->status
) );
273 $t_resolution = string_attribute( get_enum_element( 'resolution', $t_bug->resolution
) );
274 $t_version_id = version_get_id( $t_bug->fixed_in_version
, $t_project );
275 if ( ( false !== $t_version_id ) && ( VERSION_RELEASED
== version_get_field( $t_version_id, 'released' ) ) ) {
276 $t_released_label = '<a title="' . lang_get( 'released' ) . '">' . $t_bug->fixed_in_version
. '</a>';
278 $t_released_label = $t_bug->fixed_in_version
;
281 echo '<tr bgcolor="' . get_status_color( $t_bug->status
) . '">';
282 echo '<td><a href="' . string_get_bug_view_url( $row['bug'] ) . '">' . bug_format_id( $row['bug'] ) . '</a></td>';
283 echo '<td>' . project_get_field( $t_bug->project_id
, 'name' ) . ' </td>';
284 echo '<td class="right">' . $t_released_label . ' </td>';
285 echo '<td><a title="' . $t_resolution . '"><u>' . $t_status . '</u> </a></td>';
288 echo '<td>' . string_display_line( $t_bug->summary
);
289 if ( VS_PRIVATE
== $t_bug->view_state
) {
290 printf( ' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get( 'private' ), lang_get( 'private' ) );
293 # describe sponsorship amount
295 print_user( $t_sponsor->user_id
);
297 echo '<td class="right">' . sponsorship_format_amount( $t_sponsor->amount
) . '</td>';
298 echo '<td><select name="sponsor_' . $row['bug'] . '_' . $t_sponsor->id
. '">';
299 print_enum_string_option_list( 'sponsorship', $t_sponsor->paid
);
300 echo '</select></td>';
303 if ( SPONSORSHIP_PAID
== $t_sponsor->paid
) {
304 $t_total_paid +
= $t_sponsor->amount
;
306 $t_total_owing +
= $t_sponsor->amount
;
310 $t_hidden_bug_list = implode( ',', $t_buglist );
314 <td colspan
="5"></td
>
315 <td
><?php
echo lang_get( 'total_owing' ) ?
></td
>
316 <td
class="right"><?php
echo sponsorship_format_amount( $t_total_owing ) ?
></td
>
320 <td colspan
="5"></td
>
321 <td
><?php
echo lang_get( 'total_paid' ) ?
></td
>
322 <td
class="right"><?php
echo sponsorship_format_amount( $t_total_paid ) ?
></td
>
325 <input type
="hidden" name
="buglist" value
="<?php echo $t_hidden_bug_list ?>" />
328 <td colspan
="5"> 
;</td
>
329 <!-- Update Button
-->
331 <input type
="submit" class="button" value
="<?php echo lang_get( 'update_sponsorship_button' ) ?>" />
337 <?php
} # end sponsored issues ?>
342 html_button ( 'account_sponsor_page.php',
343 lang_get( ( $t_show_all ?
'sponsor_hide' : 'sponsor_show' ) ),
344 array( 'show_all' => ( $t_show_all ?
0 : 1 ) ) );