r303: Added SVN constant to user files; now ISSO debug information shows SVN details.
[bugdar.git] / newreport.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'newreport',
15 'pcv_select_row'
16 );
17
18 define('SVN', '$Id$');
19
20 require_once('./global.php');
21
22 if (!can_perform('cansubmitbugs'))
23 {
24 $message->error_permission();
25 }
26
27 // ###################################################################
28
29 if (empty($_REQUEST['do']))
30 {
31 $_REQUEST['do'] = 'add';
32 }
33
34 // ###################################################################
35
36 if ($_POST['do'] == 'insert')
37 {
38 // -------------------------------------------------------------------
39 // check permissions on various input values
40 if (!can_perform('canchangestatus'))
41 {
42 $bugsys->in['priority'] = $bugsys->options['defaultpriority'];
43 $bugsys->in['status'] = $bugsys->options['defaultstatus'];
44 $bugsys->in['resolution'] = $bugsys->options['defaultresolve'];
45 }
46 else
47 {
48 if (!$bugsys->datastore['priority'][ $bugsys->in['priority'] ])
49 {
50 $bugsys->in['priority'] = $bugsys->options['defaultpriority'];
51 }
52 if (!$bugsys->datastore['status'][ $bugsys->in['status'] ])
53 {
54 $bugsys->in['status'] = $bugsys->options['defaultstatus'];
55 }
56 if (!$bugsys->datastore['resolution'][ $bugsys->in['resolution'] ])
57 {
58 $bugsys->in['resolution'] = $bugsys->options['defaultresolve'];
59 }
60 }
61 if (!can_perform('canassign'))
62 {
63 $bugsys->in['assignedto'] = $bugsys->options['defaultassign'];
64 }
65 else
66 {
67 // assigned person is not a dev or a valid user
68 if (!$bugsys->datastore['assignto'][ $bugsys->in['assignedto'] ]['userid'])
69 {
70 $bugsys->in['assignedto'] = $bugsys->options['defaultassign'];
71 }
72 }
73
74 // -------------------------------------------------------------------
75 // product/component/version stuff
76 $pcv = parse_pcv_select($bugsys->in['pcv_select'], true);
77
78 print_r($vars);
79
80 // -------------------------------------------------------------------
81 // sanity checks
82 if (!$pcv)
83 {
84 $message->error('there was a problem selecting the product, component, or version');
85 }
86 if (!$bugsys->in['summary'])
87 {
88 $message->error('please enter a bug title');
89 }
90 if (!$bugsys->in['comment'])
91 {
92 $message->error('please enter a bug description');
93 }
94
95 // -------------------------------------------------------------------
96 // data clean and insert
97 $bugsys->in['comment_parsed'] = $bugsys->in['comment'];
98
99 if (!$bugsys->options['allowhtml'])
100 {
101 $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']);
102 }
103
104 // create the bug report
105 $db->query("
106 INSERT INTO " . TABLE_PREFIX . "bug
107 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
108 VALUES
109 (" . $bugsys->userinfo['userid'] . ", " . $pcv['product'] . ", " . $pcv['component'] . ", " . $pcv['version'] . ",
110 '" . $bugsys->in['summary'] . "', " . intval($bugsys->in['severity']) . ", " . intval($bugsys->in['priority']) . ",
111 " . intval($bugsys->in['status']) . ", " . intval($bugsys->in['assignedto']) . ", " . intval($bugsys->in['resolution']) . "
112 )"
113 );
114
115 $bugid = $db->insert_id();
116
117 $time = TIMENOW;
118
119 // insert the comment to the database
120 $db->query("
121 INSERT INTO " . TABLE_PREFIX . "comment
122 (bugid, userid, dateline, comment, comment_parsed)
123 VALUES
124 ($bugid, " . $bugsys->userinfo['userid'] . ",
125 $time, '" . $bugsys->in['comment'] . "',
126 '" . nl2br($bugsys->in['comment_parsed']) . "'
127 )"
128 );
129
130 $initialreport = $db->insert_id();
131
132 $db->query("
133 UPDATE " . TABLE_PREFIX . "bug
134 SET dateline = $time,
135 initialreport = $initialreport,
136 lastposttime = $time,
137 lastpostby = " . $bugsys->userinfo['userid'] . ",
138 hiddenlastposttime = $time,
139 hiddenlastpostby = " . $bugsys->userinfo['userid'] . "
140 WHERE bugid = $bugid"
141 );
142
143 $message->redirect('bug is done!', "showreport.php?bugid=$bugid");
144 }
145
146 // ###################################################################
147
148 if ($_REQUEST['do'] == 'add')
149 {
150 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid');
151
152 $show['changestatus'] = ((can_perform('canchangestatus')) ? true : false);
153
154 if (can_perform('canchangestatus'))
155 {
156 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid');
157 $select['status'] = construct_datastore_select('status', 'status', 'statusid');
158 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid');
159 }
160
161 $show['assign'] = ((can_perform('canassign')) ? true : false);
162
163 if (can_perform('canassign'))
164 {
165 foreach ($bugsys->datastore['assignto'] AS $dev)
166 {
167 $value = $dev['userid'];
168 $label = construct_user_display($dev, false);
169 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
170 }
171 }
172
173 $pcv_select = construct_pcv_select();
174
175 eval('$template->flush("' . $template->fetch('newreport') . '");');
176 }
177
178 /*=====================================================================*\
179 || ###################################################################
180 || # $HeadURL$
181 || # $Id$
182 || ###################################################################
183 \*=====================================================================*/
184 ?>