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
');
24 if (!can_perform('cansubmitbugs
'))
26 $message->error_permission();
29 // ###################################################################
31 if (empty($_REQUEST['do']))
33 $_REQUEST['do'] = 'add
';
36 // ###################################################################
38 if ($_POST['do'] == 'insert
')
40 // -------------------------------------------------------------------
41 // check permissions on various input values
42 if (!can_perform('canchangestatus
'))
44 $bugsys->in['priority
'] = $bugsys->options['defaultpriority
'];
45 $bugsys->in['status
'] = $bugsys->options['defaultstatus
'];
46 $bugsys->in['resolution
'] = $bugsys->options['defaultresolve
'];
50 if (!$bugsys->datastore['priority
'][ $bugsys->in['priority
'] ])
52 $bugsys->in['priority
'] = $bugsys->options['defaultpriority
'];
54 if (!$bugsys->datastore['status
'][ $bugsys->in['status
'] ])
56 $bugsys->in['status
'] = $bugsys->options['defaultstatus
'];
58 if (!$bugsys->datastore['resolution
'][ $bugsys->in['resolution
'] ])
60 $bugsys->in['resolution
'] = $bugsys->options['defaultresolve
'];
63 if (!can_perform('canassign
'))
65 $bugsys->in['assignedto
'] = $bugsys->options['defaultassign
'];
69 // assigned person is not a dev or a valid user
70 if (!$bugsys->datastore['assignto
'][ $bugsys->in['assignedto
'] ]['userid
'])
72 $bugsys->in['assignedto
'] = $bugsys->options['defaultassign
'];
76 // -------------------------------------------------------------------
77 // product/component/version stuff
78 $pcv = parse_pcv_select($bugsys->in['pcv_select
'], true);
80 // -------------------------------------------------------------------
84 $message->error($lang->string('Invalid product
/component
/version selected
.'));
86 if (!$bugsys->in['summary
'])
88 $message->error($lang->string('Please enter a title
for the bug
'));
90 if (!$bugsys->in['comment
'])
92 $message->error($lang->string('Please fill in the bug\'s description field
'));
95 // -------------------------------------------------------------------
96 // data clean and insert
97 $bugsys->in['comment_parsed
'] = $bugsys->in['comment
'];
99 if (!$bugsys->options['allowhtml
'])
101 $bugsys->in['comment_parsed
'] = $bugsys->sanitize($bugsys->in['comment_parsed
']);
104 // create the bug report
106 INSERT INTO " . TABLE_PREFIX . "bug
107 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
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
']) . "
115 $bugid = $db->insert_id();
119 // insert the comment to the database
121 INSERT INTO " . TABLE_PREFIX . "comment
122 (bugid, userid, dateline, comment, comment_parsed)
124 ($bugid, " . $bugsys->userinfo['userid
'] . ",
125 $time, '" . $bugsys->in['comment'] . "',
126 '" . nl2br($bugsys->in['comment_parsed']) . "'
130 $initialreport = $db->insert_id();
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"
143 $db->query("INSERT INTO " . TABLE_PREFIX . "vote (bugid, votefor, voteagainst) VALUES ($bugid, 0, 0)");
145 $message->redirect($lang->string('The bug has been added to the database
.'), "showreport.php?bugid=$bugid");
148 // ###################################################################
150 if ($_REQUEST['do'] == 'add
')
152 $select['severity
'] = construct_datastore_select('severity
', 'severity
', 'severityid
');
154 $show['changestatus
'] = ((can_perform('canchangestatus
')) ? true : false);
156 if (can_perform('canchangestatus
'))
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
');
163 $show['assign
'] = ((can_perform('canassign
')) ? true : false);
165 if (can_perform('canassign
'))
167 foreach ($bugsys->datastore['assignto
'] AS $dev)
169 $value = $dev['userid
'];
170 $label = construct_user_display($dev, false);
171 eval('$select[dev
] .= "' . $template->fetch('selectoption') . '";');
175 $pcv_select = construct_pcv_select();
177 eval('$template->flush("' . $template->fetch('newreport') . '");');
180 /*=====================================================================*\
181 || ###################################################################
184 || ###################################################################
185 \*=====================================================================*/