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 $message->error_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();
131 UPDATE " . TABLE_PREFIX
. "bug
132 SET dateline = $time,
133 initialreport = $initialreport,
134 lastposttime = $time,
135 lastpostby = " . $bugsys->userinfo
['userid'] . ",
136 hiddenlastposttime = $time,
137 hiddenlastpostby = " . $bugsys->userinfo
['userid'] . "
138 WHERE bugid = $bugid"
141 $message->redirect('bug is done!', "showreport.php?bugid=$bugid");
144 // ###################################################################
146 if ($_REQUEST['do'] == 'add')
148 $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid');
150 $show['changestatus'] = ((can_perform('canchangestatus')) ? true
: false
);
152 if (can_perform('canchangestatus'))
154 $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid');
155 $select['status'] = construct_datastore_select('status', 'status', 'statusid');
156 $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid');
159 $show['assign'] = ((can_perform('canassign')) ? true
: false
);
161 if (can_perform('canassign'))
163 foreach ($bugsys->datastore
['assignto'] AS $dev)
165 $value = $dev['userid'];
166 $label = construct_user_display($dev, false
);
167 eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
171 $pcv_select = construct_pcv_select();
173 eval('$template->flush("' . $template->fetch('newreport') . '");');
176 /*=====================================================================*\
177 || ###################################################################
180 || ###################################################################
181 \*=====================================================================*/