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 \*=====================================================================*/
13 $fetchtemplates = array(
18 define('SVN', '$Id$');
20 $focus['newreport'] = 'focus';
22 require_once('./global.php');
23 require_once('./includes/functions_product.php');
25 if (!can_perform('cansubmitbugs'))
27 $message->error_permission();
30 // ###################################################################
32 if (empty($_REQUEST['do']))
34 $_REQUEST['do'] = 'add';
37 // ###################################################################
39 if ($_POST['do'] == 'insert')
41 // -------------------------------------------------------------------
42 // check permissions on various input values
43 if (!can_perform('canchangestatus'))
45 $bugsys->in
['priority'] = $bugsys->options
['defaultpriority'];
46 $bugsys->in
['status'] = $bugsys->options
['defaultstatus'];
47 $bugsys->in
['resolution'] = $bugsys->options
['defaultresolve'];
51 if (!$bugsys->datastore
['priority'][ $bugsys->in
['priority'] ])
53 $bugsys->in
['priority'] = $bugsys->options
['defaultpriority'];
55 if (!$bugsys->datastore
['status'][ $bugsys->in
['status'] ])
57 $bugsys->in
['status'] = $bugsys->options
['defaultstatus'];
59 if (!$bugsys->datastore
['resolution'][ $bugsys->in
['resolution'] ])
61 $bugsys->in
['resolution'] = $bugsys->options
['defaultresolve'];
64 if (!can_perform('canassign'))
66 $bugsys->in
['assignedto'] = $bugsys->options
['defaultassign'];
70 // assigned person is not a dev or a valid user
71 if (!$bugsys->datastore
['assignto'][ $bugsys->in
['assignedto'] ]['userid'])
73 $bugsys->in
['assignedto'] = $bugsys->options
['defaultassign'];
77 // -------------------------------------------------------------------
78 // product/component/version stuff
79 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
81 // -------------------------------------------------------------------
85 $message->error($lang->string('Invalid product/component/version selected.'));
87 if (!$bugsys->in
['summary'])
89 $message->error($lang->string('Please enter a title for the bug'));
91 if (!$bugsys->in
['comment'])
93 $message->error($lang->string('Please fill in the bug\'s description field'));
96 // -------------------------------------------------------------------
97 // data clean and insert
98 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
100 if (!$bugsys->options
['allowhtml'])
102 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
105 // create the bug report
107 INSERT INTO " . TABLE_PREFIX
. "bug
108 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
110 (" . $bugsys->userinfo
['userid'] . ", " . $pcv['product'] . ", " . $pcv['component'] . ", " . $pcv['version'] . ",
111 '" . $bugsys->in
['summary'] . "', " . intval($bugsys->in
['severity']) . ", " . intval($bugsys->in
['priority']) . ",
112 " . intval($bugsys->in
['status']) . ", " . intval($bugsys->in
['assignedto']) . ", " . intval($bugsys->in
['resolution']) . "
116 $bugid = $db->insert_id();
120 // insert the comment to the database
122 INSERT INTO " . TABLE_PREFIX
. "comment
123 (bugid, userid, dateline, comment, comment_parsed)
125 ($bugid, " . $bugsys->userinfo
['userid'] . ",
126 $time, '" . $bugsys->in
['comment'] . "',
127 '" . nl2br($bugsys->in
['comment_parsed']) . "'
131 $initialreport = $db->insert_id();
134 UPDATE " . TABLE_PREFIX
. "bug
135 SET dateline = $time,
136 initialreport = $initialreport,
137 lastposttime = $time,
138 lastpostby = " . $bugsys->userinfo
['userid'] . ",
139 hiddenlastposttime = $time,
140 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
141 WHERE bugid = $bugid"
144 $db->query("INSERT INTO " . TABLE_PREFIX
. "vote (bugid, votefor, voteagainst) VALUES ($bugid, 0, 0)");
146 $message->redirect($lang->string('The bug has been added to the database.'), "showreport.php?bugid=$bugid");
149 // ###################################################################
151 if ($_REQUEST['do'] == 'add')
153 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid');
155 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
157 if (can_perform('canchangestatus'))
159 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid');
160 $select['status'] = construct_datastore_select('status', 'status', 'statusid');
161 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid');
164 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
166 if (can_perform('canassign'))
168 foreach ($bugsys->datastore
['assignto'] AS $dev)
170 $value = $dev['userid'];
171 $label = construct_user_display($dev, false
);
172 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
176 $pcv_select = construct_pcv_select();
178 eval('$template->flush("' . $template->fetch('newreport') . '");');
181 /*=====================================================================*\
182 || ###################################################################
185 || ###################################################################
186 \*=====================================================================*/