Update of /cvsroot/mantisbt/mantisbt In directory sc8-pr-cvs1:/tmp/cvs-serv32281 Modified Files: config_defaults_inc.php constant_inc.php manage_proj_edit_page.php Added Files: manage_proj_custom_field_add_existing.php manage_proj_custom_field_add_new.php manage_proj_custom_field_delete.php manage_proj_custom_field_edit_page.php manage_proj_custom_field_remove.php manage_proj_custom_field_update.php Log Message: some work from Christian on custom fields I cleaned it up a bit though I haven't finished reviewing the newly added files Everything important should be prevented from loading unless you set the appropriate flag in your config file (see the bottom of config_defaults) --- NEW FILE: manage_proj_custom_field_add_existing.php --- <?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - ke...@30... # Copyright (C) 2002 Mantis Team - man...@li... # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details ?> <?php require_once( 'core.php' ) ?> <?php login_cookie_check() ?> <?php check_access( MANAGER ); if ( empty( $f_field_id ) || empty( $f_project_id ) ) { print_mantis_error( ERROR_EMPTY_FIELD ); } $result = custom_field_bind( $f_field_id, $f_project_id ); $t_redirect_url = 'manage_proj_edit_page.php?f_project_id='.$f_project_id; ?> <?php print_page_top1() ?> <?php if ( $result ) { print_meta_redirect( $t_redirect_url ); } ?> <?php print_page_top2() ?> <br /> <div align="center"> <?php if ( $result ) { # SUCCESS echo lang_get( 'operation_successful' ).'<br />'; } else if ( $duplicate ) { # DUPLICATE echo $MANTIS_ERROR[ERROR_CUSTOM_FIELD_CAPTION_NOT_UNIQUE].'<br />'; } else { # FAILURE print_sql_error( $query ); } print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); ?> </div> <?php print_page_bot1( __FILE__ ) ?> --- NEW FILE: manage_proj_custom_field_add_new.php --- <?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - ke...@30... # Copyright (C) 2002 Mantis Team - man...@li... # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details ?> <?php require_once( 'core.php' ) ?> <?php login_cookie_check() ?> <?php check_access( MANAGER ); if ( empty( $f_caption ) ) { print_mantis_error( ERROR_EMPTY_FIELD ); } $t_captions_array = explode( '|', $f_caption ); $t_count = count( $t_captions_array ); $duplicate = false; foreach ( $t_captions_array as $t_caption ) { $t_caption = trim( $t_caption ); if ( $t_caption == '') { continue; } if ( custom_field_is_caption_unique( $t_caption ) ) { $t_generated_id = custom_field_create( $t_caption ); custom_field_bind( $t_generated_id, $f_project_id ); } else { $duplicate = true; } } $t_redirect_url = 'manage_proj_edit_page.php?f_project_id='.$f_project_id; ?> <?php print_page_top1() ?> <?php print_meta_redirect( $t_redirect_url ); ?> <?php print_page_top2() ?> <br /> <div align="center"> <?php if ( $duplicate ) { # DUPLICATE echo $MANTIS_ERROR[ERROR_CUSTOM_FIELD_CAPTION_NOT_UNIQUE].'<br />'; } print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); ?> </div> <?php print_page_bot1( __FILE__ ) ?> --- NEW FILE: manage_proj_custom_field_delete.php --- <?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - ke...@30... # Copyright (C) 2002 Mantis Team - man...@li... # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details ?> <?php require_once( 'core.php' ) ?> <?php login_cookie_check() ?> <?php check_access( MANAGER ); if ( empty( $f_field_id ) || empty( $f_project_id ) ) { print_mantis_error( ERROR_EMPTY_FIELD ); } $t_affected_projects = false; if( 0 == count( custom_field_get_project_ids( $f_field_id ) ) ) { $result = custom_field_delete( $f_field_id ); } else { $result = false; $t_affected_projects = true; } $t_redirect_url = 'manage_proj_edit_page.php?f_project_id='.$f_project_id; ?> <?php print_page_top1() ?> <?php if ( $result ) { print_meta_redirect( $t_redirect_url ); } ?> <?php print_page_top2() ?> <br /> <div align="center"> <?php if ( $result ) { # SUCCESS echo lang_get( 'operation_successful' ).'<br />'; } else if ( $t_affected_projects ) { echo $MANTIS_ERROR[ERROR_CUSTOM_FIELD_IN_USE].'<br />'; } else { # FAILURE print_sql_error( $query ); } print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); ?> </div> --- NEW FILE: manage_proj_custom_field_edit_page.php --- <?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - ke...@30... # Copyright (C) 2002 Mantis Team - man...@li... # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details ?> <?php require_once( 'core.php' ) ?> <?php login_cookie_check() ?> <?php check_access( MANAGER ); ?> <?php print_page_top1() ?> <?php print_page_top2() ?> <?php print_manage_menu( 'manage_proj_custom_field_edit_page.php' ); custom_field_ensure_exists( $f_field_id ); $t_definition = custom_field_get_definition( $f_field_id ) ?> <br /> <div align="center"> <form method="post" action="manage_proj_custom_field_update.php"> <input type="hidden" name="f_project_id" value="<?php echo $f_project_id ?>" /> <input type="hidden" name="f_field_id" value="<?php echo $f_field_id ?>" /> <table class="width50" cellspacing="1"> <tr> <td class="form-title" colspan="2"> <?php echo lang_get( 'edit_custom_field_title' ) ?> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_caption' ) ?> </td> <td> <input type="text" name="f_caption" size="32" maxlength="64" value="<?php echo $t_definition['caption'] ?>" /> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_type' ) ?> </td> <td> <input type="text" name="f_type" size="32" maxlength="64" value="<?php echo $t_definition['type'] ?>" /> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_possible_values' ) ?> </td> <td> <input type="text" name="f_possible_values" size="32" maxlength="255" value="<?php echo $t_definition['possible_values'] ?>" /> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_default_value' ) ?> </td> <td> <input type="text" name="f_default_value" size="32" maxlength="255" value="<?php echo $t_definition['default_value'] ?>" /> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_valid_regexp' ) ?> </td> <td> <input type="text" name="f_valid_regexp" size="32" maxlength="255" value="<?php echo $t_definition['valid_regexp'] ?>" /> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_access_level_r' ) ?> </td> <td> <select name="f_access_level_r"> <?php print_enum_string_option_list( 'access_levels', $t_definition['access_level_r'] ) ?> </select> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_access_level_rw' ) ?> </td> <td> <select name="f_access_level_rw"> <?php print_enum_string_option_list( 'access_levels', $t_definition['access_level_rw'] ) ?> </select> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_length_min' ) ?> </td> <td> <input type="text" name="f_length_min" size="32" maxlength="64" value="<?php echo $t_definition['length_min'] ?>" /> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_length_max' ) ?> </td> <td> <input type="text" name="f_length_max" size="32" maxlength="64" value="<?php echo $t_definition['length_max'] ?>" /> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_advanced' ) ?> </td> <td> <input type="checkbox" name="f_advanced" value="1" <?php if($t_definition['advanced']) echo 'checked'; ?>> </td> </tr> <tr <?php echo helper_alternate_class() ?>> <td class="category"> <?php echo lang_get( 'custom_field_seqence' ) ?> </td> <td> <input type="text" name="f_seqence" size="32" maxlength="64" value="<?php echo $t_definition['seqence'] ?>" /> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="<?php echo lang_get( 'update_custom_field_button' ) ?>" /> </td> </tr> </table> </form> </div> <br /> <div class="border-center"> <form method="post" action="manage_proj_custom_field_delete.php"> <input type="hidden" name="f_field_id" value="<?php echo $f_field_id ?>" /> <input type="submit" value="<?php echo lang_get( 'delete_custom_field_button' ) ?>" /> </form> </div> <?php print_page_bot1( __FILE__ ) ?> --- NEW FILE: manage_proj_custom_field_remove.php --- <?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - ke...@30... # Copyright (C) 2002 Mantis Team - man...@li... # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details ?> <?php require_once( 'core.php' ) ?> <?php login_cookie_check() ?> <?php check_access( MANAGER ); if ( empty( $f_field_id ) || empty( $f_project_id ) ) { print_mantis_error( ERROR_EMPTY_FIELD ); } $result = custom_field_remove( $f_field_id, $f_project_id ); $t_redirect_url = 'manage_proj_edit_page.php?f_project_id='.$f_project_id; ?> <?php print_page_top1() ?> <?php if ( $result ) { print_meta_redirect( $t_redirect_url ); } ?> <?php print_page_top2() ?> <br /> <div align="center"> <?php if ( $result ) { # SUCCESS echo lang_get( 'operation_successful' ).'<br />'; } else { # FAILURE print_sql_error( $query ); } print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); ?> </div> --- NEW FILE: manage_proj_custom_field_update.php --- <?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - ke...@30... # Copyright (C) 2002 Mantis Team - man...@li... # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details ?> <?php require_once( 'core.php' ) ?> <?php login_cookie_check() ?> <?php check_access( MANAGER ); $f_project_id = gpc_get_int( 'f_project_id' ); $f_field_id = gpc_get_int( 'f_field_id' ); $t_values['caption'] = gpc_get_string( 'f_caption' ); $t_values['type'] = gpc_get_int( 'f_type' ); $t_values['possible_values'] = gpc_get_string( 'f_possible_values' ); $t_values['default_value'] = gpc_get_string( 'f_default_value' ); $t_values['valid_regexp'] = gpc_get_string( 'f_valid_regexp' ); $t_values['access_level_r'] = gpc_get_int( 'f_access_level_r' ); $t_values['access_level_rw'] = gpc_get_int( 'f_access_level_rw' ); $t_values['length_min'] = gpc_get_int( 'f_length_min' ); $t_values['length_max'] = gpc_get_int( 'f_length_max' ); $t_values['advanced'] = gpc_get_int( 'f_advanced', 0 ); $t_values['seqence'] = gpc_get_int( 'f_seqence' ); $result = custom_field_update( $f_field_id, $t_values ); $t_redirect_url = 'manage_proj_edit_page.php?f_project_id='.$f_project_id; ?> <?php print_page_top1() ?> <?php if ( $result ) { print_meta_redirect( $t_redirect_url ); } ?> <?php print_page_top2() ?> <br /> <div align="center"> <?php if ( $result ) { # SUCCESS echo lang_get( 'operation_successful' ).'<br />'; } else { # FAILURE print_sql_error( $query ); } print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); ?> </div> <?php print_page_bot1( __FILE__ ) ?> Index: config_defaults_inc.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/config_defaults_inc.php,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- config_defaults_inc.php 12 Nov 2002 12:08:35 -0000 1.35 +++ config_defaults_inc.php 25 Nov 2002 08:06:00 -0000 1.36 @@ -572,8 +572,8 @@ 'closed' => '#e8e8e8'); # light gray # --- custom status color codes ---------- # array for colors assoociated with custom attributes - # @@@@ Consider changing the values in this array to point to $s_color_<xxxx>. For example, - # lang_get('color_antique_white') should return 'Antique White' for English language. + # @@@@ Consider changing the values in this array to point to $s_color_<xxxx>. For example, + # lang_get('color_antique_white') should return 'Antique White' for English language. $g_custom_colors = array('#FAEBD7' => 'ANTIQUEWHITE', '#F5DEB3' => 'WHEAT', '#FFD700' => 'GOLD', @@ -672,6 +672,9 @@ $g_mantis_user_pref_table = $g_db_table_prefix.'_user_pref_table'; $g_mantis_user_print_pref_table = $g_db_table_prefix.'_user_print_pref_table'; $g_mantis_project_customization_table = $g_db_table_prefix.'_project_customization_table'; + $g_mantis_custom_field_project_table = $g_db_table_prefix.'_custom_field_project_table'; + $g_mantis_custom_field_table = $g_db_table_prefix.'_custom_field_table'; + $g_mantis_custom_field_string_table = $g_db_table_prefix.'_custom_field_string_table'; ########################### # Mantis Enum Strings @@ -821,4 +824,14 @@ # Assign to this variable a keyword that won't change. If this value changes # all hyper links to defects will be not work. $g_admin_crypt_word = $g_path; + + ########################### + # Experimental features + ########################### + # --- custom fields --------- + # allow the user / administrator to create custom fields for each project + # WARNING: this feature is in heavy development and is subject to change. + # There will be no upgrade path for this stuff as it is being developed. + # So don't enable it now unless you're developing on it. + $g_use_experimental_custom_fields = OFF; ?> Index: constant_inc.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/constant_inc.php,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- constant_inc.php 13 Nov 2002 03:58:39 -0000 1.60 +++ constant_inc.php 25 Nov 2002 08:06:00 -0000 1.61 @@ -202,6 +202,8 @@ # ERROR_CUSTOM_FIELD_* define( 'ERROR_CUSTOM_FIELD_NOT_FOUND', 1300 ); + define( 'ERROR_CUSTOM_FIELD_CAPTION_NOT_UNIQUE',1301 ); + define( 'ERROR_CUSTOM_FIELD_IN_USE', 1302 ); # Status Legend Position define( 'STATUS_LEGEND_POSITION_TOP', 1); Index: manage_proj_edit_page.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/manage_proj_edit_page.php,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- manage_proj_edit_page.php 12 Nov 2002 05:19:03 -0000 1.40 +++ manage_proj_edit_page.php 25 Nov 2002 08:06:00 -0000 1.41 @@ -254,4 +254,99 @@ </table> </div> +<?php if( ON == config_get( 'use_experimental_custom_fields' ) ) { ?> +<br /> +<div align="center"> +<table class="width75" cellspacing="1"> +<tr> + <td class="form-title" colspan="2"> + <?php echo lang_get( 'custom_fields_setup' ) ?> + </td> +</tr> +<tr class="row-category"> + <td width="100%"> + <?php echo lang_get( 'custom_fields' ) ?> + </td> +</tr> +<tr> + <td width="100%"> + <table width="100%" cellspacing="1"> + <?php + $t_custom_fields = custom_field_get_ids( $f_project_id ); + + foreach( $t_custom_fields as $t_this_field_id ) { + $t_desc = custom_field_get_definition( $t_this_field_id ); + ?> + <tr <?php echo helper_alternate_class( $i ) ?>> + <td width="50%"> + <?php echo $t_desc['caption'] ?> + </td> + <td width="25%"> + <?php echo $t_this_field_id ?> + </td> + <td class="center" width="25%"> + <?php + print_bracket_link( 'manage_proj_custom_field_edit_page.php?f_field_id='.$t_this_field_id.'&f_project_id='.$f_project_id, lang_get( 'edit_link' ) ); + PRINT ' '; + print_bracket_link( 'manage_proj_custom_field_remove.php?f_field_id='.$t_this_field_id.'&f_project_id='.$f_project_id, lang_get( 'remove_link' ) ); + ?> + </td> + </tr> + <?php } # end for loop ?> + </table> + </td> +</tr> +<tr> + <td class="left"> + <form method="post" action="manage_proj_custom_field_add_new.php"> + <input type="hidden" name="f_project_id" value="<?php echo $f_project_id ?>" /> + <input type="text" name="f_caption" size="32" maxlength="64" /> + <input type="submit" value="<?php echo lang_get( 'add_custom_field_button' ) ?>" /> + </form> + </td> +</tr> +<tr> + <td class="left"> + <form method="post" action="manage_proj_custom_field_add_existing.php"> + <input type="hidden" name="f_project_id" value="<?php echo $f_project_id ?>" /> + <select name="f_field_id"> + <?php + $t_custom_fields = custom_field_get_ids(); + + foreach( $t_custom_fields as $t_this_field_id ) + { + if( !custom_field_in_project( $t_this_field_id, $f_project_id ) ) { + $t_desc = custom_field_get_definition( $t_this_field_id ); + echo "<option value=\"$t_this_field_id\">" . $t_desc['caption'] . '</option>' ; + } + } + ?> + </select> + <input type="submit" value="<?php echo lang_get( 'add_existing_custom_field' ) ?>" /> + </form> + </td> +</tr> +<tr> + <td class="left"> + <form method="post" action="manage_proj_custom_field_delete.php"> + <input type="hidden" name="f_project_id" value="<?php echo $f_project_id ?>" /> + <select name="f_field_id"> + <?php + $t_custom_fields = custom_field_get_ids(); + + foreach( $t_custom_fields as $t_this_field_id ) + { + $t_desc = custom_field_get_definition( $t_this_field_id ); + echo "<option value=\"$t_this_field_id\">" . $t_desc['caption'] . '</option>' ; + } + ?> + </select> + <input type="submit" value="<?php echo lang_get( 'delete_custom_field_everywhere' ) ?>" /> + </form> + </td> +</tr> +</table> +</div> +<?php } // ON = config_get( 'use_experimental_custom_fields' ) ?> + <?php print_page_bot1( __FILE__ ) ?> |