Skip to content

Commit

Permalink
* constant_inc.php
Browse files Browse the repository at this point in the history
  (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
  • Loading branch information
Julian Fitzell committed Feb 8, 2003
1 parent c6ed948 commit 28a1430
Show file tree
Hide file tree
Showing 32 changed files with 298 additions and 257 deletions.
8 changes: 6 additions & 2 deletions constant_inc.php
Expand Up @@ -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 $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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);
Expand Down
135 changes: 89 additions & 46 deletions core/category_api.php
Expand Up @@ -6,88 +6,130 @@
# 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 $
# --------------------------------------------------------

###########################################################################
# Category API
###########################################################################

# --------------------
# 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' );

Expand All @@ -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 );

Expand Down
10 changes: 5 additions & 5 deletions lang/strings_chinese_simplified.txt
Expand Up @@ -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 $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -139,7 +139,7 @@
$MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = "ERROR: No file specified";
$MANTIS_ERROR[ERROR_FILE_DISALLOWED] = "ERROR: The file type is disallowed";
$MANTIS_ERROR[ERROR_NO_DIRECTORY] = "ERROR: The directory does not exist. Please check the project settings.";
$MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY] = "ERROR: This is a duplicate category.";
$MANTIS_ERROR[ERROR_CATEGORY_DUPLICATE] = "ERROR: This is a duplicate category.";
$MANTIS_ERROR[ERROR_DUPLICATE_VERSION] = "ERROR: This is a duplicate version.";
$MANTIS_ERROR[ERROR_DUPLICATE_FILE] = "ERROR: This is a duplicate file. Please delete the file first.";
$MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'ERROR: A project with that name already exists.';
Expand Down
10 changes: 5 additions & 5 deletions lang/strings_chinese_traditional.txt
Expand Up @@ -7,11 +7,11 @@

# Chinese_Traditional: Pao-Hsi Huang, doggy8088@mail2000.com.tw
# -------------------------------------------------
# $Revision: 1.37 $
# $Author: beerfrick $
# $Date: 2003-01-29 22:19:07 $
# $Revision: 1.38 $
# $Author: jfitzell $
# $Date: 2003-02-08 22:47:01 $
#
# $Id: strings_chinese_traditional.txt,v 1.37 2003-01-29 22:19:07 beerfrick Exp $
# $Id: strings_chinese_traditional.txt,v 1.38 2003-02-08 22:47:01 jfitzell Exp $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -139,7 +139,7 @@
$MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = 'ERROR: No file specified';
$MANTIS_ERROR[ERROR_FILE_DISALLOWED] = 'ERROR: The file type is disallowed';
$MANTIS_ERROR[ERROR_NO_DIRECTORY] = 'ERROR: The directory does not exist. Please check the project settings.';
$MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY] = 'ERROR: This is a duplicate category.';
$MANTIS_ERROR[ERROR_CATEGORY_DUPLICATE] = 'ERROR: This is a duplicate category.';
$MANTIS_ERROR[ERROR_DUPLICATE_VERSION] = 'ERROR: This is a duplicate version.';
$MANTIS_ERROR[ERROR_DUPLICATE_FILE] = 'ERROR: This is a duplicate file. Please delete the file first.';
$MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'ERROR: A project with that name already exists.';
Expand Down
10 changes: 5 additions & 5 deletions lang/strings_czech.txt
Expand Up @@ -8,11 +8,11 @@
# Czech: Pavel Loupal, Pavel.Loupal@seznam.cz
# Code page: ISO-8259-2
# -------------------------------------------------
# $Revision: 1.29 $
# $Author: beerfrick $
# $Date: 2003-01-29 22:19:07 $
# $Revision: 1.30 $
# $Author: jfitzell $
# $Date: 2003-02-08 22:47:02 $
#
# $Id: strings_czech.txt,v 1.29 2003-01-29 22:19:07 beerfrick Exp $
# $Id: strings_czech.txt,v 1.30 2003-02-08 22:47:02 jfitzell Exp $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -140,7 +140,7 @@
$MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = 'ERROR: No file specified';
$MANTIS_ERROR[ERROR_FILE_DISALLOWED] = 'ERROR: The file type is disallowed';
$MANTIS_ERROR[ERROR_NO_DIRECTORY] = 'ERROR: The directory does not exist. Please check the project settings.';
$MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY] = 'ERROR: This is a duplicate category.';
$MANTIS_ERROR[ERROR_CATEGORY_DUPLICATE] = 'ERROR: This is a duplicate category.';
$MANTIS_ERROR[ERROR_DUPLICATE_VERSION] = 'ERROR: This is a duplicate version.';
$MANTIS_ERROR[ERROR_DUPLICATE_FILE] = 'ERROR: This is a duplicate file. Please delete the file first.';
$MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'ERROR: A project with that name already exists.';
Expand Down
10 changes: 5 additions & 5 deletions lang/strings_danish.txt
Expand Up @@ -7,11 +7,11 @@

