Blame Identity/Models/Html/Mantis/1.1.2-1.fc9/bug_actiongroup_add_note_inc.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: bug_actiongroup_add_note_inc.php,v 1.3.2.1 2007-10-13 22:32:31 giallu Exp $
4c79b5
	# --------------------------------------------------------
4c79b5
4c79b5
	/**
4c79b5
	 * Prints the title for the custom action page.	 
4c79b5
	 */
4c79b5
	function action_add_note_print_title() {
4c79b5
        echo '';
4c79b5
        echo '';
4c79b5
        echo lang_get( 'add_bugnote_title' );
4c79b5
        echo '';		
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	 * Prints the field within the custom action form.  This has an entry for
4c79b5
	 * every field the user need to supply + the submit button.  The fields are
4c79b5
	 * added as rows in a table that is already created by the calling code.
4c79b5
	 * A row has two columns.         	 
4c79b5
	 */
4c79b5
	function action_add_note_print_fields() {
4c79b5
		echo '', lang_get( 'add_bugnote_title' ), '<textarea name="bugnote_text" cols="80" rows="10"></textarea>';
4c79b5
	?>
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		
4c79b5
	
4c79b5
	
4c79b5
4c79b5
		if ( access_has_project_level( config_get( 'change_view_status_threshold' ) ) ) { ?>
4c79b5
			<select name="view_state">
4c79b5
				view_state) ?>
4c79b5
			</select>
4c79b5
4c79b5
		} else {
4c79b5
			echo get_enum_element( 'view_state', $t_bug->view_state );
4c79b5
			echo '<input type="hidden" name="view_state" value="', $t_bug->view_state, '" />';
4c79b5
		}
4c79b5
?>
4c79b5
	
4c79b5
	
4c79b5
	
4c79b5
		echo '<center><input type="submit" class="button" value="' . lang_get( 'add_bugnote_button' ) . ' " /></center>';
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	 * Validates the action on the specified bug id.
4c79b5
	 * 
4c79b5
	 * @returns true    Action can be applied.
4c79b5
	 * @returns array( bug_id => reason for failure )	 
4c79b5
	 */
4c79b5
	function action_add_note_validate( $p_bug_id ) {
4c79b5
		$f_bugnote_text = gpc_get_string( 'bugnote_text' );
4c79b5
4c79b5
		if ( is_blank( $f_bugnote_text ) ) {
4c79b5
			error_parameters( lang_get( 'bugnote' ) );
4c79b5
			trigger_error( ERROR_EMPTY_FIELD, ERROR );
4c79b5
		}
4c79b5
4c79b5
		$t_failed_validation_ids = array();
4c79b5
		$t_add_bugnote_threshold = config_get( 'add_bugnote_threshold' );
4c79b5
		$t_bug_id = $p_bug_id;
4c79b5
4c79b5
		if ( bug_is_readonly( $t_bug_id ) ) {
4c79b5
			$t_failed_validation_ids[$t_bug_id] = lang_get( 'actiongroup_error_issue_is_readonly' );
4c79b5
			return $t_failed_validation_ids;
4c79b5
		}
4c79b5
4c79b5
		if ( !access_has_bug_level( $t_add_bugnote_threshold, $t_bug_id ) ) {
4c79b5
			$t_failed_validation_ids[$t_bug_id] = lang_get( 'access_denied' );
4c79b5
			return $t_failed_validation_ids;
4c79b5
		}
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	 * Executes the custom action on the specified bug id.
4c79b5
	 * 
4c79b5
	 * @param $p_bug_id  The bug id to execute the custom action on.
4c79b5
	 * 
4c79b5
	 * @returns true   Action executed successfully.
4c79b5
	 * @returns array( bug_id => reason for failure )               	 
4c79b5
	 */
4c79b5
	function action_add_note_process( $p_bug_id ) {
4c79b5
		$f_bugnote_text = gpc_get_string( 'bugnote_text' );
4c79b5
		$f_view_state = gpc_get_int( 'view_state' );
4c79b5
		bugnote_add ( $p_bug_id, $f_bugnote_text, '0:00', /* $p_private = */ $f_view_state != VS_PUBLIC  );
4c79b5
        return true;
4c79b5
    }
4c79b5
?>