View Issue Details

IDProjectCategoryView StatusLast Update
0008060mantisbtadministrationpublic2023-06-16 11:55
Reportercaldarola Assigned Todregad  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionno change required 
Product Version1.0.7 
Summary0008060: Make Product Version field required in Simple and Advanced Report
Description

In order to deploy correctly the dlls involved in issue I'd like to set Product Version field required.

TagsNo tags attached.

Activities

emm

emm

2007-06-14 11:31

reporter   ~0014762

I've customized this for myself, if it helps you:

--> in bug_report_page.php
line 14

$g_allow_browser_cache = 1;

line 195
<span class="required">*</span>

--> in bug_report_advanced_page.php
line 14

$g_allow_browser_cache = 1;

line 268
<span class="required">*</span>

--> in core/custom_function_api.php
line 105
function custom_function_override_issue_create_validate( $p_new_issue_data ) {
$t_version_count = count( version_get_all_rows( $p_new_issue_data->project_id ) );
if ( ( $t_version_count > 0 ) && ( $p_new_issue_data->version == '' ) ) {
error_parameters( 'Product Version' );
trigger_error(ERROR_EMPTY_FIELD, ERROR );
}
}

caldarola

caldarola

2007-06-25 10:26

reporter   ~0014812

Thank you, but I'd like to make that field required in CLOSED report only. How do I modify your script?

JohnWashburn

JohnWashburn

2007-10-02 19:12

reporter   ~0015795

Here is the code I added to custom_functions_inc.php to make product version a requried field if an only if product version is a field which is displayed on the reporting screen (advanced or simple). Not all of our project have version defined.
<?php

--------------------

# Hook to validate field settings before creating an issue
# Verify that the proper fields are set before proceeding to create an issue
# In case of errors, this function should call trigger_error()
# p_new_issue_data is an object (BugData) with the appropriate fields updated
# --------------------
# This code was ripped off and mutated from the following files
#    custom_function_api.php,v 1.25 2005/07/23 12:01:48
#    bug_view_page.php,v 1.77.6.1.4.1 2007/03/06 07:00:33 and
#    bug_api.php,v 1.95.8.1.6.1 2006/04/18 00:53:04 thraxisp 
#
#    The test for IF there is a product version to select was mutated from bug_view_page.php.  
#        Should this be a core mantis function found in bug_api.php and is named somthing like: is_product_version_visible()?
#       bug_create() of bug_api.php for the test for blank value and throwing the correct error message
# --------------------
function custom_function_override_issue_create_validate( $p_new_issue_data ) {
    # the purpose of this override is to add to the current validation functionality
    # So, call the default validator when creating a new mantis report
    # and then call the additional check found in this function
    # I don't know if this chaining of behavior is MANTIS typical
    #
    custom_function_default_issue_create_validate( $p_new_issue_data );

    # Decide if product_version is available on the report entry screen being validated for the user
    $c_project_id = helper_get_current_project();
    $show_product_version_config = config_get( 'show_product_version' );
    $show_product_version_counts = count( version_get_all_rows( $c_project_id) );
    $is_product_version_visible = ( ON == $show_product_version_config ) 
                               || ( ( AUTO == $show_product_version_config )
                                 && ( 0 &lt; $show_product_version_counts     ) );
    if ( $is_product_version_visible ) {

        # if the field, product version, is visible to the user, 
        # then trigger an error if the product version is blank
        $c_version = db_prepare_string( $p_bug_data->version );
        if ( is_blank( $c_version) ) {
            error_parameters( lang_get( 'product_version' ) );
            trigger_error( ERROR_EMPTY_FIELD, ERROR );
        }
    }
}

?>

If custom_functions_inc.php does not exist, then you need to create the file in the root directory for mantis.

I hope this helps. I think you need to make a similar function in the customization function for issue_update in order to force product version to be required on CLOSING a defect, but I don't know this.

JohnWashburn

JohnWashburn

2007-10-03 10:14

reporter   ~0015801

actually the line:
$show_product_version_counts = count( version_get_all_rows( $c_project_id) );
needs to read:
$show_product_version_counts = count( version_get_all_rows( $c_project_id, true) );

The first count is the count of ALL versions defined for the current project.
The second count is the count of all RELEASED versions defined for the current project.

This will require the product version field if there is at least on RELEASED version. There is no point in requiring entry for Product Version if the list of available Product Versions is empty. The list of available product versions would be empty if no versions are released versions.

baamster

baamster

2011-04-15 10:54

reporter   ~0028632

I tried this (with and without the last change from John), but get an error every time I try to report a bug (product version filled in or not). Using version 1.24 and I've "turned off the 'OS', 'OS_Version' and 'Platform' field, but that should not influence this should it?

tomozaki

tomozaki

2012-04-05 01:30

reporter   ~0031598

$p_bug_data in 0008060:0015795 shall be $p_new_issue_data.
By the way, copied from is mine.

function custom_function_override_issue_create_validate( $p_new_issue_data ) {

custom_function_default_issue_create_validate( $p_new_issue_data );

$c_project_id = helper_get_current_project();
$show_product_version_config = config_get( 'show_product_version' );
$show_product_version_counts = count( version_get_all_rows( $c_project_id) );
$is_product_version_visible = ( ON == $show_product_version_config ) 
                               || ( ( AUTO == $show_product_version_config )
                                 && ( 0 &lt; $show_product_version_counts ) );

if ( $is_product_version_visible ) {

    # Product Version shall be set.
    # NOTE: Actual data is in $p_new_issue_data->version, not $p_new_issue_data->product_version.
    if ( is_blank( $p_new_issue_data->version ) ) {
        error_parameters( lang_get( 'product_version' ) );
        trigger_error( ERROR_EMPTY_FIELD, ERROR );
    }

    # Target Version shall be set.
    if ( is_blank( $p_new_issue_data->target_version ) ) {
        error_parameters( lang_get( 'target_version' ) );
        trigger_error( ERROR_EMPTY_FIELD, ERROR );
    }

    # for not to be registered unnecessarily while debugging....
    #error_parameters( 'PASSED: ' . lang_get( 'product_version' ) . ' == &lt;' . $p_new_issue_data->version . '>  ' . lang_get( 'target_version' ) . ' == &lt;' . $p_new_issue_data->target_version );
    #trigger_error( ERROR_EMPTY_FIELD, ERROR );
}

}

dregad

dregad

2023-06-06 11:53

developer   ~0067832

We are resolving this issue as "no change required", because it was reported against an old version of MantisBT which is no longer supported.

We recommend that you upgrade to the latest stable version [1]; if after doing so the problem still exists, do not hesitate to reopen the issue.

[1] http://www.mantisbt.org/download.php