/
bug_monitor.php
79 lines (68 loc) · 2.29 KB
/
bug_monitor.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
<?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
# --------------------------------------------------------
# $Revision: 1.10 $
# $Author: jfitzell $
# $Date: 2002-08-25 21:04:56 $
#
# $Id: bug_monitor.php,v 1.10 2002-08-25 21:04:56 jfitzell Exp $
# --------------------------------------------------------
?>
<?php
# This file sets the bug to the chosen resolved state then gives the
# user the opportunity to enter a reason for the closure
?>
<?php require_once( 'core.php' ) ?>
<?php login_cookie_check() ?>
<?php
project_access_check( $f_id );
check_bug_exists( $f_id );
$t_view_state = get_bug_field( $f_id, 'view_state' );
$t_threshold = $g_monitor_bug_threshold;
if ( ( PRIVATE == $t_view_state ) && ( $g_private_bug_threshold > $t_threshold ) ) {
$t_threshold = $g_private_bug_threshold;
}
check_access( $t_threshold );
$c_id = (integer)$f_id;
# get user information
$u_id = get_current_user_field( 'id' );
if ( 'add' == $f_action ) {
# Make sure we aren't already monitoring this bug
$query ="SELECT bug_id ".
"FROM $g_mantis_bug_monitor_table ".
"WHERE bug_id='$c_id' AND user_id='$u_id' ".
"LIMIT 1";
$result = db_query( $query );
$t_num_rows = db_num_rows( $result );
if ( $t_num_rows == 0 ) {
# Insert monitoring record
$query ="INSERT ".
"INTO $g_mantis_bug_monitor_table ".
"( user_id, bug_id ) ".
"VALUES ".
"( '$u_id', '$c_id' )";
$result = db_query($query);
# log new monitoring action
history_log_event_special( $f_id, BUG_MONITOR, $u_id );
}
} elseif ( 'delete' == $f_action ) {
# Delete monitoring record
$query ="DELETE ".
"FROM $g_mantis_bug_monitor_table ".
"WHERE user_id = '$u_id' AND bug_id = '$c_id'";
$result = db_query($query);
# log new un-monitor action
history_log_event_special( $f_id, BUG_UNMONITOR, $u_id );
}
# Determine which view page to redirect back to.
$t_redirect_url = get_view_redirect_url( $f_id, 1 );
if ( $result ) {
print_header_redirect( $t_redirect_url );
} else {
print_mantis_error( ERROR_GENERIC );
}
?>