<?php # Mantis - a php based bugtracking system # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org # Copyright (C) 2002 - 2004 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: bug_delete.php,v 1.40 2005/07/25 16:34:10 thraxisp Exp $ # -------------------------------------------------------- # Deletes the bug and re-directs to view_all_bug_page.php require_once 'core.php'; $t_core_path = config_get('core_path'); require_once $t_core_path . 'bug_api.php'; $f_bug_id = gpc_get_int('bug_id'); access_ensure_bug_level(config_get('delete_bug_threshold'), $f_bug_id); $t_bug = bug_get($f_bug_id, true); if ($t_bug->project_id != helper_get_current_project()) { # in case the current project is not the same project of the bug we are viewing... # ... override the current project. This to avoid problems with categories and handlers lists etc. $g_project_override = $t_bug->project_id; } helper_ensure_confirmed(lang_get('delete_bug_sure_msg'), lang_get('delete_bug_button')); $t_bug = bug_get($f_bug_id, true); helper_call_custom_function('issue_delete_validate', array($f_bug_id)); bug_delete($f_bug_id); helper_call_custom_function('issue_delete_notify', array($f_bug_id)); print_successful_redirect('view_all_bug_page.php');
if (access_can_close_bug($t_bug)) { if ($t_status < $t_closed && bug_check_workflow($t_status, $t_closed)) { # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $f_bug_id, $t_bug_data, $f_bugnote_text ) ); bug_close($t_bug_id, $f_bug_notetext, $f_bug_noteprivate); helper_call_custom_function('issue_update_notify', array($t_bug_id)); } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_status'); } } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access'); } break; case 'DELETE': if (access_has_bug_level(config_get('delete_bug_threshold'), $t_bug_id)) { event_signal('EVENT_BUG_DELETED', array($t_bug_id)); bug_delete($t_bug_id); } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access'); } break; case 'MOVE': $f_project_id = gpc_get_int('project_id'); if (access_has_bug_level(config_get('move_bug_threshold'), $t_bug_id) && access_has_project_level(config_get('report_bug_threshold', null, null, $f_project_id), $f_project_id)) { # @todo we need to issue a helper_call_custom_function( 'issue_update_validate', array( $t_bug_id, $t_bug_data, $f_bugnote_text ) ); bug_move($t_bug_id, $f_project_id); helper_call_custom_function('issue_update_notify', array($t_bug_id)); } else { $t_failed_ids[$t_bug_id] = lang_get('bug_actiongroup_access'); } break; case 'COPY':
/** * Delete all bugs associated with a project * @param array p_project_id integer representing a projectid * @return bool always true * @access public * @uses database_api.php */ function bug_delete_all($p_project_id) { $c_project_id = (int) $p_project_id; $t_bug_table = db_get_table('mantis_bug_table'); $query = "SELECT id\n\t\t\t\t FROM {$t_bug_table}\n\t\t\t\t WHERE project_id=" . db_param(); $result = db_query_bound($query, array($c_project_id)); $bug_count = db_num_rows($result); for ($i = 0; $i < $bug_count; $i++) { $row = db_fetch_array($result); bug_delete($row['id']); } # @todo should we check the return value of each bug_delete() and # return false if any of them return false? Presumable bug_delete() # will eventually trigger an error on failure so it won't matter... return true; }
/** * Delete the specified issue. * * @param string $p_username The name of the user trying to delete the issue. * @param string $p_password The password of the user. * @param integer $p_issue_id The id of the issue to delete. * @return boolean True if the issue has been deleted successfully, false otherwise. */ function mc_issue_delete($p_username, $p_password, $p_issue_id) { global $g_project_override; $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!bug_exists($p_issue_id)) { return SoapObjectsFactory::newSoapFault('Client', 'Issue \'' . $p_issue_id . '\' does not exist.'); } $t_project_id = bug_get_field($p_issue_id, 'project_id'); $g_project_override = $t_project_id; if (!mci_has_readwrite_access($t_user_id, $t_project_id)) { return mci_soap_fault_access_denied($t_user_id); } if (!access_has_bug_level(config_get('delete_bug_threshold'), $p_issue_id, $t_user_id)) { return mci_soap_fault_access_denied($t_user_id); } log_event(LOG_WEBSERVICE, 'deleting issue \'' . $p_issue_id . '\''); return bug_delete($p_issue_id); }
$delete_successful = true; break; case "delete_news_post": news_delete($_POST['confirm_project_id'], $_POST['confirm_id']); $delete_successful = true; break; case "remove_bug_category_from_project": project_remove_bug_category($_POST['confirm_project_id'], $_POST['confirm_id']); $delete_successful = true; break; case "remove_bug_component_from_project": project_remove_bug_component($_POST['confirm_project_id'], $_POST['confirm_id']); $delete_successful = true; break; case "delete_bug": bug_delete($_POST['confirm_id']); $delete_successful = true; break; case "delete_bugnote": bug_delete_bugnote($_POST['confirm_id']); $delete_successful = true; break; case "delete_bug_assoc": bug_delete_bug_assoc($_POST['confirm_id']); $delete_successful = true; break; case "delete_testplan": testset_delete_test_plan($_POST['confirm_id']); $delete_successful = true; break; case "delete_uploaded_testrun_document":
/** * Delete the specified issue. * * @param string $p_username The name of the user trying to delete the issue. * @param string $p_password The password of the user. * @param integer $p_issue_id The id of the issue to delete. * @return boolean True if the issue has been deleted successfully, false otherwise. */ function mc_issue_delete( $p_username, $p_password, $p_issue_id ) { $t_user_id = mci_check_login( $p_username, $p_password ); if( $t_user_id === false ) { return mci_soap_fault_login_failed(); } if( !bug_exists( $p_issue_id ) ) { return new soap_fault( 'Client', '', "Issue '$p_issue_id' does not exist."); } $t_project_id = bug_get_field( $p_issue_id, 'project_id' ); if( !mci_has_readwrite_access( $t_user_id, $t_project_id ) ) { return mci_soap_fault_access_denied( $t_user_id ); } return bug_delete( $p_issue_id ); }
/** * Delete all bugs associated with a project * @param integer $p_project_id Integer representing a project identifier. * @access public * @uses database_api.php * @return void */ function bug_delete_all( $p_project_id ) { $c_project_id = (int)$p_project_id; $t_query = 'SELECT id FROM {bug} WHERE project_id=' . db_param(); $t_result = db_query( $t_query, array( $c_project_id ) ); while( $t_row = db_fetch_array( $t_result ) ) { bug_delete( $t_row['id'] ); } # @todo should we check the return value of each bug_delete() and # return false if any of them return false? Presumable bug_delete() # will eventually trigger an error on failure so it won't matter... }
/** * Delete the specified issue. * * @param string $p_username The name of the user trying to delete the issue. * @param string $p_password The password of the user. * @param integer $p_issue_id The id of the issue to delete. * @return boolean True if the issue has been deleted successfully, false otherwise. */ function mc_issue_delete($p_username, $p_password, $p_issue_id) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_login_failed(); } if (!bug_exists($p_issue_id)) { return SoapObjectsFactory::newSoapFault('Client', "Issue '{$p_issue_id}' does not exist."); } $t_project_id = bug_get_field($p_issue_id, 'project_id'); if (!mci_has_readwrite_access($t_user_id, $t_project_id)) { return mci_soap_fault_access_denied($t_user_id); } if (!access_has_bug_level(config_get('delete_bug_threshold'), $p_issue_id, $t_user_id)) { return mci_soap_fault_access_denied($t_user_id); } return bug_delete($p_issue_id); }
function bug_delete_all($p_project_id) { $c_project_id = db_prepare_int($p_project_id); $t_bug_table = config_get('mantis_bug_table'); $query = "SELECT id\r\n\t\t\t\t FROM {$t_bug_table}\r\n\t\t\t\t WHERE project_id='{$c_project_id}'"; $result = db_query($query); $bug_count = db_num_rows($result); for ($i = 0; $i < $bug_count; $i++) { $row = db_fetch_array($result); bug_delete($row['id']); } # @@@ should we check the return value of each bug_delete() and # return false if any of them return false? Presumable bug_delete() # will eventually trigger an error on failure so it won't matter... return true; }