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