/
bug_actiongroup.php
162 lines (128 loc) · 4.14 KB
/
bug_actiongroup.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 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
?>
<?php
# This page allows the close / suppress / others mass treatments, and display the adequate page
?>
<?php require_once( 'core.php' ) ?>
<?php login_cookie_check() ?>
<?php
$f_action = gpc_get_string( 'f_action' );
$f_bug_arr = gpc_get_string_array( 'f_bug_arr', array() );
# the queries
function updateBugLite($p_id, $p_status, $p_request) {
$t_handler_id = auth_get_current_user_id();
$t_query='';
$result = 1;
bug_ensure_exists( $p_id );
# history treatment
# extract current extended information into history variables
$row = bug_get_extended_row( $p_id );
extract( $row, EXTR_PREFIX_ALL, 'h' );
switch ($p_status) {
case 'MOVED' :
check_access( config_get( 'bug_move_access_level' ) );
$t_query = "project_id='$p_request'";
break;
case CLOSED :
check_access( config_get( 'close_bug_threshold' ) );
$t_query="status='$p_status'";
break ;
case ASSIGNED :
check_access( config_get( 'update_bug_threshold' ) );
// @@@ Check that $p_request has access to handle a bug.
$t_handler_id = $p_request ;
$t_query="handler_id='$t_handler_id', status='$p_status'";
break ;
case RESOLVED :
check_access( config_get( 'handle_bug_threshold' ) );
$t_query=" status='$p_status', resolution='$p_request'";
break ;
case 'UP_PRIOR' :
check_access( config_get( 'update_bug_threshold' ) );
$t_query="priority='$p_request'";
break ;
case 'UP_STATUS' :
check_access( config_get( 'update_bug_threshold' ) );
$t_query="handler_id='$t_handler_id', status='$p_request'";
break ;
}
# Update fields
$query = "UPDATE ".config_get( 'mantis_bug_table' )."
SET $t_query
WHERE id='$p_id'";
$result = db_query($query);
if ( !$result ) {
print_mantis_error( ERROR_GENERIC );
}
# history logging should be done after the field updates
switch ($p_status) {
case 'MOVED' :
history_log_event_direct( $p_id, 'project_id', $h_project_id, $p_request, $t_handler_id );
break;
case CLOSED :
history_log_event_direct( $p_id, 'status', $h_status, $p_status, $t_handler_id );
break ;
case ASSIGNED :
history_log_event_direct( $p_id, 'handler_id', $h_handler_id, $p_request, $t_handler_id );
history_log_event_direct( $p_id, 'status', $h_status, $p_status, $t_handler_id );
break ;
case RESOLVED :
history_log_event_direct( $p_id, 'resolution', $h_resolution, $p_request, $t_handler_id );
history_log_event_direct( $p_id, 'status', $h_status, $p_status, $t_handler_id );
break ;
case 'UP_PRIOR' :
history_log_event_direct( $p_id, 'priority', $h_priority, $p_request, $t_handler_id );
break ;
case 'UP_STATUS' :
history_log_event_direct( $p_id, 'status', $h_status, $p_request, $t_handler_id );
break ;
}
# update bug last updated
bug_update_date($p_id);
# notify reporter and handler
switch ( $p_status ) {
case ASSIGNED: email_assign( $p_id );
break;
case RESOLVED: email_resolved( $p_id );
break;
case CLOSED: email_close( $p_id );
break;
}
}//updateBug
foreach($f_bug_arr as $value) {
switch ( $f_action ) {
case 'CLOSE':
updateBugLite( $value, CLOSED, '' );
break;
case 'DELETE':
bug_delete( $value );
break;
case 'MOVE':
$f_project_id = gpc_get_int( 'f_project_id' );
updateBugLite( $value, 'MOVED', $f_project_id );
break;
case 'ASSIGN':
$f_assign = gpc_get_int( 'f_assign' );
updateBugLite( $value, ASSIGNED, $f_assign );
break;
case 'RESOLVE':
$f_resolution = gpc_get_int( 'f_resolution' );
updateBugLite( $value, RESOLVED, $f_resolution );
break;
case 'UP_PRIOR':
$f_priority = gpc_get_int( 'f_priority' );
updateBugLite( $value, 'UP_PRIOR', $f_priority );
break;
case 'UP_STATUS':
$f_status = gpc_get_int( 'f_status' );
updateBugLite( $value, 'UP_STATUS', $f_status );
break;
}
}
print_meta_redirect( 'view_all_bug_page.php',0);
?>