7.6.2. Example Custom Function Override
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_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_VALIDATE_FAILURE, ERROR );
}
}
}
?>
The errors will also need to be defined, by modifying the following files
custom_constants_inc.php
define( 'ERROR_VALIDATE_FAILURE', 2000 );
$MANTIS_ERROR['ERROR_VALIDATE_FAILURE'] = 'This change cannot be made because %s';