require_api('form_api.php'); require_api('gpc_api.php'); require_api('helper_api.php'); require_api('html_api.php'); require_api('lang_api.php'); require_api('print_api.php'); require_api('string_api.php'); form_security_validate('manage_proj_cat_delete'); auth_reauthenticate(); $f_category_id = gpc_get_int('id'); $f_project_id = gpc_get_int('project_id'); $t_row = category_get_row($f_category_id); $t_name = category_full_name($f_category_id); $t_project_id = $t_row['project_id']; access_ensure_project_level(config_get('manage_project_threshold'), $t_project_id); # Protect the 'default category for moves' from deletion 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); # Confirm with the user helper_ensure_confirmed(sprintf(lang_get('category_delete_confirm_msg'), string_display_line($t_name)), lang_get('delete_category_button')); category_remove($f_category_id); form_security_purge('manage_proj_cat_delete'); if ($f_project_id == ALL_PROJECTS) { $t_redirect_url = 'manage_proj_page.php'; } else { $t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id; } html_page_top(null, $t_redirect_url); html_operation_successful($t_redirect_url); html_page_bottom();
/** * Remove a category from the project * @param integer $p_category_id Category identifier. * @param integer $p_new_category_id New category id (to replace existing category). * @return void * @access public */ 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); } db_param_push(); $t_query = 'DELETE FROM {category} WHERE id=' . db_param(); db_query($t_query, array($p_category_id)); # update bug history entries db_param_push(); $t_query = 'SELECT id FROM {bug} WHERE category_id=' . db_param(); $t_result = db_query($t_query, array($p_category_id)); while ($t_bug_row = db_fetch_array($t_result)) { history_log_event_direct($t_bug_row['id'], 'category', $t_category_row['name'], category_full_name($p_new_category_id, false)); } # update bug data db_param_push(); $t_query = 'UPDATE {bug} SET category_id=' . db_param() . ' WHERE category_id=' . db_param(); db_query($t_query, array($p_new_category_id, $p_category_id)); }