<?php

class CustomReporterPlugin extends MantisPlugin {

	function register() {
		$this->name = 'CustomReporterPlugin';    # Proper name of plugin
		$this->description = '';    # Short description of the plugin
		$this->page = '';           # Default plugin page
		
		$this->version = '1.0';     # Plugin version string
		$this->requires = array(    # Plugin dependencies, array of basename => version pairs
		    'MantisCore' => '1.2.0',  #   Should always depend on an appropriate version of MantisBT
		    );
		
		$this->author = 'carlos proensa';         # Author/team name
		$this->contact = '';        # Author/team e-mail address
		$this->url = '';            # Support webpage
	}

	function hooks() {
		return array(
		'EVENT_REPORT_BUG_FORM_TOP' => 'reportBugFormTop',
		'EVENT_REPORT_BUG' => 'reportBug'
		);
	}


	function reportBugFormTop ( $p_event, $p_project_id){
		
		#
		#/ allow to change reporter_id (if access level is higher than reporter)
		#
		$user_id= auth_get_current_user_id();
		$access_level= user_get_access_level( $user_id, $p_project_id );
		if ($access_level > REPORTER) {
			echo '<tr><td>';
			echo 'Reporter: ';
				echo '<select '.helper_get_tab_index().' name="user_id">';
				print_reporter_option_list( $user_id, $p_new_bug->project_id );
				echo '</select>';
			echo '&nbsp;<input type="checkbox" value="'.$user_id.'" name="user_monitor" />Monitor this bug';
		}
		echo '</td></tr>';
	}


	function reportBug($p_event, $p_bug_data, $p_bug_id) {
		// this custom input was created on bug_report page event
		$t_add_user= gpc_get_int('user_monitor',0);
		if ($t_add_user!=0){
			bug_monitor($p_bug_id, $t_add_user);
		}
	}
}
?>