# Danish: S�ren Mortensen, sm@artmus.dk
# -------------------------------------------------
# $Revision: 1.39 $
# $Author: beerfrick $
# $Date: 2003-01-29 22:19:07 $
# $Revision: 1.40 $
# $Author: jfitzell $
# $Date: 2003-02-08 22:47:02 $
#
# $Id: strings_danish.txt,v 1.39 2003-01-29 22:19:07 beerfrick Exp $
# $Id: strings_danish.txt,v 1.40 2003-02-08 22:47:02 jfitzell Exp $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -139,7 +139,7 @@
$MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = 'FEJL: Der er ikke valgt en fil';
$MANTIS_ERROR[ERROR_FILE_DISALLOWED] = 'FEJL: Denne fil-type er ikke tilladt';
$MANTIS_ERROR[ERROR_NO_DIRECTORY] = 'FEJL: Denne mappe findes ikke. Unders�g venligst projekts indstillinger.';
$MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY] = 'FEJL: Denne kategori findes allerede.';
$MANTIS_ERROR[ERROR_CATEGORY_DUPLICATE] = 'FEJL: Denne kategori findes allerede.';
$MANTIS_ERROR[ERROR_DUPLICATE_VERSION] = 'FEJL: Denne version findes allerede.';
$MANTIS_ERROR[ERROR_DUPLICATE_FILE] = 'FEJL: Denne fil findes allerede. Slet den gamle fil f�rst.';
$MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'ERROR: A project with that name already exists.';
Expand Down
10 changes: 5 additions & 5 deletions lang/strings_dutch.txt
Expand Up @@ -9,11 +9,11 @@
# Dutch: Klaasjan Brand, kjb@dds.nl
# Dutch: Jeroen Latour, jlatour@calaquendi.net
# -------------------------------------------------
# $Revision: 1.40 $
# $Author: beerfrick $
# $Date: 2003-01-29 22:19:08 $
# $Revision: 1.41 $
# $Author: jfitzell $
# $Date: 2003-02-08 22:47:02 $
#
# $Id: strings_dutch.txt,v 1.40 2003-01-29 22:19:08 beerfrick Exp $
# $Id: strings_dutch.txt,v 1.41 2003-02-08 22:47:02 jfitzell Exp $
###########################################################################

?>
Expand Down Expand Up @@ -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.';
Expand Down
10 changes: 6 additions & 4 deletions lang/strings_english.txt
Expand Up @@ -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 $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -141,7 +141,6 @@
$MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = 'ERROR: No file specified';
$MANTIS_ERROR[ERROR_FILE_DISALLOWED] = 'ERROR: The file type is disallowed';
$MANTIS_ERROR[ERROR_NO_DIRECTORY] = 'ERROR: The directory does not exist. Please check the project settings.';
$MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY] = 'ERROR: This is a duplicate category.';
$MANTIS_ERROR[ERROR_DUPLICATE_VERSION] = 'ERROR: This is a duplicate version.';
$MANTIS_ERROR[ERROR_DUPLICATE_FILE] = 'ERROR: This is a duplicate file. Please delete the file first.';
$MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'ERROR: A project with that name already exists.';
Expand Down Expand Up @@ -185,6 +184,9 @@
$MANTIS_ERROR[ERROR_DB_CONNECT_FAILED] = 'ERROR: Database connection failed.';
$MANTIS_ERROR[ERROR_DB_QUERY_FAILED] = 'ERROR: Database query failed.';
$MANTIS_ERROR[ERROR_DB_SELECT_FAILED] = 'ERROR: Database selection failed.';
$MANTIS_ERROR[ERROR_CATEGORY_DUPLICATE] = 'ERROR: This is a duplicate category.';
$MANTIS_ERROR[ERROR_CATEGORY_NO_ACTION] = 'ERROR: No copy action was specified.';
$MANTIS_ERROR[ERROR_CATEGORY_NOT_FOUND] = 'ERROR: Category not found.';

$s_login_error = 'ERROR: your account may be disabled or the username/password you entered is incorrect.';
$s_login_cookies_disabled = 'ERROR: Your browser either doesn\'t know how to handle cookies, or refuses to handle them.';
Expand Down
8 changes: 4 additions & 4 deletions lang/strings_french.txt
Expand Up @@ -12,11 +12,11 @@
# French: Roland Meyer, Daniel Coquette
# French : Jean-Charles Trosset, jean-charles.trosset@laposte.net
# -------------------------------------------------
# $Revision: 1.45 $
# $Revision: 1.46 $
# $Author: jfitzell $
# $Date: 2003-02-03 23:37:58 $
# $Date: 2003-02-08 22:47:02 $
#
# $Id: strings_french.txt,v 1.45 2003-02-03 23:37:58 jfitzell Exp $
# $Id: strings_french.txt,v 1.46 2003-02-08 22:47:02 jfitzell Exp $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -144,7 +144,7 @@
$MANTIS_ERROR[ERROR_NO_FILE_SPECIFIED] = 'ERROR: No file specified';
$MANTIS_ERROR[ERROR_FILE_DISALLOWED] = 'ERROR: The file type is disallowed';
$MANTIS_ERROR[ERROR_NO_DIRECTORY] = 'ERROR: The directory does not exist. Please check the project settings.';
$MANTIS_ERROR[ERROR_DUPLICATE_CATEGORY] = 'ERROR: This is a duplicate category.';
$MANTIS_ERROR[ERROR_CATEGORY_DUPLICATE] = 'ERROR: This is a duplicate category.';
$MANTIS_ERROR[ERROR_DUPLICATE_VERSION] = 'ERROR: This is a duplicate version.';
$MANTIS_ERROR[ERROR_DUPLICATE_FILE] = 'ERROR: This is a duplicate file. Please delete the file first.';
$MANTIS_ERROR[ERROR_DUPLICATE_PROJECT] = 'ERROR: A project with that name already exists.';
Expand Down

0 comments on commit 28a1430

Please sign in to comment.