/
manage_proj_delete.php
89 lines (77 loc) · 2.48 KB
/
manage_proj_delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
?>
<?php include( "core_API.php" ) ?>
<?php login_cookie_check() ?>
<?php
db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
check_access( MANAGER );
$f_project_id = (integer)$f_project_id;
# Delete the bugs, bug text, bugnotes, and bugnote text
# first select the bug ids
$query = "SELECT id, bug_text_id
FROM $g_mantis_bug_table
WHERE project_id='$f_project_id'";
$result = db_query( $query );
$bug_count = db_num_rows( $result );
for ($i=0;$i<$bug_count;$i++) {
$row = db_fetch_array( $result );
$t_bug_id = $row["id"];
$t_bug_text_id = $row["bug_text_id"];
# Delete the bug texts
$query2 = "DELETE
FROM $g_mantis_bug_text_table
WHERE id='$t_bug_text_id'";
$result2 = db_query( $query2 );
# select bugnotes to delete
$query3 = "SELECT id, bugnote_text_id
FROM $g_mantis_bugnote_table
WHERE bug_id='$t_bug_id'";
$result3 = db_query( $query3 );
$bugnote_count = db_num_rows( $result3 );
for ($j=0;$j<$bugnote_count;$j++) {
$row2 = db_fetch_array( $result3 );
$t_bugnote_id = $row2["id"];
$t_bugnote_text_id = $row2["bugnote_text_id"];
# Delete the bugnotes
$query = "DELETE
FROM $g_mantis_bugnote_table
WHERE id='$t_bugnote_id'";
$result = db_query( $query );
# Delete the bugnote texts
$query4 = "DELETE
FROM $g_mantis_bugnote_text_table
WHERE id='$t_bugnote_text_id'";
$result4 = db_query( $query4 );
}
}
# now finally remove all bugs that are part of the project
$query = "DELETE
FROM $g_mantis_bug_table
WHERE project_id='$f_project_id'";
$result = db_query( $query );
# Delete the project entry
$query = "DELETE
FROM $g_mantis_project_table
WHERE id='$f_project_id'";
$result = db_query( $query );
# Delete the project categories
$query = "DELETE
FROM $g_mantis_project_category_table
WHERE project_id='$f_project_id'";
$result = db_query( $query );
# Delete the project versions
$query = "DELETE
FROM $g_mantis_project_version_table
WHERE project_id='$f_project_id'";
$result = db_query( $query );
$t_redirect_url = $g_manage_project_menu_page;
if ( $result ) {
print_header_redirect( $t_redirect_url );
} else {
print_mantis_error( ERROR_GENERIC );
}
?>