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 04:40:06 -0000 @@ -22,13 +22,13 @@ project_id != helper_get_current_project() ) { # in case the current project is not the same project of the bug we are viewing... # ... override the current project. This to avoid problems with categories and handlers lists etc. $g_project_override = $t_bug->project_id; } - + $f_new_status = gpc_get_int( 'new_status' ); $f_reopen_flag = gpc_get_int( 'reopen_flag', OFF ); @@ -113,7 +113,7 @@ name="category"> - ', string_attribute( lang_get( 'select_option' ) ), ''; } - print_category_option_list( $f_category ); + print_category_option_list( $f_category ); ?> @@ -415,16 +415,16 @@ > - * + * Index: bug_report_page.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/bug_report_page.php,v retrieving revision 1.64 diff -u -r1.64 bug_report_page.php --- bug_report_page.php 13 Jul 2007 07:58:27 -0000 1.64 +++ bug_report_page.php 27 Jul 2007 04:46:25 -0000 @@ -132,12 +132,12 @@ echo "[" . project_get_field( $t_bug->project_id, 'name' ) . "] "; } ?> @@ -259,15 +259,15 @@ > - + * 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 04:51:54 -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 04:53:28 -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; ?> > - * + * 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['advanced'] ) || $t_def['require_update']) && custom_field_has_write_access( $t_id, $f_bug_id ) ) { + $t_def = custom_field_get_definition( $t_id[0] ); + if( ( ( !$t_def['advanced'] ) || $t_id[1]) && custom_field_has_write_access( $t_id[0], $f_bug_id ) ) { $t_custom_fields_found = true; ?> > - * + * 'zip.gif', 'ace' => 'zip.gif', 'arj' => 'zip.gif', @@ -1685,7 +1686,7 @@ $g_rss_enabled = ON; # This seed is used as part of the inputs for calculating the authentication key for the RSS feeds. - # If this seed changes, all the existing keys for the RSS feeds will become invalid. This is + # If this seed changes, all the existing keys for the RSS feeds will become invalid. This is # defaulted to the database user name, but it is recommended to overwrite it with a specific value # on installation. $g_rss_key_seed = '%db_username%'; @@ -1764,7 +1765,7 @@ # Custom Group Actions # # This extensibility model allows developing new group custom actions. This - # can be implemented with a totally custom form and action pages or with a + # can be implemented with a totally custom form and action pages or with a # pre-implemented form and action page and call-outs to some functions. These # functions are to be implemented in a predefined file whose name is based on # the action name. For example, for an action to add a note, the action would @@ -1792,26 +1793,26 @@ ##################### # Wiki Integration ##################### - + # Wiki Integration Enabled? $g_wiki_enable = OFF; # Wiki Engine (supported engines: 'dokuwiki', 'mediawiki') $g_wiki_engine = 'dokuwiki'; - + # Wiki namespace to be used as root for all pages relating to this mantis installation. $g_wiki_root_namespace = 'mantis'; - + # URL under which the wiki engine is hosted. Must be on the same server. $g_wiki_engine_url = $t_protocol . '://' . $t_host . '/%wiki_engine%/'; - + ##################### # Recently Visited ##################### # Whether to show the most recently visited issues or not. At the moment we always track them even if this flag is off. $g_recently_visited = ON; - + # The maximum number of issues to keep in the recently visited list. $g_recently_visited_count = 5; @@ -1847,7 +1848,7 @@ # Threshold needed to be able to create and modify global profiles $g_manage_global_profile_threshold = MANAGER; - # Allows the users to enter free text when reporting/updating issues + # Allows the users to enter free text when reporting/updating issues # for the profile related fields (i.e. platform, os, os build) $g_allow_freetext_in_profile_fields = ON; @@ -1861,7 +1862,7 @@ # The twitter account user name. $g_twitter_username = ''; - + # The twitter account password. $g_twitter_password = ''; ?> Index: manage_custom_field_edit_page.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/manage_custom_field_edit_page.php,v retrieving revision 1.25 diff -u -r1.25 manage_custom_field_edit_page.php --- manage_custom_field_edit_page.php 18 May 2007 03:17:59 -0000 1.25 +++ manage_custom_field_edit_page.php 27 Jul 2007 05:00:04 -0000 @@ -129,73 +129,56 @@ /> - > - - - - - /> - - - > - - - - - /> - - - > - - - - - /> - - - > - - - - - /> - - - > - - - - - /> - - - > - - - - - /> - - - > - - - - - /> - - - > - - - - - /> - - - -   - + +

+ + + + + + + + + + + + $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 27 Jul 2007 05:09:52 -0000 @@ -42,6 +42,21 @@ 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); + if( $t_status_display_val > 0 ) { + array_push( $t_status_display, array( $t_status, $t_status_display_val ) ) ; + } + } + + # Update the custom field status display values + custom_field_status_update( $f_field_id, $t_status_display ); + html_page_top1(); html_meta_redirect( $f_return ); Index: admin/db_stats.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/admin/db_stats.php,v retrieving revision 1.3 diff -u -r1.3 db_stats.php --- admin/db_stats.php 10 Feb 2007 12:19:10 -0000 1.3 +++ admin/db_stats.php 27 Jul 2007 05:11:10 -0000 @@ -47,6 +47,7 @@ print_table_stats( config_get( 'mantis_config_table' ) ); print_table_stats( config_get( 'mantis_custom_field_project_table' ) ); print_table_stats( config_get( 'mantis_custom_field_string_table' ) ); + print_table_stats( config_get( 'mantis_custom_field_status_table' ) ); print_table_stats( config_get( 'mantis_custom_field_table' ) ); print_table_stats( config_get( 'mantis_filters_table' ) ); print_table_stats( config_get( 'mantis_news_table' ) ); Index: admin/db_table_names_inc.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/admin/db_table_names_inc.php,v retrieving revision 1.8 diff -u -r1.8 db_table_names_inc.php --- admin/db_table_names_inc.php 14 Jul 2005 21:38:00 -0000 1.8 +++ admin/db_table_names_inc.php 27 Jul 2007 05:11:41 -0000 @@ -31,6 +31,7 @@ $t_custom_field_project_table = config_get_global( 'mantis_custom_field_project_table' ); $t_custom_field_table = config_get_global( 'mantis_custom_field_table' ); $t_custom_field_string_table = config_get_global( 'mantis_custom_field_string_table' ); + $t_custom_field_status_table = config_get_global( 'mantis_custom_field_status_table' ); $t_upgrade_table = config_get_global( 'mantis_upgrade_table' ); $t_filters_table = config_get_global( 'mantis_filters_table' ); $t_tokens_table = config_get_global( 'mantis_tokens_table' ); 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 05:26:22 -0000 @@ -7,7 +7,7 @@ # -------------------------------------------------------- # $Id: schema.php,v 1.19 2007/07/22 19:51:18 prichards Exp $ # -------------------------------------------------------- - + # Each entry below defines the schema. The upgrade array consists of # two elements # The first is the function to generate SQL statements (see adodb schema doc for more details) @@ -15,8 +15,8 @@ # DropTableSQL, ChangeTableSQL, RenameTableSQL, RenameColumnSQL, AlterColumnSQL, DropColumnSQL # A local function "InsertData" has been provided to add data to the db # The second parameter is an array of the parameters to be passed to the function. - - # An update identifier is inferred from the ordering of this table. ONLY ADD NEW CHANGES TO THE + + # An update identifier is inferred from the ordering of this table. ONLY ADD NEW CHANGES TO THE # END OF THE TABLE!!! $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_config_table')," config_id C(64) NOTNULL PRIMARY, @@ -132,6 +132,11 @@ value C(255) NOTNULL DEFAULT \" '' \" ",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS'))); $upgrade[] = Array('CreateIndexSQL',Array('idx_custom_field_bug',config_get('mantis_custom_field_string_table'),'bug_id')); +$upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_custom_field_status_table')," + field_id I NOTNULL PRIMARY DEFAULT '0', + status_id I NOTNULL PRIMARY DEFAULT '0', + required L NOTNULL DEFAULT '0' +",Array('mysql' => 'TYPE=MyISAM', 'pgsql' => 'WITHOUT OIDS'))); $upgrade[] = Array('CreateTableSQL',Array(config_get('mantis_custom_field_table')," id I NOTNULL PRIMARY AUTOINCREMENT, name C(64) NOTNULL DEFAULT \" '' \", @@ -309,9 +314,9 @@ $upgrade[] = Array('CreateIndexSQL',Array('idx_user_username',config_get('mantis_user_table'),'username',Array('UNIQUE'))); $upgrade[] = Array('CreateIndexSQL',Array('idx_enable',config_get('mantis_user_table'),'enabled')); $upgrade[] = Array('CreateIndexSQL',Array('idx_access',config_get('mantis_user_table'),'access_level')); -$upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), - "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES - ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', " . db_now() . ", " . db_now() . ", 1, 0, 90, 3, 0, 0, '" . +$upgrade[] = Array('InsertData', Array( config_get('mantis_user_table'), + "(username, realname, email, password, date_created, last_visit, enabled, protected, access_level, login_count, lost_password_request_count, failed_login_count, cookie_string) VALUES + ('administrator', '', 'root@localhost', '63a9f0ea7bb98050796b649e85481845', " . db_now() . ", " . db_now() . ", 1, 0, 90, 3, 0, 0, '" . md5( mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() ) ) . md5( time() ) . "')" ) ); $upgrade[] = Array('AlterColumnSQL', Array( config_get( 'mantis_bug_history_table' ), "old_value C(255) NOTNULL" ) ); $upgrade[] = Array('AlterColumnSQL', Array( config_get( 'mantis_bug_history_table' ), "new_value C(255) NOTNULL" ) ); 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 27 Jul 2007 05:41:35 -0000 @@ -469,6 +469,41 @@ return true; } + # -------------------- + # Update the status-specific display of custom fields + function custom_field_status_update( $p_field_id, $p_status_display ) + { + $t_mantis_custom_field_status_table = config_get( 'mantis_custom_field_status_table' ); + $t_field_id = db_prepare_int( $p_field_id ); + + $query = "DELETE FROM $t_mantis_custom_field_status_table + WHERE field_id = $p_field_id"; + db_query( $query ); + + foreach ( $p_status_display as $t_status ) { + $t_status_val = db_prepare_int( $t_status[0] ); + + if( $t_status[1] == 1 ) { + $query = "INSERT INTO $t_mantis_custom_field_status_table + (field_id, status_id) + VALUES + ( $t_field_id, $t_status_val )" ; + + db_query( $query ) ; + } else if( $t_status[1] == 2 ) { + $query = "INSERT INTO $t_mantis_custom_field_status_table + (field_id, status_id, required) + VALUES + ( $t_field_id, $t_status_val, 1 )" ; + + db_query( $query ) ; + } + } + + return true ; + + } + # -------------------- # Add a custom field to a project # return true on success, false on failure or if already added @@ -623,9 +658,9 @@ # The ids will be sorted based on the sequence number associated with the binding function custom_field_get_linked_ids( $p_project_id = ALL_PROJECTS ) { global $g_cache_cf_linked; - + if ( ! isset( $g_cache_cf_linked[$p_project_id] ) ) { - + $t_custom_field_table = config_get( 'mantis_custom_field_table' ); $t_custom_field_project_table = config_get( 'mantis_custom_field_project_table' ); @@ -636,7 +671,7 @@ $t_user_id = auth_get_current_user_id(); $t_pub = VS_PUBLIC; $t_priv = VS_PRIVATE; - + $t_private_access = config_get( 'private_project_threshold' ); if ( is_array( $t_private_access ) ) { if ( 1 == count( $t_private_access ) ) { @@ -646,19 +681,19 @@ } } else { $t_access_clause = ">= $t_private_access "; - } + } - - # select only the ids that the user has some access to + + # select only the ids that the user has some access to # e.g., all fields in public projects, or private projects where the user is listed # or private projects where the user is implicitly listed $query = "SELECT cft.id as id, cft.name as name FROM $t_custom_field_table as cft, $t_user_table ut, $t_project_table pt, $t_custom_field_project_table cfpt - LEFT JOIN $t_project_user_list_table pult + LEFT JOIN $t_project_user_list_table pult on cfpt.project_id = pult.project_id and pult.user_id = $t_user_id - WHERE cft.id = cfpt.field_id AND cfpt.project_id = pt.id AND ut.id = $t_user_id AND - ( pt.view_state = $t_pub OR - ( pt.view_state = $t_priv and pult.user_id = $t_user_id ) OR + WHERE cft.id = cfpt.field_id AND cfpt.project_id = pt.id AND ut.id = $t_user_id AND + ( pt.view_state = $t_pub OR + ( pt.view_state = $t_priv and pult.user_id = $t_user_id ) OR ( pult.user_id is null and ut.access_level $t_access_clause ) ) GROUP BY cft.id, cft.name ORDER BY cft.name ASC"; @@ -671,7 +706,7 @@ } } else { $t_project_clause = "= $p_project_id "; - } + } $query = "SELECT cft.id, cft.name, cfpt.sequence FROM $t_custom_field_table cft, $t_custom_field_project_table cfpt WHERE cfpt.project_id $t_project_clause AND @@ -691,15 +726,73 @@ } 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 ) { + $t_custom_field_status_table = config_get( 'mantis_custom_field_status_table' ); + + # First get the array of custom fields for this project + $t_field_ids = custom_field_get_linked_ids( $p_project_id ) ; + + # Query the database to see if any of the custom field IDs are associated with + # this status. + $query = "SELECT cfs.field_id, cfs.required + FROM $t_custom_field_status_table cfs + WHERE cfs.status_id = $p_status_id AND + cfs.field_id IN (" . implode( ',', $t_field_ids ) . ")" ; + + $result = db_query( $query ); + $t_row_count = db_num_rows( $result ); + $t_ids = array(); + + for ( $i=0 ; $i < $t_row_count ; $i++ ) { + $row = db_fetch_array( $result ); + + array_push( $t_ids, array( $row['field_id'], $row['required'] ) ); + } + + 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 ) + { + $t_custom_field_status_table = config_get( 'mantis_custom_field_status_table' ); + + $query = "SELECT cfs.status_id, cfs.required + FROM $t_custom_field_status_table cfs + WHERE cfs.field_id = $p_custom_field_id" ; + + $result = db_query( $query ); + $t_row_count = db_num_rows( $result ); + $t_ids = array(); + + for ( $i=0 ; $i < $t_row_count ; $i++ ) { + $row = db_fetch_array( $result ); + + if( $row['required'] ) { + $t_ids[$row['status_id']] = 2 ; + } else { + $t_ids[$row['status_id']] = 1 ; + } + } + + 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 27 Jul 2007 05:18:48 -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'; @@ -1187,6 +1188,9 @@ $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';
+ +
+ + + + + + + +
+ + + > + + > + + > +