Blame Extras/Mantis/1.1.2-1.fc9/account_sponsor_page.php

4c79b5
4c79b5
# Mantis - a php based bugtracking system
4c79b5
4c79b5
# Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
4c79b5
# Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
4c79b5
4c79b5
# Mantis is free software: you can redistribute it and/or modify
4c79b5
# it under the terms of the GNU General Public License as published by
4c79b5
# the Free Software Foundation, either version 2 of the License, or
4c79b5
# (at your option) any later version.
4c79b5
#
4c79b5
# Mantis is distributed in the hope that it will be useful,
4c79b5
# but WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4c79b5
# GNU General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
4c79b5
4c79b5
	# --------------------------------------------------------
4c79b5
	# $Id: account_sponsor_page.php,v 1.5.2.1 2007-10-13 22:32:20 giallu Exp $
4c79b5
	# --------------------------------------------------------
4c79b5
4c79b5
	# CALLERS
4c79b5
	#	This page is called from:
4c79b5
	#	- print_menu()
4c79b5
	#	- print_account_menu()
4c79b5
4c79b5
	# EXPECTED BEHAVIOUR
4c79b5
	#	- Display the user's current sponsorships
4c79b5
	#	- Allow the user to edit the payment flag
4c79b5
4c79b5
	# CALLS
4c79b5
	#	This page calls the following pages:
4c79b5
	#	- account_sponsor_update.php  (to save changes)
4c79b5
4c79b5
	# RESTRICTIONS & PERMISSIONS
4c79b5
	#	- User must be authenticated, and not anonymous
4c79b5
	#   - sponsorship must be enabled
4c79b5
4c79b5
	require_once( 'core.php' );
4c79b5
4c79b5
	$t_core_path = config_get( 'core_path' );
4c79b5
4c79b5
	require_once( $t_core_path.'current_user_api.php' );
4c79b5
4c79b5
	if ( config_get( 'enable_sponsorship' ) == OFF ) {
4c79b5
		trigger_error( ERROR_SPONSORSHIP_NOT_ENABLED, ERROR );
4c79b5
	}
4c79b5
4c79b5
	# anonymous users are not allowed to sponsor issues
4c79b5
	if ( current_user_is_anonymous() ) {
4c79b5
		access_denied();
4c79b5
	}
4c79b5
	
4c79b5
	$t_show_all = gpc_get_bool( 'show_all', false );
4c79b5
4c79b5
	# start the page
4c79b5
	html_page_top1( lang_get( 'my_sponsorship' ) );
4c79b5
	html_page_top2();
4c79b5
	
4c79b5
	$t_project = helper_get_current_project();
4c79b5
?>
4c79b5

4c79b5
4c79b5
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
4c79b5
4c79b5
4c79b5
	# get issues user has sponsored
4c79b5
	$t_user = auth_get_current_user_id();
4c79b5
	$t_resolved = config_get( 'bug_resolved_status_threshold' );
4c79b5
	$t_bug_table = config_get( 'mantis_bug_table' );
4c79b5
	$t_sponsor_table = config_get( 'mantis_sponsorship_table' );
4c79b5
	$t_payment = config_get( 'payment_enable', 0 );
4c79b5
	
4c79b5
	$t_show_clause =  $t_show_all ? '' : 'AND ( b.status < ' . $t_resolved . ' OR s.paid < ' . SPONSORSHIP_PAID . ')';
4c79b5
	$t_project_clause = helper_project_specific_where( $t_project );
4c79b5
	
4c79b5
	$query = "SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status 
4c79b5
		FROM $t_bug_table b, $t_sponsor_table s 
4c79b5
		WHERE s.user_id=$t_user AND s.bug_id = b.id $t_show_clause AND $t_project_clause
4c79b5
		ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC";
4c79b5
		
4c79b5
	$result = db_query( $query );
4c79b5
		
4c79b5
	$t_sponsors = db_num_rows( $result );
