Mantis Logo
Mantis Manual
Manual
Customizing Mantis
Custom Functions

Defined Functions
Example Custom Function


Partner Links


Example Custom Function
Last Modified: December 8, 2004 12:12PM
(Introduced in 0.19.0)
Description

The following function is used to validate an issue before it is resolved.
<?php # -------------------- # Hook to validate Validate field settings before resolving # verify that the resolution is not set to OPEN # verify that the fixed in version is set (if versions of the product exist) function custom_function_override_issue_update_validate( $p_issue_id, $p_bug_data, $p_bugnote_text ) { if ( $p_bug_data->status == RESOLVED ) { if ( $p_bug_data->resolution == OPEN ) { error_parameters( 'the resolution cannot be open to resolve the issue' ); trigger_error( ERROR_BUG_VALIDATE_FAILURE, ERROR ); } $t_version_count = count( version_get_all_rows( $p_bug_data->project_id ) ); if ( ( $t_version_count > 0 ) && ( $p_bug_data->fixed_in_version == '' ) ) { error_parameters( 'fixed in version must be set to resolve the issue' ); trigger_error( ERROR_BUG_VALIDATE_FAILURE, ERROR ); } } } ?>

The errors will also need to be defined by adding the following:

To custom_constant_inc.php
define ( 'ERROR_VALIDATE_FAILURE', 2000 );

To custom_strings_inc.php
$MANTIS_ERROR['ERROR_VALIDATE_FAILURE'] = 'This change cannot be made because %s';


User Contributed Notes
Example Custom Function
Add Notes About Notes
polzin@NOSPAMgmx.de
06-Apr-2005 6:49
#401
There are two mistakes in the example:

1. ERROR_BUG_VALIDATE_FAILURE has to be corrected to
ERROR_VALIDATE_FAILURE

2. $MANTIS_ERROR['ERROR_VALIDATE_FAILURE'] should be
$MANTIS_ERROR[ERROR_VALIDATE_FAILURE]

And probably you want the "fixed in version" field to be required only if "resolution" is "FIXED" and not "SUSPENDED"...

Tobias
Add Notes About Notes
Last updated: Wed, 20 Aug 2008 - 5:09:14

Mantis @ SourceForge