summaryrefslogtreecommitdiffstats
path: root/post_bug.cgi
blob: 94878d3bb4a8973f405e48f7de751f1d9e1ae2a7 (plain)
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
#! /usr/bonsaitools/bin/mysqltcl
# -*- Mode: tcl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
# 
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
# 
# The Original Code is the Bugzilla Bug Tracking System.
# 
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
# 
# Contributor(s): Terry Weissman <terry@mozilla.org>


source "CGI.tcl"
confirm_login

puts "Set-Cookie: PLATFORM=$FORM(product) ; path=/ ; expires=Sun, 30-Jun-99 00:00:00 GMT"
puts "Set-Cookie: VERSION-$FORM(product)=$FORM(version) ; path=/ ; expires=Sun, 30-Jun-99 00:00:00 GMT"
puts "Content-type: text/html\n"

if {[info exists FORM(maketemplate)]} {
    puts "<TITLE>Bookmarks are your friend.</TITLE>"
    puts "<H1>Template constructed.</H1>"
    
    set url "enter_bug.cgi?$buffer"

    puts "If you put a bookmark <a href=\"$url\">to this link</a>, it will"
    puts "bring up the submit-a-new-bug page with the fields initialized"
    puts "as you've requested."
    exit
}

PutHeader "Posting Bug -- Please wait" "Posting Bug" "One moment please..."

flush stdout
umask 0
ConnectToDatabase

if {![info exists FORM(component)] || [cequal $FORM(component) ""]} {
    puts "You must choose a component that corresponds to this bug.  If"
    puts "necessary, just guess.  But please hit the <B>Back</B> button and"
    puts "choose a component."
    exit 0
}
    

set forceAssignedOK 0
if {[cequal "" $FORM(assigned_to)]} {
    SendSQL "select initialowner from components
where program='[SqlQuote $FORM(product)]'
and value='[SqlQuote $FORM(component)]'"
    set FORM(assigned_to) [lindex [FetchSQLData] 0]
    set forceAssignedOK 1
}

set FORM(assigned_to) [DBNameToIdAndCheck $FORM(assigned_to) $forceAssignedOK]
set FORM(reporter) [DBNameToIdAndCheck $FORM(reporter)]


set bug_fields { reporter product version rep_platform bug_severity \
                     priority op_sys assigned_to bug_status bug_file_loc \
                     short_desc component }
set query "insert into bugs (\n"

foreach field $bug_fields {
  append query "$field,\n"
}

append query "creation_ts, long_desc )\nvalues (\n"


foreach field $bug_fields {
    if {$field == "qa_assigned_to"} {

        set valin [DBname_to_id $FORM($field)]
        if {$valin == "__UNKNOWN__"} {
            append query "null,\n"
        } else {
            append query "$valin,\n"
        }

    } else {
        regsub -all "'" [FormData $field] "''" value
        append query "'$value',\n"
    }
}

append query "now(), "
append query "'[SqlQuote [FormData comment]]' )\n"


set ccids(zz) 1
unset ccids(zz)


if {[info exists FORM(cc)]} {
    foreach person [split $FORM(cc) " ,"] {
        if {![cequal $person ""]} {
            set ccids([DBNameToIdAndCheck $person]) 1
        }
    }
}


# puts "<PRE>$query</PRE>"

SendSQL $query
while {[MoreSQLData]} { set ret [FetchSQLData] }

SendSQL "select LAST_INSERT_ID()"
set id [FetchSQLData]

foreach person [array names ccids] {
    SendSQL "insert into cc (bug_id, who) values ($id, $person)"
    while { [ MoreSQLData ] } { FetchSQLData }
}

# Now make sure changes are written before we run processmail...
Disconnect

puts "<H2>Changes Submitted</H2>"
puts "<A HREF=\"show_bug.cgi?id=$id\">Show BUG# $id</A>"
puts "<BR><A HREF=\"query.cgi\">Back To Query Page</A>"

flush stdout

exec ./processmail $id < /dev/null > /dev/null 2> /dev/null &
exit