From 28a143050a44fa64a9464b7b1c8928fb9865f9dd Mon Sep 17 00:00:00 2001 From: Julian Fitzell Date: Sat, 8 Feb 2003 22:47:03 +0000 Subject: [PATCH] * constant_inc.php (ERROR_DUPLICATE_CATEGORY): removed (ERROR_CATEGORY_DUPLICATE): added (ERROR_CATEGORY_NOT_FOUND): added (ERROR_CATEGORY_NO_ACTION): added * manage_proj_cat_add.php: * manage_proj_cat_copy.php: * manage_proj_cat_delete.php: * manage_proj_cat_edit_page.php: * manage_proj_cat_update.php: cleaned up all these files * manage_proj_edit_page.php: use string_display() before showing the category name * manage_proj_update.php: remove an unecessary temp variable * core/category_api.php - cleaned up all API functions to use config_get() instead of globals and db_prepare_*() functions (is_duplicate_category): renamed to category_is_unique() and logic reversed (category_is_unique): new function (category_delete): renamed to category_remove() to be symmetric with category_add() (category_remove): renamed from category_delete() to be symmetric with category_add() (category_get_row): added function to get one row (category_update): update the bugs as well as the category table * lang/* (ERROR_DUPLICATE_CATEGORY): renamed to ERROR_CATEGORY_DUPLICATE (ERROR_CATEGORY_DUPLICATE): renamed from ERROR_DUPLICATE_CATEGORY * lang/strings_english.txt (ERROR_CATEGORY_NOT_FOUND): added (ERROR_CATEGORY_NO_ACTION): added git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@1799 f5dc347c-c33d-0410-90a0-b07cc1902cb9 --- constant_inc.php | 8 +- core/category_api.php | 135 ++++++++++++++++++--------- lang/strings_chinese_simplified.txt | 10 +- lang/strings_chinese_traditional.txt | 10 +- lang/strings_czech.txt | 10 +- lang/strings_danish.txt | 10 +- lang/strings_dutch.txt | 10 +- lang/strings_english.txt | 10 +- lang/strings_french.txt | 8 +- lang/strings_german.txt | 10 +- lang/strings_hungarian.txt | 10 +- lang/strings_italian.txt | 10 +- lang/strings_japanese_euc.txt | 10 +- lang/strings_japanese_sjis.txt | 10 +- lang/strings_korean.txt | 10 +- lang/strings_norwegian.txt | 10 +- lang/strings_polish.txt | 10 +- lang/strings_portuguese_brazil.txt | 10 +- lang/strings_portuguese_standard.txt | 10 +- lang/strings_romanian.txt | 10 +- lang/strings_russian.txt | 10 +- lang/strings_russian_koi8.txt | 10 +- lang/strings_spanish.txt | 10 +- lang/strings_swedish.txt | 10 +- lang/strings_turkish.txt | 10 +- manage_proj_cat_add.php | 54 +++++------ manage_proj_cat_copy.php | 17 ++-- manage_proj_cat_delete.php | 19 ++-- manage_proj_cat_edit_page.php | 34 ++++--- manage_proj_cat_update.php | 51 ++++------ manage_proj_edit_page.php | 4 +- manage_proj_update.php | 5 +- 32 files changed, 298 insertions(+), 257 deletions(-) diff --git a/constant_inc.php b/constant_inc.php index cbfbdafe2b..ac7cadc902 100644 --- a/constant_inc.php +++ b/constant_inc.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: constant_inc.php,v 1.70 2003-01-24 00:09:05 vboctor Exp $ + # $Id: constant_inc.php,v 1.71 2003-02-08 22:46:59 jfitzell Exp $ # -------------------------------------------------------- ########################################################################### @@ -139,7 +139,6 @@ define( 'ERROR_NO_FILE_SPECIFIED', 4 ); define( 'ERROR_FILE_DISALLOWED', 5 ); define( 'ERROR_NO_DIRECTORY', 6 ); - define( 'ERROR_DUPLICATE_CATEGORY', 7 ); define( 'ERROR_DUPLICATE_VERSION', 8 ); define( 'ERROR_DUPLICATE_FILE', 9 ); define( 'ERROR_DUPLICATE_PROJECT', 10 ); @@ -212,6 +211,11 @@ define( 'ERROR_LDAP_UPDATE_FAILED', 1402 ); define( 'ERROR_LDAP_USER_NOT_FOUND', 1402 ); + # ERROR_CATEGORY_* + define( 'ERROR_CATEGORY_DUPLICATE', 1500 ); + define( 'ERROR_CATEGORY_NO_ACTION', 1501 ); + define( 'ERROR_CATEGORY_NOT_FOUND', 1502 ); + # Status Legend Position define( 'STATUS_LEGEND_POSITION_TOP', 1); define( 'STATUS_LEGEND_POSITION_BOTTOM', 2); diff --git a/core/category_api.php b/core/category_api.php index 1edc485772..2ac9b028ad 100644 --- a/core/category_api.php +++ b/core/category_api.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: category_api.php,v 1.5 2003-01-30 09:41:31 jfitzell Exp $ + # $Id: category_api.php,v 1.6 2003-02-08 22:47:01 jfitzell Exp $ # -------------------------------------------------------- ########################################################################### @@ -14,80 +14,122 @@ ########################################################################### # -------------------- - # checks to see if the category is a duplicate - # we do it this way because each different project can have the same category names - # The old category name is excluded from the search for duplicate since a category - # can re-take its name. It is also useful when changing the case of a category name. - # For example, "category" -> "Category". - function is_duplicate_category( $p_project_id, $p_category , $p_old_category = '' ) { - global $g_mantis_project_category_table; - - $c_project_id = (integer)$p_project_id; - $c_category = addslashes($p_category); + # Check whether the category is unique within a project + # Returns true if the category is unique, false otherwise + function category_is_unique( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); $query = "SELECT COUNT(*) - FROM $g_mantis_project_category_table + FROM $t_project_category_table WHERE project_id='$c_project_id' AND category='$c_category'"; - if (strlen($p_old_category) != 0) { - $c_old_category = addslashes($p_old_category); - $query = $query . " AND category <> '$c_old_category'"; - } - $result = db_query( $query ); - $category_count = db_result( $result, 0, 0 ); + $category_count = db_result( $result ); - return ( $category_count > 0 ); + if ( 0 == $category_count ) { + return true; + } else { + return false; + } } + # -------------------- + # Add a new category to the project function category_add( $p_project_id, $p_category ) { - global $g_mantis_project_category_table; + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); - $c_project_id = (integer)$p_project_id; - $c_category = addslashes($p_category); + $t_project_category_table = config_get( 'mantis_project_category_table' ); $query = "INSERT - INTO $g_mantis_project_category_table + INTO $t_project_category_table ( project_id, category ) VALUES ( '$c_project_id', '$c_category' )"; - return db_query( $query ); + db_query( $query ); + + # db_query() errors on failure so: + return true; } + # -------------------- - function category_update( $p_project_id, $p_category, $p_orig_category, $p_assigned_to ) { - global $g_mantis_project_category_table; + # Update the name and user associated with the category + function category_update( $p_project_id, $p_category, $p_new_category, $p_assigned_to ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); + $c_new_category = db_prepare_string( $p_new_category ); + $c_assigned_to = db_prepare_int( $p_assigned_to ); + + $t_project_category_table = config_get( 'mantis_project_category_table' ); + $t_bug_table = config_get( 'mantis_bug_table' ); + + $query = "UPDATE $t_project_category_table + SET category='$c_new_category', user_id=$c_assigned_to + WHERE category='$c_category' AND + project_id='$c_project_id'"; + db_query( $query ); - $c_project_id = (integer)$p_project_id; - $c_category = addslashes($p_category); - $c_orig_category = addslashes($p_orig_category); - $c_assigned_to = (integer)$p_assigned_to; + if ( $p_category != $p_new_category ) { + $query = "UPDATE $t_bug_table + SET category='$c_new_category' + WHERE category='$c_category' + AND project_id='$c_project_id'"; + db_query( $query ); + } - $query = "UPDATE $g_mantis_project_category_table - SET category='$c_category', user_id=$c_assigned_to - WHERE category='$c_orig_category' AND - project_id='$c_project_id'"; - return db_query( $query ); + # db_query() errors on failure so: + return true; } + # -------------------- - function category_delete( $p_project_id, $p_category ) { - global $g_mantis_project_category_table; + # Remove a category from the project + function category_remove( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); - $c_project_id = (integer)$p_project_id; - $c_category = addslashes($p_category); + $t_project_category_table = config_get( 'mantis_project_category_table' ); $query = "DELETE - FROM $g_mantis_project_category_table + FROM $t_project_category_table WHERE project_id='$c_project_id' AND category='$c_category'"; - return db_query( $query ); + db_query( $query ); + + # db_query() errors on failure so: + return true; } + # -------------------- - # return all categories for the specified project id - function category_get_all_rows( $p_project_id ) { - global $g_mantis_project_category_table; + # Return the definition row for the category + function category_get_row( $p_project_id, $p_category ) { + $c_project_id = db_prepare_int( $p_project_id ); + $c_category = db_prepare_string( $p_category ); - $c_project_id = db_prepare_int( $p_project_id ); + $t_project_category_table = config_get( 'mantis_project_category_table' ); + + $query = "SELECT category, user_id + FROM $t_project_category_table + WHERE project_id='$c_project_id' + AND category='$c_category'"; + $result = db_query( $query ); + + $count = db_num_rows( $result ); + + if ( 0 == $count ) { + trigger_error( ERROR_CATEGORY_NOT_FOUND, ERROR ); + } + + return db_fetch_array( $result ); + } + + # -------------------- + # Return all categories for the specified project id + function category_get_all_rows( $p_project_id ) { + $c_project_id = db_prepare_int( $p_project_id ); $t_project_category_table = config_get( 'mantis_project_category_table' ); @@ -109,8 +151,9 @@ function category_get_all_rows( $p_project_id ) { return $rows; } + # -------------------- - # delete all categories associated with a project + # Delete all categories associated with a project function category_delete_all( $p_project_id ) { $c_project_id = db_prepare_int( $p_project_id ); diff --git a/lang/strings_chinese_simplified.txt b/lang/strings_chinese_simplified.txt index a21b9b7167..5e268ac9a5 100644 --- a/lang/strings_chinese_simplified.txt +++ b/lang/strings_chinese_simplified.txt @@ -7,11 +7,11 @@ # Chinese_Simplified: Kai-Zheng Cheng, neek@sina.com # ------------------------------------------------- - # $Revision: 1.18 $ - # $Author: beerfrick $ - # $Date: 2003-01-29 22:19:06 $ + # $Revision: 1.19 $ + # $Author: jfitzell $ + # $Date: 2003-02-08 22:47:01 $ # - # $Id: strings_chinese_simplified.txt,v 1.18 2003-01-29 22:19:06 beerfrick Exp $ + # $Id: strings_chinese_simplified.txt,v 1.19 2003-02-08 22:47:01 jfitzell Exp $ ########################################################################### ?> @@ -142,7 +142,7 @@ $MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = 'FOUT: Geen bestand opgegeven.'; $MANTIS_ERROR[ERROR_FILE_DISALLOWED] = 'FOUT: Het bestandstype is niet toegestaan'; $MANTIS_ERROR[ERROR_NO_DIRECTORY] = 'FOUT: De folder bestaat niet. Controleer de project instellingen.'; - $MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY] = 'FOUT: Deze categorie bestaat al.'; + $MANTIS_ERROR[ERROR_CATEGORY_DUPLICATE] = 'FOUT: Deze categorie bestaat al.'; $MANTIS_ERROR[ERROR_DUPLICATE_VERSION] = 'FOUT: Deze versie bestaat al.'; $MANTIS_ERROR[ERROR_DUPLICATE_FILE] = 'FOUT: Dit bestand bestaat al. Verwijder het bestand eerst.'; $MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'FOUT: Dit project bestaat al.'; diff --git a/lang/strings_english.txt b/lang/strings_english.txt index f47c786a70..504e5d0680 100644 --- a/lang/strings_english.txt +++ b/lang/strings_english.txt @@ -9,11 +9,11 @@ ########################################################################### # English strings for Mantis # ------------------------------------------------- - # $Revision: 1.108 $ + # $Revision: 1.109 $ # $Author: jfitzell $ - # $Date: 2003-01-30 07:16:38 $ + # $Date: 2003-02-08 22:47:02 $ # - # $Id: strings_english.txt,v 1.108 2003-01-30 07:16:38 jfitzell Exp $ + # $Id: strings_english.txt,v 1.109 2003-02-08 22:47:02 jfitzell Exp $ ########################################################################### ?> # Polish: Jaroslaw Lewandowski # ------------------------------------------------- - # $Revision: 1.43 $ - # $Author: beerfrick $ - # $Date: 2003-01-29 22:19:12 $ + # $Revision: 1.44 $ + # $Author: jfitzell $ + # $Date: 2003-02-08 22:47:03 $ # - # $Id: strings_polish.txt,v 1.43 2003-01-29 22:19:12 beerfrick Exp $ + # $Id: strings_polish.txt,v 1.44 2003-02-08 22:47:03 jfitzell Exp $ ########################################################################### ?> - - + print_page_top1(); + + print_meta_redirect( $t_redirect_url ); + print_page_top2(); +?>
'; - } else if ( $duplicate ) { # DUPLICATE - echo $MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY].'
'; - } else { # FAILURE - print_sql_error( $query ); - } + echo lang_get( 'operation_successful' ) . '
'; print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); ?> diff --git a/manage_proj_cat_copy.php b/manage_proj_cat_copy.php index 4335a62d5b..d9aa5d555c 100644 --- a/manage_proj_cat_copy.php +++ b/manage_proj_cat_copy.php @@ -4,6 +4,10 @@ # Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id: manage_proj_cat_copy.php,v 1.16 2003-02-08 22:47:00 jfitzell Exp $ + # -------------------------------------------------------- ?> diff --git a/manage_proj_cat_delete.php b/manage_proj_cat_delete.php index 31518e3a2a..4e07354db1 100644 --- a/manage_proj_cat_delete.php +++ b/manage_proj_cat_delete.php @@ -4,6 +4,10 @@ # Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id: manage_proj_cat_delete.php,v 1.17 2003-02-08 22:47:00 jfitzell Exp $ + # -------------------------------------------------------- ?> diff --git a/manage_proj_cat_edit_page.php b/manage_proj_cat_edit_page.php index bb0e77db8d..bafa9068eb 100644 --- a/manage_proj_cat_edit_page.php +++ b/manage_proj_cat_edit_page.php @@ -4,8 +4,18 @@ # Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id: manage_proj_cat_edit_page.php,v 1.23 2003-02-08 22:47:00 jfitzell Exp $ + # -------------------------------------------------------- +?> + - @@ -32,24 +42,24 @@ - +> - - + + - + - +> @@ -69,9 +79,9 @@
- - - + + +
diff --git a/manage_proj_cat_update.php b/manage_proj_cat_update.php index 004a3a220a..00abec49bd 100644 --- a/manage_proj_cat_update.php +++ b/manage_proj_cat_update.php @@ -4,6 +4,10 @@ # Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net # This program is distributed under the terms and conditions of the GPL # See the README and LICENSE files for details + + # -------------------------------------------------------- + # $Id: manage_proj_cat_update.php,v 1.26 2003-02-08 22:47:00 jfitzell Exp $ + # -------------------------------------------------------- ?> - - + print_page_top1(); + + print_meta_redirect( $t_redirect_url ); + print_page_top2(); +?>
'; - } else if ( is_duplicate_category( $f_project_id, $f_category, $f_orig_category )) { - echo $MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY].'
'; - } else { # FAILURE - print_sql_error( $query ); - } + echo lang_get( 'operation_successful' ) . '
'; print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); ?> diff --git a/manage_proj_edit_page.php b/manage_proj_edit_page.php index fb15f56dbb..79895f9518 100644 --- a/manage_proj_edit_page.php +++ b/manage_proj_edit_page.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: manage_proj_edit_page.php,v 1.52 2003-01-30 09:41:21 jfitzell Exp $ + # $Id: manage_proj_edit_page.php,v 1.53 2003-02-08 22:47:00 jfitzell Exp $ # -------------------------------------------------------- ?> > - + diff --git a/manage_proj_update.php b/manage_proj_update.php index 2cb3cb3b1f..4750a54a2e 100644 --- a/manage_proj_update.php +++ b/manage_proj_update.php @@ -6,7 +6,7 @@ # See the README and LICENSE files for details # -------------------------------------------------------- - # $Id: manage_proj_update.php,v 1.22 2003-01-30 09:41:24 jfitzell Exp $ + # $Id: manage_proj_update.php,v 1.23 2003-02-08 22:47:00 jfitzell Exp $ # -------------------------------------------------------- ?> @@ -24,6 +24,5 @@ project_update( $f_project_id, $f_name, $f_description, $f_status, $f_view_state, $f_file_path, $f_enabled ); - $t_redirect_url = 'manage_proj_page.php'; - print_header_redirect( $t_redirect_url ); + print_header_redirect( 'manage_proj_page.php' ); ?>