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 require_once('./global.php');
20 if (!can_perform('cansubmitbugs'))
22 $erorr->throw_permission();
25 // ###################################################################
27 if (empty($_REQUEST['do']))
29 $_REQUEST['do'] = 'add';
32 // ###################################################################
34 if ($_POST['do'] == 'insert')
36 // -------------------------------------------------------------------
37 // check permissions on various input values
38 if (!can_perform('canchangestatus'))
40 $bugsys->in
['priority'] = $bugsys->options
['defaultpriority'];
41 $bugsys->in
['status'] = $bugsys->options
['defaultstatus'];
42 $bugsys->in
['resolution'] = $bugsys->options
['defaultresolve'];
46 if (!$bugsys->datastore
['priority'][ $bugsys->in
['priority'] ])
48 $bugsys->in
['priority'] = $bugsys->options
['defaultpriority'];
50 if (!$bugsys->datastore
['status'][ $bugsys->in
['status'] ])
52 $bugsys->in
['status'] = $bugsys->options
['defaultstatus'];
54 if (!$bugsys->datastore
['resolution'][ $bugsys->in
['resolution'] ])
56 $bugsys->in
['resolution'] = $bugsys->options
['defaultresolve'];
59 if (!can_perform('canassign'))
61 $bugsys->in
['assignedto'] = $bugsys->options
['defaultassign'];
65 // assigned person is not a dev or a valid user
66 if (!$bugsys->datastore
['assignto'][ $bugsys->in
['assignedto'] ]['userid'])
68 $bugsys->in
['assignedto'] = $bugsys->options
['defaultassign'];
72 // -------------------------------------------------------------------
73 // product/component/version stuff
74 $pcv = parse_pcv_select($bugsys->in
['pcv_select'], true
);
78 // -------------------------------------------------------------------
82 $message->error('there was a problem selecting the product, component, or version');
84 if (!$bugsys->in
['summary'])
86 $message->error('please enter a bug title');
88 if (!$bugsys->in
['comment'])
90 $message->error('please enter a bug description');
93 // -------------------------------------------------------------------
94 // data clean and insert
95 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
97 if (!$bugsys->options
['allowhtml'])
99 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
102 // create the bug report
104 INSERT INTO " . TABLE_PREFIX
. "bug
105 (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution)
107 (" . $bugsys->userinfo
['userid'] . ", " . $pcv['product'] . ", " . $pcv['component'] . ", " . $pcv['version'] . ",
108 '" . $bugsys->in
['summary'] . "', " . intval($bugsys->in
['severity']) . ", " . intval($bugsys->in
['priority']) . ",
109 " . intval($bugsys->in
['status']) . ", " . intval($bugsys->in
['assignedto']) . ", " . intval($bugsys->in
['resolution']) . "
113 $bugid = $db->insert_id();
117 // insert the comment to the database
119 INSERT INTO " . TABLE_PREFIX
. "comment
120 (bugid, userid, dateline, comment, comment_parsed)
122 ($bugid, " . $bugsys->userinfo
['userid'] . ",
123 $time, '" . $bugsys->in
['comment'] . "',
124 '" . nl2br($bugsys->in
['comment_parsed']) . "'
128 $initialreport = $db->insert_id();
130 $db->query("UPDATE " . TABLE_PREFIX
. "bug SET dateline = $time, initialreport = $initialreport, lastposttime = $time, lastpostby = " . $bugsys->userinfo
['userid'] . " WHERE bugid = $bugid");
132 $message->redirect('bug is done!', "showreport.php?bugid=$bugid");
135 // ###################################################################
137 if ($_REQUEST['do'] == 'add')
139 foreach ($bugsys->datastore
['severity'] AS $severity)
141 $value = $severity['severityid'];
142 $label = $severity['severity'];
143 eval('$select[severity] .= "' . $template->fetch('selectoption') . '";');
146 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
148 if (can_perform('canchangestatus'))
150 foreach ($bugsys->datastore
['priority'] AS $priority)
152 $value = $priority['priorityid'];
153 $label = $priority['priority'];
154 eval('$select[priority] .= "' . $template->fetch('selectoption') . '";');
157 foreach ($bugsys->datastore
['status'] AS $status)
159 $value = $status['statusid'];
160 $label = $status['status'];
161 eval('$select[status] .= "' . $template->fetch('selectoption') . '";');
164 foreach ($bugsys->datastore
['resolution'] AS $resolution)
166 $value = $resolution['resolutionid'];
167 $label = $resolution['resolution'];
168 eval('$select[resolution] .= "' . $template->fetch('selectoption') . '";');
172 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
174 if (can_perform('canassign'))
176 foreach ($bugsys->datastore
['assignto'] AS $dev)
178 $value = $dev['userid'];
179 $label = construct_user_display($dev, false
);
180 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
184 $pcv_select = construct_pcv_select();
186 eval('$template->flush("' . $template->fetch('newreport') . '");');
189 /*=====================================================================*\
190 || ###################################################################
193 || ###################################################################
194 \*=====================================================================*/