/
bugnote_add.php
70 lines (62 loc) · 1.95 KB
/
bugnote_add.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
<?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
# Insert the bugnote into the database then redirect to the bug page
?>
<?php include( 'core_API.php' ) ?>
<?php login_cookie_check() ?>
<?php
db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name );
project_access_check( $f_id );
check_access( REPORTER );
check_bug_exists( $f_id );
$c_id = (integer)$f_id;
# get user information
$u_id = get_current_user_field( 'id' );
$f_bugnote_text = trim( $f_bugnote_text );
# check for blank bugnote
if ( !empty( $f_bugnote_text ) ) {
$c_bugnote_text = string_prepare_textarea( $f_bugnote_text );
# insert bugnote text
$query = "INSERT
INTO $g_mantis_bugnote_text_table
( id, note )
VALUES
( null, '$c_bugnote_text' )";
$result = db_query( $query );
# retrieve bugnote text id number
$t_bugnote_text_id = db_insert_id();
# insert bugnote info
$query = "INSERT
INTO $g_mantis_bugnote_table
( id, bug_id, reporter_id, bugnote_text_id, date_submitted, last_modified )
VALUES
( null, '$c_id', '$u_id','$t_bugnote_text_id', NOW(), NOW() )";
$result = db_query( $query );
# update bug last updated
$result = bug_date_update( $f_id );
# log new bug
history_log_event_special( $f_id, BUGNOTE_ADDED );
# notify reporter and handler
if ( get_bug_field( $f_id, 'status' ) == FEEDBACK ) {
if ( get_bug_field( $f_id, 'resolution' ) == REOPENED ) {
email_reopen( $f_id );
} else {
email_feedback( $f_id );
}
} else {
email_bugnote_add( $f_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 );
}
?>