Adding mandatory field checks

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
monotek
Posts: 24
Joined: Jul 01, 2008 11:20 am

Adding mandatory field checks

Post by monotek » Mar 02, 2009 9:14 am

I want to add the following 2 checks to mantis 1.1.6:

http://bugtracker.morinie.fr/mantis/dok ... in_version

http://bugtracker.morinie.fr/mantis/dok ... ck_bugnote

It works fine if i only add on of them but when adding both i get the follwoing error:
Fatal error: Cannot redeclare custom_function_override_issue_update_validate() (previously declared in /var/www/mantis/custom_functions_inc.php:81) in /var/www/mantis/custom_functions_inc.php on line 100
Is it possible to use 2 at a time?

deboutv
Posts: 507
Joined: Jan 15, 2007 9:31 am
Location: La Ciotat, FRANCE
Contact:

Re: Adding mandatory field checks

Post by deboutv » Mar 04, 2009 2:50 am

Yes of course, you need to merge the two functions in only one.
Want more plugins to customize Mantis?
=> http://deboutv.free.fr/mantis/

Mantis: 1.1.0, 1.1.0a2
PHP: 5.0.4
SQL: MySQL 5.0.19
OS: Linux

monotek
Posts: 24
Joined: Jul 01, 2008 11:20 am

Re: Adding mandatory field checks

Post by monotek » Mar 04, 2009 3:04 am

Thanks a lot.

It works now :-)

Code: Select all

define( 'ERROR_BUG_UPDATE_VALIDATE_FAILURE', 10001 );
 
function custom_function_override_issue_update_validate( $p_issue_id, $p_new_issue_data, $p_bugnote_text ) {
    $t_resolved = config_get( 'bug_resolved_status_threshold' );
    if ( bug_get_field( $p_issue_id, 'status' ) != $p_new_issue_data->status &&
         $p_new_issue_data->status == $t_resolved && trim( $p_new_issue_data->fixed_in_version ) == '' ) {
        trigger_error( ERROR_BUG_UPDATE_VALIDATE_FAILURE, ERROR );
    }
	
	if ( bug_get_field( $p_issue_id, 'status' ) != $p_new_issue_data->status &&
         $p_new_issue_data->status == $t_resolved && trim( $p_bugnote_text ) == '' ) {
        trigger_error( ERROR_BUG_UPDATE_VALIDATE_FAILURE2, ERROR );
    }

}

Code: Select all

if ( lang_get_current() == 'french' ) {
    $MANTIS_ERROR[ERROR_BUG_UPDATE_VALIDATE_FAILURE] = 'Une note doit être renseignée.';
} else {
    $MANTIS_ERROR[ERROR_BUG_UPDATE_VALIDATE_FAILURE] = 'The bugnote must be filled.';
}

if ( lang_get_current() == 'french' ) {
    $MANTIS_ERROR[ERROR_BUG_UPDATE_VALIDATE_FAILURE2] = 'Le champs Fixé dans la version doit être renseigné.';
} else {
    $MANTIS_ERROR[ERROR_BUG_UPDATE_VALIDATE_FAILURE2] = 'The field Fixed in version must be filled.';
}

monotek
Posts: 24
Joined: Jul 01, 2008 11:20 am

Re: Adding mandatory field checks

Post by monotek » Mar 06, 2009 3:43 am

One last Question.

Is it also possible to mark this fileds with a star now, via custom_functions.php?

deboutv
Posts: 507
Joined: Jan 15, 2007 9:31 am
Location: La Ciotat, FRANCE
Contact:

Re: Adding mandatory field checks

Post by deboutv » Mar 06, 2009 10:08 am

No you need to modify directly the PHP file.
Want more plugins to customize Mantis?
=> http://deboutv.free.fr/mantis/

Mantis: 1.1.0, 1.1.0a2
PHP: 5.0.4
SQL: MySQL 5.0.19
OS: Linux

Post Reply