Skip to content

Commit

Permalink
Category deletion now uses the new API functions
Browse files Browse the repository at this point in the history
Issue #20761
  • Loading branch information
dregad committed Mar 27, 2016
1 parent c5edb0c commit a9f7cb9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 7 additions & 1 deletion core/category_api.php
Expand Up @@ -198,6 +198,7 @@ function category_remove( $p_category_id, $p_new_category_id = 0 ) {
$t_category_row = category_get_row( $p_category_id );

category_ensure_exists( $p_category_id );
category_ensure_can_remove( $p_category_id );
if( 0 != $p_new_category_id ) {
category_ensure_exists( $p_new_category_id );
}
Expand All @@ -219,7 +220,8 @@ function category_remove( $p_category_id, $p_new_category_id = 0 ) {
}

/**
* Remove all categories associated with a project
* Remove all categories associated with a project.
* This will skip processing of categories that can't be deleted.
* @param integer $p_project_id A Project identifier.
* @param integer $p_new_category_id New category id (to replace existing category).
* @return boolean
Expand All @@ -240,6 +242,10 @@ function category_remove_all( $p_project_id, $p_new_category_id = 0 ) {

$t_category_ids = array();
while( $t_row = db_fetch_array( $t_result ) ) {
# Don't add category to the list if it can't be deleted
if( !category_can_remove( $t_row['id'] ) ) {
continue;
}
$t_category_ids[] = $t_row['id'];
}

Expand Down
7 changes: 1 addition & 6 deletions manage_proj_cat_delete.php
Expand Up @@ -66,12 +66,7 @@
access_ensure_project_level( config_get( 'manage_project_threshold' ), $t_project_id );

# Protect the 'default category for moves' from deletion
$t_default_category_id = config_get( 'default_category_for_moves', /* default */ null, ALL_USERS, ALL_PROJECTS );
if( $f_category_id == $t_default_category_id
|| config_is_defined( 'default_category_for_moves', $f_category_id )
) {
trigger_error( ERROR_CATEGORY_CANNOT_DELETE_DEFAULT, ERROR );
}
category_ensure_can_remove( $f_category_id );

# Protect the category from deletion which is associted with an issue.
category_ensure_can_delete( $f_category_id );
Expand Down

0 comments on commit a9f7cb9

Please sign in to comment.