Exemplo n.º 1
0
/**
 * Remove one or more bug revisions from the bug history.
 * @param int $p_revision_id Revision ID, or array of revision IDs
 * @return null
 */
function bug_revision_drop( $p_revision_id ) {
	$t_bug_rev_table = db_get_table( 'bug_revision' );

	if ( is_array( $p_revision_id ) ) {
		$t_revisions = array();
		$t_first = true;
		$t_query = "DELETE FROM $t_bug_rev_table WHERE id IN ( ";

		# TODO: Fetch bug revisions in one query (and cache them)
		foreach( $p_revision_id as $t_rev_id ) {
			$t_query .= ( $t_first ? db_param() : ', ' . db_param() );
			$t_revisions[$t_rev_id] = bug_revision_get( $t_rev_id );
		}

		$t_query .= ' )';
		db_query_bound( $t_query, $p_revision_id );
		foreach( $p_revision_id as $t_rev_id ) {
			if ( $t_revisions[$t_rev_id]['type'] == REV_BUGNOTE ) {
				history_log_event_special( $t_revisions[$t_rev_id]['bug_id'], BUGNOTE_REVISION_DROPPED, bugnote_format_id( $t_rev_id ), $t_revisions[$t_rev_id]['bugnote_id'] );
			} else {
				history_log_event_special( $t_revisions[$t_rev_id]['bug_id'], BUG_REVISION_DROPPED, bugnote_format_id( $t_rev_id ), $t_revisions[$t_rev_id]['type'] );
			}
		}
	} else {
		$t_revision = bug_revision_get( $p_revision_id );
		$t_query = "DELETE FROM $t_bug_rev_table WHERE id=" . db_param();
		db_query_bound( $t_query, array( $p_revision_id ) );
		if ( $t_revision['type'] == REV_BUGNOTE ) {
			history_log_event_special( $t_revision['bug_id'], BUGNOTE_REVISION_DROPPED, bugnote_format_id( $p_revision_id ), $t_revision['bugnote_id'] );
		} else {
			history_log_event_special( $t_revision['bug_id'], BUG_REVISION_DROPPED, bugnote_format_id( $p_revision_id ), $t_revision['type'] );
		}
	}
}
Exemplo n.º 2
0
 *
 * @uses core.php
 * @uses access_api.php
 * @uses bug_revision_api.php
 * @uses config_api.php
 * @uses form_api.php
 * @uses gpc_api.php
 * @uses helper_api.php
 * @uses lang_api.php
 * @uses print_api.php
 */
/**
 * MantisBT Core API's
 */
require_once 'core.php';
require_api('access_api.php');
require_api('bug_revision_api.php');
require_api('config_api.php');
require_api('form_api.php');
require_api('gpc_api.php');
require_api('helper_api.php');
require_api('lang_api.php');
require_api('print_api.php');
form_security_validate('bug_revision_drop');
$f_revision_id = gpc_get_int('id');
$t_revision = bug_revision_get($f_revision_id);
access_ensure_bug_level(config_get('bug_revision_drop_threshold'), $t_revision['bug_id']);
helper_ensure_confirmed(lang_get('confirm_revision_drop'), lang_get('revision_drop'));
bug_revision_drop($f_revision_id);
form_security_purge('bug_revision_drop');
print_successful_redirect_to_bug($t_revision['bug_id']);