Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / account_sponsor_update.php
blobe9beac3989adda6afeff2c0580338bab3131dfcd
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 * This page updates a user's sponsorships
19 * If an account is protected then changes are forbidden
20 * The page gets redirected back to account_page.php
22 * @package MantisBT
23 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
24 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
25 * @link http://www.mantisbt.org
27 * @uses core.php
28 * @uses access_api.php
29 * @uses authentication_api.php
30 * @uses bug_api.php
31 * @uses config_api.php
32 * @uses form_api.php
33 * @uses gpc_api.php
34 * @uses html_api.php
35 * @uses lang_api.php
36 * @uses print_api.php
37 * @uses sponsorship_api.php
40 require_once( 'core.php' );
41 require_api( 'access_api.php' );
42 require_api( 'authentication_api.php' );
43 require_api( 'bug_api.php' );
44 require_api( 'config_api.php' );
45 require_api( 'form_api.php' );
46 require_api( 'gpc_api.php' );
47 require_api( 'html_api.php' );
48 require_api( 'lang_api.php' );
49 require_api( 'print_api.php' );
50 require_api( 'sponsorship_api.php' );
52 form_security_validate( 'account_sponsor_update' );
54 auth_ensure_user_authenticated();
56 $f_bug_list = gpc_get_string( 'buglist', '' );
57 $t_bug_list = explode( ',', $f_bug_list );
59 foreach ( $t_bug_list as $t_bug ) {
60 list( $t_bug_id, $t_sponsor_id ) = explode( ':', $t_bug );
61 $c_bug_id = (int) $t_bug_id;
63 bug_ensure_exists( $c_bug_id ); # dies if bug doesn't exist
65 access_ensure_bug_level( config_get( 'handle_sponsored_bugs_threshold' ), $c_bug_id ); # dies if user can't handle bug
67 $t_bug = bug_get( $c_bug_id );
68 $t_sponsor = sponsorship_get( (int) $t_sponsor_id );
70 $t_new_payment = gpc_get_int( 'sponsor_' . $c_bug_id . '_' . $t_sponsor->id, $t_sponsor->paid );
71 if ( $t_new_payment != $t_sponsor->paid ) {
72 sponsorship_update_paid( $t_sponsor_id, $t_new_payment );
76 form_security_purge( 'account_sponsor_update' );
78 $t_redirect = 'account_sponsor_page.php';
79 html_page_top( null, $t_redirect );
81 echo '<br /><div align="center">';
83 echo lang_get( 'payment_updated' ) . '<br />';
85 echo lang_get( 'operation_successful' ) . '<br />';
86 print_bracket_link( $t_redirect, lang_get( 'proceed' ) );
87 echo '</div>';
88 html_page_bottom();