? custom_contant_inc.php
? mantisbt.patch
Index: bug_change_status_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_change_status_page.php,v
retrieving revision 1.28
diff -u -r1.28 bug_change_status_page.php
--- bug_change_status_page.php 13 Jul 2007 07:58:26 -0000 1.28
+++ bug_change_status_page.php 27 Jul 2007 15:27:45 -0000
@@ -154,33 +154,14 @@
$f_new_status ) ) {
- $t_custom_status_label = "resolved";
-}
-if ( CLOSED == $f_new_status ) {
- $t_custom_status_label = "closed";
-}
-$t_related_custom_field_ids = custom_field_get_linked_ids( bug_get_field( $f_bug_id, 'project_id' ) );
+$t_related_custom_field_ids = custom_field_get_linked_status_ids( bug_get_field( $f_bug_id, 'project_id' ), $f_new_status );
foreach( $t_related_custom_field_ids as $t_id ) {
- $t_def = custom_field_get_definition( $t_id );
- $t_display = $t_def['display_' . $t_custom_status_label];
- $t_require = $t_def['require_' . $t_custom_status_label];
-
- if ( ( "update" == $t_custom_status_label ) && ( ! $t_require ) ) {
- continue;
- }
- if ( in_array( $t_custom_status_label, array( "resolved", "closed" ) ) && ! ( $t_display || $t_require ) ) {
- continue;
- }
- if ( custom_field_has_write_access( $t_id, $f_bug_id ) ) {
+ $t_def = custom_field_get_definition( $t_id[0] );
+ $t_require = $t_id[1];
+
+ if ( custom_field_has_write_access( $t_id[0], $f_bug_id ) ) {
?>
>
-
+
*
Index: bug_update.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_update.php,v
retrieving revision 1.91
diff -u -r1.91 bug_update.php
--- bug_update.php 12 Dec 2006 18:26:28 -0000 1.91
+++ bug_update.php 27 Jul 2007 15:27:45 -0000
@@ -87,44 +87,28 @@
$t_resolved = config_get( 'bug_resolved_status_threshold' );
- $t_custom_status_label = "update"; # default info to check
- if ( $t_bug_data->status == $t_resolved ) {
- $t_custom_status_label = "resolved";
- }
- if ( $t_bug_data->status == CLOSED ) {
- $t_custom_status_label = "closed";
- }
-
- $t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id );
+ $t_related_custom_field_ids = custom_field_get_linked_status_ids( $t_bug_data->project_id, $f_new_status );
foreach( $t_related_custom_field_ids as $t_id ) {
- $t_def = custom_field_get_definition( $t_id );
- $t_custom_field_value = gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], null );
-
- # Only update the field if it would have been display for editing
- if( !( ( ! $f_update_mode && $t_def['require_' . $t_custom_status_label] ) ||
- ( ! $f_update_mode && $t_def['display_' . $t_custom_status_label] && in_array( $t_custom_status_label, array( "resolved", "closed" ) ) ) ||
- ( $f_update_mode && $t_def['display_update'] ) ||
- ( $f_update_mode && $t_def['require_update'] ) ) ) {
- continue;
- }
+ $t_def = custom_field_get_definition( $t_id[0] );
+ $t_custom_field_value = gpc_get_custom_field( "custom_field_".$t_id[0], $t_def['type'], null );
- # Only update the field if it is posted
+ # Only update the field if it is posted
# ( will fail in custom_field_set_value(), if it was required )
if ( $t_custom_field_value === null ) {
continue;
}
# Do not set custom field value if user has no write access.
- if( !custom_field_has_write_access( $t_id, $f_bug_id ) ) {
+ if( !custom_field_has_write_access( $t_id[0], $f_bug_id ) ) {
continue;
}
- if ( $t_def['require_' . $t_custom_status_label] && ( gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], '' ) == '' ) ) {
- error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
+ if ( $t_id[1] && ( gpc_get_custom_field( "custom_field_".$t_id[0], $t_def['type'], '' ) == '' ) ) {
+ error_parameters( lang_get_defaulted( custom_field_get_field( $t_id[0], 'name' ) ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
}
- if ( !custom_field_set_value( $t_id, $f_bug_id, $t_custom_field_value ) ) {
- error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
+ if ( !custom_field_set_value( $t_id[0], $f_bug_id, $t_custom_field_value ) ) {
+ error_parameters( lang_get_defaulted( custom_field_get_field( $t_id[0], 'name' ) ) );
trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
}
}
Index: bug_update_advanced_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_update_advanced_page.php,v
retrieving revision 1.102
diff -u -r1.102 bug_update_advanced_page.php
--- bug_update_advanced_page.php 13 Jul 2007 07:58:28 -0000 1.102
+++ bug_update_advanced_page.php 27 Jul 2007 15:27:45 -0000
@@ -512,15 +512,15 @@
project_id );
+ $t_related_custom_field_ids = custom_field_get_linked_status_ids( $t_bug->project_id, $t_bug->status );
foreach( $t_related_custom_field_ids as $t_id ) {
- $t_def = custom_field_get_definition( $t_id );
- if( ( $t_def['display_update'] || $t_def['require_update']) && custom_field_has_write_access( $t_id, $f_bug_id ) ) {
+ $t_def = custom_field_get_definition( $t_id[0] );
+ if( custom_field_has_write_access( $t_id[0], $f_bug_id ) ) {
$t_custom_fields_found = true;
?>
|
- |
-
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ $t_label ) {
+?>
+ >
+
+
+ |
+
+ >
+ |
+
+ >
+ |
+
+ >
+ |
+
+
+
+
|
Index: manage_custom_field_update.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/manage_custom_field_update.php,v
retrieving revision 1.17
diff -u -r1.17 manage_custom_field_update.php
--- manage_custom_field_update.php 3 Aug 2004 23:43:49 -0000 1.17
+++ manage_custom_field_update.php 29 Jul 2007 04:41:16 -0000
@@ -31,16 +31,20 @@
$t_values['length_min'] = gpc_get_int( 'length_min' );
$t_values['length_max'] = gpc_get_int( 'length_max' );
$t_values['advanced'] = gpc_get_bool( 'advanced' );
- $t_values['display_report'] = gpc_get_bool( 'display_report' );
- $t_values['display_update'] = gpc_get_bool( 'display_update' );
- $t_values['display_resolved'] = gpc_get_bool( 'display_resolved' );
- $t_values['display_closed'] = gpc_get_bool( 'display_closed' );
- $t_values['require_report'] = gpc_get_bool( 'require_report' );
- $t_values['require_update'] = gpc_get_bool( 'require_update' );
- $t_values['require_resolved'] = gpc_get_bool( 'require_resolved' );
- $t_values['require_closed'] = gpc_get_bool( 'require_closed' );
- custom_field_update( $f_field_id, $t_values );
+ # For each status value, look for the assigned value from the page and
+ # store it in an array
+ $t_status_display = array();
+ $t_enum_status = config_get( 'status_enum_string' );
+ $t_status_arr = get_enum_to_array( $t_enum_status );
+ foreach ( $t_status_arr as $t_status => $t_label ) {
+ $t_status_display_val = gpc_get_int('status_'.$t_status, 0);
+ $t_status_display[$t_status] = $t_status_display_val ;
+ }
+
+ $t_values['display_enum'] = serialize( $t_status_display ) ;
+
+ custom_field_update( $f_field_id, $t_values );
html_page_top1();
Index: admin/install.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/admin/install.php,v
retrieving revision 1.33
diff -u -r1.33 install.php
--- admin/install.php 10 Jul 2007 07:04:56 -0000 1.33
+++ admin/install.php 29 Jul 2007 04:58:34 -0000
@@ -61,7 +61,52 @@
return Array( $query );
}
-
+ # This function will migrate custom field display/require settings
+ # to the new method of storing them as a list per #5744 '
+ # This function must be called AFTER the new field has been added to the
+ # custom_field table AND all patches to PHP files have been applied, but
+ # BEFORE the old booleans (require_report, etc) are removed from the table
+ function migrateCustomFieldDisplay() {
+ $t_field_ids = custom_field_get_ids() ;
+ $t_enum_status = config_get( 'status_enum_string' ) ;
+ $t_status_arr = get_enum_to_array( $t_enum_status );
+ $t_report_status = config_get( 'bug_submit_status' ) ;
+ $t_closed_status = CLOSED ;
+ $t_resolved_status = config_get( 'bug_resolved_status_threshold' ) ;
+
+ foreach( $t_field_ids as $t_field_id )
+ {
+ $t_status_display = array() ;
+ $t_field = custom_field_cache_row( $t_field_id ) ;
+
+ foreach ( $t_status_arr as $t_status => $t_label ) {
+ if( $t_status == $t_report_status ) {
+ $t_custom_status_label = "report" ;
+ } elseif ( $t_status == $t_resolved_status ) {
+ $t_custom_status_label = "resolved" ;
+ } elseif ( $t_status == $t_closed_status ) {
+ $t_custom_status_label = "closed" ;
+ } else {
+ $t_custom_status_label = "update" ;
+ }
+
+ $t_display = $t_field['display_' . $t_custom_status_label];
+ $t_require = $t_field['require_' . $t_custom_status_label];
+
+ $t_status_display_val = 0;
+ if( $t_display ) $t_status_display_val = 1;
+ if( $t_require ) $t_status_display_val = 2;
+
+ $t_status_display[$t_status] = $t_status_display_val ;
+ }
+
+ $t_field['display_enum'] = serialize( $t_status_display ) ;
+
+ # Update the custom field status display values
+ custom_field_update( $t_field_id, $t_field );
+
+ }
+ }
# install_state
# 0 = no checks done
Index: admin/schema.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/admin/schema.php,v
retrieving revision 1.19
diff -u -r1.19 schema.php
--- admin/schema.php 22 Jul 2007 19:51:18 -0000 1.19
+++ admin/schema.php 27 Jul 2007 23:57:50 -0000
@@ -144,14 +144,7 @@
length_min I NOTNULL DEFAULT '0',
length_max I NOTNULL DEFAULT '0',
advanced L NOTNULL DEFAULT '0',
- require_report L NOTNULL DEFAULT '0',
- require_update L NOTNULL DEFAULT '0',
- display_report L NOTNULL DEFAULT '1',
- display_update L NOTNULL DEFAULT '1',
- require_resolved L NOTNULL DEFAULT '0',
- display_resolved L NOTNULL DEFAULT '0',
- display_closed L NOTNULL DEFAULT '0',
- require_closed L NOTNULL DEFAULT '0'
+ display_enum C(255) NOTNULL DEFAULT \" '' \"
",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS')));
$upgrade[] = Array('CreateIndexSQL',Array('idx_custom_field_name',config_get('mantis_custom_field_table'),'name'));
$upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_filters_table'),"
Index: api/soap/mantisconnect.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/api/soap/mantisconnect.php,v
retrieving revision 1.1
diff -u -r1.1 mantisconnect.php
--- api/soap/mantisconnect.php 18 Jul 2007 06:52:47 -0000 1.1
+++ api/soap/mantisconnect.php 29 Jul 2007 04:18:36 -0000
@@ -479,14 +479,7 @@
'length_min' => array( 'name' => 'length_min', 'type' => 'xsd:integer', 'minOccurs' => '0'),
'length_max' => array( 'name' => 'length_max', 'type' => 'xsd:integer', 'minOccurs' => '0'),
'advanced' => array( 'name' => 'advanced', 'type' => 'xsd:boolean', 'minOccurs' => '0'),
- 'display_report' => array( 'name' => 'display_report', 'type' => 'xsd:boolean', 'minOccurs' => '0'),
- 'display_update' => array( 'name' => 'display_update', 'type' => 'xsd:boolean', 'minOccurs' => '0'),
- 'display_resolved' => array( 'name' => 'display_resolved','type' => 'xsd:boolean', 'minOccurs' => '0'),
- 'display_closed' => array( 'name' => 'display_closed', 'type' => 'xsd:boolean', 'minOccurs' => '0'),
- 'require_report' => array( 'name' => 'require_report', 'type' => 'xsd:boolean', 'minOccurs' => '0'),
- 'require_update' => array( 'name' => 'require_update', 'type' => 'xsd:boolean', 'minOccurs' => '0'),
- 'require_resolved' => array( 'name' => 'require_resolved','type' => 'xsd:boolean', 'minOccurs' => '0'),
- 'require_closed' => array( 'name' => 'require_closed', 'type' => 'xsd:boolean', 'minOccurs' => '0')
+ 'display_enum' => array( 'name' => 'display_enum', 'type' => 'xsd:string', 'minOccurs' => '0')
)
);
Index: api/soap/mc_project_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/api/soap/mc_project_api.php,v
retrieving revision 1.1
diff -u -r1.1 mc_project_api.php
--- api/soap/mc_project_api.php 18 Jul 2007 06:52:56 -0000 1.1
+++ api/soap/mc_project_api.php 29 Jul 2007 04:18:28 -0000
@@ -435,14 +435,7 @@
'length_min' => $t_def['length_min'],
'length_max' => $t_def['length_max'],
'advanced' => $t_def['advanced'],
- 'display_report' => $t_def['display_report'],
- 'display_update' => $t_def['display_update'],
- 'display_resolved' => $t_def['display_resolved'],
- 'display_closed' => $t_def['display_closed'],
- 'require_report' => $t_def['require_report'],
- 'require_update' => $t_def['require_update'],
- 'require_resolved' => $t_def['require_resolved'],
- 'require_closed' => $t_def['require_closed'],
+ 'display_enum' => $t_def['display_enum']
);
}
}
Index: core/custom_field_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/custom_field_api.php,v
retrieving revision 1.64
diff -u -r1.64 custom_field_api.php
--- core/custom_field_api.php 6 Jul 2007 07:30:16 -0000 1.64
+++ core/custom_field_api.php 29 Jul 2007 04:59:04 -0000
@@ -280,15 +280,8 @@
$c_access_level_rw = db_prepare_int( $p_def_array['access_level_rw'] );
$c_length_min = db_prepare_int( $p_def_array['length_min'] );
$c_length_max = db_prepare_int( $p_def_array['length_max'] );
- $c_advanced = db_prepare_bool( $p_def_array['advanced'] );
- $c_display_report = db_prepare_bool( $p_def_array['display_report'] );
- $c_display_update = db_prepare_bool( $p_def_array['display_update'] );
- $c_display_resolved = db_prepare_bool( $p_def_array['display_resolved'] );
- $c_display_closed = db_prepare_bool( $p_def_array['display_closed'] );
- $c_require_report = db_prepare_bool( $p_def_array['require_report'] );
- $c_require_update = db_prepare_bool( $p_def_array['require_update'] );
- $c_require_resolved = db_prepare_bool( $p_def_array['require_resolved'] );
- $c_require_closed = db_prepare_bool( $p_def_array['require_closed'] );
+ $c_advanced = db_prepare_bool( $p_def_array['advanced'] );
+ $c_display_enum = db_prepare_string( $p_def_array['display_enum'] );
if (( is_blank( $c_name ) ) ||
( $c_access_level_rw < $c_access_level_r ) ||
@@ -297,11 +290,6 @@
trigger_error( ERROR_CUSTOM_FIELD_INVALID_DEFINITION, ERROR );
}
- if ( $c_advanced == true && ( $c_require_report == true || $c_require_update ) ) {
- trigger_error( ERROR_CUSTOM_FIELD_INVALID_DEFINITION, ERROR );
- }
-
-
if ( !custom_field_is_name_unique( $c_name, $c_field_id ) ) {
trigger_error( ERROR_CUSTOM_FIELD_NAME_NOT_UNIQUE, ERROR );
}
@@ -382,78 +370,22 @@
}
$query .= "length_max='$c_length_max'";
}
- if( array_key_exists( 'advanced', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "advanced='$c_advanced'";
- }
- if( array_key_exists( 'display_report', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "display_report='$c_display_report'";
- }
- if( array_key_exists( 'display_update', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "display_update='$c_display_update'";
- }
- if( array_key_exists( 'display_resolved', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "display_resolved='$c_display_resolved'";
- }
- if( array_key_exists( 'display_closed', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "display_closed='$c_display_closed'";
- }
- if( array_key_exists( 'require_report', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "require_report='$c_require_report'";
- }
- if( array_key_exists( 'require_update', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "require_update='$c_require_update'";
- }
- if( array_key_exists( 'require_resolved', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "require_resolved='$c_require_resolved'";
- }
- if( array_key_exists( 'require_closed', $p_def_array ) ) {
- if ( !$t_update_something ) {
- $t_update_something = true;
- } else {
- $query .= ', ';
- }
- $query .= "require_closed='$c_require_closed'";
- }
+ if( array_key_exists( 'advanced', $p_def_array ) ) {
+ if ( !$t_update_something ) {
+ $t_update_something = true;
+ } else {
+ $query .= ', ';
+ }
+ $query .= "advanced='$c_advanced'";
+ }
+ if( array_key_exists( 'display_enum', $p_def_array ) ) {
+ if ( !$t_update_something ) {
+ $t_update_something = true;
+ } else {
+ $query .= ', ';
+ }
+ $query .= "display_enum='$c_display_enum'";
+ }
$query .= " WHERE id='$c_field_id'";
@@ -691,15 +623,60 @@
} else {
$t_ids = $g_cache_cf_linked[$p_project_id];
}
return $t_ids;
}
+ # --------------------
+ # Return an array of ids of custom fields bound to the specified project and status
+ #
+ function custom_field_get_linked_status_ids( $p_project_id = ALL_PROJECTS, $p_status_id ) {
+
+ # First get the array of custom fields for this project
+ $t_field_ids = custom_field_get_linked_ids( $p_project_id ) ;
+
+ $t_ids = array();
+
+ # For each custom field ID associated with this project
+ foreach ( $t_field_ids as $t_field )
+ {
+ # Get the serialized array of status display values
+ $row = custom_field_cache_row( $t_field ) ;
+ $t_displays = unserialize( $row['display_enum'] ) ;
+
+ # If this field is displayed or required
+ if( $t_displays[$p_status_id] > 0 ) {
+
+ # Add to the array of [field_id][required]
+ # Note that the 2nd value in the array is a boolean indicating if the field is
+ # required (0=no, 1=yes). Since the value is stored in the database as
+ # 1=display, 2=require, we must decrement the value here
+ array_push( $t_ids, array( $t_field, $t_displays[$p_status_id]-1 ) ) ;
+ }
+ }
+
+ return $t_ids;
+ }
+
+ # --------------------
+ # Return an array with the following format:
+ # array[status_id]=[display_value]
+ # where display_value is one of (0:none, 1:display, 2:require)
+ function custom_field_get_status_values( $p_custom_field_id )
+ {
+ # Get the row and unserialize the data
+ $row = custom_field_cache_row( $p_custom_field_id ) ;
+
+ $t_ids = unserialize( $row['display_enum'] ) ;
+
+ return $t_ids ;
+ }
+
# --------------------
# Return an array all custom field ids sorted by name
function custom_field_get_ids( ) {
global $g_cache_cf_list;
if ( $g_cache_cf_list === NULL ) {
$t_custom_field_table = config_get( 'mantis_custom_field_table' );
$query = "SELECT id, name
Index: lang/strings_english.txt
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v
retrieving revision 1.306
diff -u -r1.306 strings_english.txt
--- lang/strings_english.txt 25 Jul 2007 10:50:49 -0000 1.306
+++ lang/strings_english.txt 29 Jul 2007 04:19:38 -0000
@@ -1163,6 +1163,7 @@
$s_update_custom_field_button = 'Update Custom Field';
$s_add_existing_custom_field = 'Add This Existing Custom Field';
$s_edit_custom_field_title = 'Edit custom field';
+$s_edit_custom_field_status_title = 'Edit custom field display properties';
$s_custom_field = 'Field';
$s_custom_fields_setup = 'Custom Fields';
$s_custom_field_name = 'Name';
@@ -1176,17 +1177,12 @@
$s_custom_field_length_min = 'Min. Length';
$s_custom_field_length_max = 'Max. Length';
$s_custom_field_advanced = 'Display Only On Advanced Page';
-$s_custom_field_display_report = 'Display When Reporting Issues';
-$s_custom_field_display_update = 'Display When Updating Issues';
-$s_custom_field_display_resolved = 'Display When Resolving Issues';
-$s_custom_field_display_closed = 'Display When Closing Issues';
-$s_custom_field_require_report = 'Required On Report';
-$s_custom_field_require_update = 'Required On Update';
-$s_custom_field_require_resolved = 'Required On Resolve';
-$s_custom_field_require_closed = 'Required On Close';
$s_link_custom_field_to_project_title = 'Link custom field to project';
$s_link_custom_field_to_project_button = 'Link Custom Field';
$s_linked_projects = 'Linked Projects';
+$s_custom_field_require = 'Require';
+$s_custom_field_display = 'Display';
+$s_custom_field_none = 'None';
$s_custom_field_sequence = 'Sequence';
$s_custom_field_type_enum_string = '0:String,1:Numeric,2:Float,3:Enumeration,4:Email,5:Checkbox,6:List,7:Multiselection list,8:Date';
|