4c79b5
	if ( 0 == $t_sponsors ) {
4c79b5
		echo '

' . lang_get( 'no_own_sponsored' ) . '

';
4c79b5
	} else {
4c79b5
?>
4c79b5
4c79b5
4c79b5

4c79b5
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
			
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		 
4c79b5
	
4c79b5
4c79b5
		$t_total_owing = 0;
4c79b5
		$t_total_paid = 0;
4c79b5
		for ( $i=0; $i < $t_sponsors; ++$i ) {
4c79b5
			$row = db_fetch_array( $result );
4c79b5
			$t_bug = bug_get( $row['bug'] );
4c79b5
			$t_sponsor = sponsorship_get( $row['sponsor'] );
4c79b5
			
4c79b5
			# describe bug
4c79b5
			$t_status = string_attribute( get_enum_element( 'status', $t_bug->status ) );
4c79b5
			$t_resolution = string_attribute( get_enum_element( 'resolution', $t_bug->resolution ) );
4c79b5
			$t_version_id = version_get_id( $t_bug->fixed_in_version, $t_project );
4c79b5
			if ( ( false !== $t_version_id ) && ( VERSION_RELEASED == version_get_field( $t_version_id, 'released' ) ) ) {
4c79b5
				$t_released_label = '' . $t_bug->fixed_in_version . '';
4c79b5
			} else {
4c79b5
				$t_released_label = $t_bug->fixed_in_version;
4c79b5
			}
4c79b5
4c79b5
			echo '';
4c79b5
			echo '' . bug_format_id( $row['bug'] ) . '';
4c79b5
			echo '' . project_get_field( $t_bug->project_id, 'name' ) . ' ';
4c79b5
			echo '' . $t_released_label . ' ';
4c79b5
			echo '' . $t_status . '';
4c79b5
			echo '';
4c79b5
			print_user( $t_bug->handler_id );
4c79b5
			echo '';
4c79b5
4c79b5
			# summary
4c79b5
			echo '' . string_display_line( $t_bug->summary );
4c79b5
			if ( VS_PRIVATE == $t_bug->view_state ) {
4c79b5
				printf( ' (%s)', $t_icon_path . 'protected.gif', lang_get( 'private' ), lang_get( 'private' ) );
4c79b5
			}
4c79b5
			
4c79b5
			# describe sponsorship amount
4c79b5
			echo '' . sponsorship_format_amount( $t_sponsor->amount ) . '';
4c79b5
			echo '' . get_enum_element( 'sponsorship', $t_sponsor->paid ) . '';
4c79b5
			
4c79b5
			if ( SPONSORSHIP_PAID == $t_sponsor->paid ) {
4c79b5
				$t_total_paid += $t_sponsor->amount;
4c79b5
			} else {
4c79b5
				$t_total_owing += $t_sponsor->amount;
4c79b5
			}
4c79b5
			
4c79b5
			echo '';
4c79b5
			if ( $t_payment ) {
4c79b5
				echo '(paypal button)';
4c79b5
			} else {
4c79b5
				echo ' ';
4c79b5
			}
4c79b5
			echo '';
4c79b5
			echo '';
4c79b5
		}
4c79b5
?>
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
4c79b5
4c79b5
4c79b5
4c79b5
4c79b5
	$query = "SELECT b.id as bug, s.id as sponsor, s.paid, b.project_id, b.fixed_in_version, b.status 
4c79b5
		FROM $t_bug_table b, $t_sponsor_table s 
4c79b5
		WHERE b.handler_id=$t_user AND s.bug_id = b.id $t_show_clause AND $t_project_clause
4c79b5
		ORDER BY s.paid ASC, b.project_id ASC, b.fixed_in_version ASC, b.status ASC, b.id DESC";
4c79b5
		
4c79b5
	$result = db_query( $query );
4c79b5
	$t_sponsors = db_num_rows( $result );
4c79b5
	if ( 0 == $t_sponsors ) {
4c79b5
		echo '

' . lang_get( 'no_sponsored' ) . '

';
4c79b5
	} else {
4c79b5
?>
4c79b5
4c79b5
4c79b5

4c79b5
4c79b5
<form method="post" action="account_sponsor_update.php">
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
			
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
		
4c79b5
	
4c79b5
4c79b5
		$t_bug_list = array();
4c79b5
		$t_total_owing = 0;
4c79b5
		$t_total_paid = 0;
4c79b5
		for ( $i=0; $i < $t_sponsors; ++$i ) {
4c79b5
			$row = db_fetch_array( $result );
4c79b5
			$t_bug = bug_get( $row['bug'] );
4c79b5
			$t_sponsor = sponsorship_get( $row['sponsor'] );
4c79b5
			$t_buglist[] = $row['bug'] . ':' . $row['sponsor'];
4c79b5
			
4c79b5
			# describe bug
4c79b5
			$t_status = string_attribute( get_enum_element( 'status', $t_bug->status ) );
4c79b5
			$t_resolution = string_attribute( get_enum_element( 'resolution', $t_bug->resolution ) );
4c79b5
			$t_version_id = version_get_id( $t_bug->fixed_in_version, $t_project );
4c79b5
			if ( ( false !== $t_version_id ) && ( VERSION_RELEASED == version_get_field( $t_version_id, 'released' ) ) ) {
4c79b5
				$t_released_label = '' . $t_bug->fixed_in_version . '';
4c79b5
			} else {
4c79b5
				$t_released_label = $t_bug->fixed_in_version;
4c79b5
			}
4c79b5
4c79b5
			echo '';
4c79b5
			echo '' . bug_format_id( $row['bug'] ) . '';
4c79b5
			echo '' . project_get_field( $t_bug->project_id, 'name' ) . ' ';
4c79b5
			echo '' . $t_released_label . ' ';
4c79b5
			echo '<u>' . $t_status . '</u> ';
4c79b5
4c79b5
			# summary
4c79b5
			echo '' . string_display_line( $t_bug->summary );
4c79b5
			if ( VS_PRIVATE == $t_bug->view_state ) {
4c79b5
				printf( ' (%s)', $t_icon_path . 'protected.gif', lang_get( 'private' ), lang_get( 'private' ) );
4c79b5
			}
4c79b5
			
4c79b5
			# describe sponsorship amount
4c79b5
			echo '';
4c79b5
			print_user( $t_sponsor->user_id );
4c79b5
			echo '';
4c79b5
			echo '' . sponsorship_format_amount( $t_sponsor->amount ) . '';
4c79b5
			echo '<select name="sponsor_' . $row['bug'] . '_' . $t_sponsor->id . '">';
4c79b5
			print_enum_string_option_list( 'sponsorship', $t_sponsor->paid );
4c79b5
			echo '</select>';
4c79b5
			
4c79b5
			echo '';
4c79b5
			if ( SPONSORSHIP_PAID == $t_sponsor->paid ) {
4c79b5
				$t_total_paid += $t_sponsor->amount;
4c79b5
			} else {
4c79b5
				$t_total_owing += $t_sponsor->amount;
4c79b5
			}
4c79b5
			
4c79b5
		}
4c79b5
		$t_hidden_bug_list = implode( ',', $t_buglist );
4c79b5
?>
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
4c79b5
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
4c79b5
	<input type="hidden" name="buglist" value="<?php echo $t_hidden_bug_list ?>" />
4c79b5
	
4c79b5
	
4c79b5
		 
4c79b5
		
4c79b5
		
4c79b5
			<input type="submit" class="button" value="<?php echo lang_get( 'update_sponsorship_button' ) ?>" />
4c79b5
		
4c79b5
	
4c79b5
4c79b5
</form>
4c79b5
4c79b5
4c79b5
4c79b5

4c79b5
4c79b5
4c79b5
	html_button ( 'account_sponsor_page.php', 
4c79b5
		lang_get( ( $t_show_all ? 'sponsor_hide' : 'sponsor_show' ) ), 
4c79b5
		array( 'show_all' => ( $t_show_all ? 0 : 1 ) ) );
4c79b5
?>
4c79b5
4c79b5
4c79b5