/////////////////////////////////////////////////////////////////////// protected void Page_Load(Object sender, EventArgs e) { Util.do_not_cache(Response); if (User.IsInRole(BtnetRoles.Admin) || User.Identity.GetCanDeleteBugs()) { // } else { Response.Write("You are not allowed to use this page."); Response.End(); } string id = Util.sanitize_integer(Request["id"]); int permission_level = Bug.get_bug_permission_level(Convert.ToInt32(id), User.Identity); if (permission_level != PermissionLevel.All) { Response.Write("You are not allowed to edit this item"); Response.End(); } if (IsPostBack) { Bug.delete_bug(Convert.ToInt32(row_id.Value)); Server.Transfer("bugs.aspx"); } else { Page.Header.Title = Util.get_setting("AppTitle", "BugTracker.NET") + " - " + "delete " + Util.get_setting("SingularBugLabel", "bug"); back_href.HRef = "edit_bug.aspx?id=" + id; sql = new SQLString(@"select bg_short_desc from bugs where bg_id = @bugId"); sql = sql.AddParameterWithValue("bugId", id); DataRow dr = DbUtil.get_datarow(sql); confirm_href.InnerText = "confirm delete of " + Util.get_setting("SingularBugLabel", "bug") + ": " + Convert.ToString(dr["bg_short_desc"]); row_id.Value = id; } }
/////////////////////////////////////////////////////////////////////// void on_update() { // does it say "Merge" or "Confirm Merge"? if (submit.Value == "Merge") { if (!validate()) { prev_from_bug.Value = ""; prev_into_bug.Value = ""; return; } } if (prev_from_bug.Value == from_bug.Value && prev_into_bug.Value == into_bug.Value) { prev_from_bug.Value = btnet.Util.sanitize_integer(prev_from_bug.Value); prev_into_bug.Value = btnet.Util.sanitize_integer(prev_into_bug.Value); // rename the attachments string upload_folder = Util.get_upload_folder(); if (upload_folder != null) { sql = new SQLString(@"select bp_id, bp_file from bug_posts where bp_type = 'file' and bp_bug = @from" ); sql = sql.AddParameterWithValue("from", prev_from_bug.Value); DataSet ds = btnet.DbUtil.get_dataset(sql); foreach (DataRow dr in ds.Tables[0].Rows) { // create path StringBuilder path = new StringBuilder(upload_folder); path.Append("\\"); path.Append(prev_from_bug.Value); path.Append("_"); path.Append(Convert.ToString(dr["bp_id"])); path.Append("_"); path.Append(Convert.ToString(dr["bp_file"])); if (System.IO.File.Exists(path.ToString())) { StringBuilder path2 = new StringBuilder(upload_folder); path2.Append("\\"); path2.Append(prev_into_bug.Value); path2.Append("_"); path2.Append(Convert.ToString(dr["bp_id"])); path2.Append("_"); path2.Append(Convert.ToString(dr["bp_file"])); System.IO.File.Move(path.ToString(), path2.ToString()); } } } // copy the from db entries to the to sql = new SQLString(@" insert into bug_subscriptions (bs_bug, bs_user) select @into, bs_user from bug_subscriptions where bs_bug = @from and bs_user not in (select bs_user from bug_subscriptions where bs_bug = @into) insert into bug_user (bu_bug, bu_user, bu_flag, bu_flag_datetime, bu_seen, bu_seen_datetime, bu_vote, bu_vote_datetime) select @into, bu_user, bu_flag, bu_flag_datetime, bu_seen, bu_seen_datetime, bu_vote, bu_vote_datetime from bug_user where bu_bug = @from and bu_user not in (select bu_user from bug_user where bu_bug = @into) update bug_posts set bp_bug = @into where bp_bug = @from update bug_tasks set tsk_bug = @into where tsk_bug = @from update svn_revisions set svnrev_bug = @into where svnrev_bug = @from update hg_revisions set hgrev_bug = @into where hgrev_bug = @from update git_commits set gitcom_bug = @into where gitcom_bug = @from "); sql = sql.AddParameterWithValue("from", prev_from_bug.Value); sql = sql.AddParameterWithValue("into", prev_into_bug.Value); btnet.DbUtil.execute_nonquery(sql); // record the merge itself sql = new SQLString(@"insert into bug_posts (bp_bug, bp_user, bp_date, bp_type, bp_comment, bp_comment_search) values(@into, @us,getdate(), 'comment', 'merged bug @from into this bug:', 'merged bug @from into this bug:') select scope_identity()" ); sql = sql.AddParameterWithValue("@from", prev_from_bug.Value); sql = sql.AddParameterWithValue("@into", prev_into_bug.Value); sql = sql.AddParameterWithValue("@us", Convert.ToString(User.Identity.GetUserId())); int comment_id = Convert.ToInt32(btnet.DbUtil.execute_scalar(sql)); // update bug comments with info from old bug sql = new SQLString(@"update bug_posts set bp_comment = convert(nvarchar,bp_comment) + char(10) + bg_short_desc from bugs where bg_id = @from and bp_id = @bc" ); sql = sql.AddParameterWithValue("from", prev_from_bug.Value); sql = sql.AddParameterWithValue("bc", Convert.ToString(comment_id)); btnet.DbUtil.execute_nonquery(sql); // delete the from bug int from_bugid = Convert.ToInt32(prev_from_bug.Value); Bug.delete_bug(from_bugid); btnet.Bug.send_notifications(btnet.Bug.UPDATE, Convert.ToInt32(prev_into_bug.Value), User.Identity); Response.Redirect("edit_bug.aspx?id=" + prev_into_bug.Value); } else { prev_from_bug.Value = from_bug.Value; prev_into_bug.Value = into_bug.Value; static_from_bug.InnerText = from_bug.Value; static_into_bug.InnerText = into_bug.Value; static_from_desc.InnerText = (string)dr[0]; static_into_desc.InnerText = (string)dr[1]; from_bug.Style["display"] = "none"; into_bug.Style["display"] = "none"; static_from_bug.Style["display"] = ""; static_into_bug.Style["display"] = ""; static_from_desc.Style["display"] = ""; static_into_desc.Style["display"] = ""; submit.Value = "Confirm Merge"; } }