in['productid']))) { $message->error_permission(); } // ################################################################### if (empty($_REQUEST['do'])) { $_REQUEST['do'] = 'add'; } // ################################################################### if ($_POST['do'] == 'insert') { // ------------------------------------------------------------------- // check permissions on various input values if (!can_perform('canchangestatus', intval($bugsys->in['productid']))) { $bugsys->in['priority'] = $bugsys->options['defaultpriority']; $bugsys->in['status'] = $bugsys->options['defaultstatus']; $bugsys->in['resolution'] = $bugsys->options['defaultresolve']; } else { if (!$bugsys->datastore['priority'][ $bugsys->in['priority'] ]) { $bugsys->in['priority'] = $bugsys->options['defaultpriority']; } if (!$bugsys->datastore['status'][ $bugsys->in['status'] ]) { $bugsys->in['status'] = $bugsys->options['defaultstatus']; } if (!$bugsys->datastore['resolution'][ $bugsys->in['resolution'] ]) { $bugsys->in['resolution'] = $bugsys->options['defaultresolve']; } } if (!can_perform('canassign', intval($bugsys->in['productid']))) { $bugsys->in['assignedto'] = $bugsys->options['defaultassign']; } else { // assigned person is not a dev or a valid user if (!$bugsys->datastore['assignto'][ $bugsys->in['assignedto'] ]['userid']) { $bugsys->in['assignedto'] = $bugsys->options['defaultassign']; } } // ------------------------------------------------------------------- // product/component/version stuff $pcv = parse_pcv_select($bugsys->in['pcv_select'], true); // ------------------------------------------------------------------- // sanity checks if (!$pcv) { $message->error($lang->string('Invalid product/component/version selected.')); } if (!$bugsys->in['summary']) { $message->error($lang->string('Please enter a title for the bug')); } if (!$bugsys->in['comment']) { $message->error($lang->string('Please fill in the bug\'s description field')); } // ------------------------------------------------------------------- // data clean and insert $bugsys->in['comment_parsed'] = $bugsys->in['comment']; if (!$bugsys->options['allowhtml']) { $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']); } // create the bug report $db->query(" INSERT INTO " . TABLE_PREFIX . "bug (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto, resolution) VALUES (" . $bugsys->userinfo['userid'] . ", " . $pcv['product'] . ", " . $pcv['component'] . ", " . $pcv['version'] . ", '" . $bugsys->in['summary'] . "', " . intval($bugsys->in['severity']) . ", " . intval($bugsys->in['priority']) . ", " . intval($bugsys->in['status']) . ", " . intval($bugsys->in['assignedto']) . ", " . intval($bugsys->in['resolution']) . " )" ); $bugid = $db->insert_id(); $time = TIMENOW; // insert the comment to the database $db->query(" INSERT INTO " . TABLE_PREFIX . "comment (bugid, userid, dateline, comment, comment_parsed) VALUES ($bugid, " . $bugsys->userinfo['userid'] . ", $time, '" . $bugsys->in['comment'] . "', '" . nl2br($bugsys->in['comment_parsed']) . "' )" ); $initialreport = $db->insert_id(); $db->query(" UPDATE " . TABLE_PREFIX . "bug SET dateline = $time, initialreport = $initialreport, lastposttime = $time, lastpostby = " . $bugsys->userinfo['userid'] . ", hiddenlastposttime = $time, hiddenlastpostby = " . $bugsys->userinfo['userid'] . " WHERE bugid = $bugid" ); $db->query("INSERT INTO " . TABLE_PREFIX . "vote (bugid, votefor, voteagainst) VALUES ($bugid, 0, 0)"); $message->redirect($lang->string('The bug has been added to the database.'), "showreport.php?bugid=$bugid"); } // ################################################################### if ($_REQUEST['do'] == 'add') { $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid'); $show['changestatus'] = ((can_perform('canchangestatus')) ? true : false); if (can_perform('canchangestatus')) { $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid'); $select['status'] = construct_datastore_select('status', 'status', 'statusid'); $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid'); } $show['assign'] = ((can_perform('canassign')) ? true : false); if (can_perform('canassign')) { foreach ($bugsys->datastore['assignto'] AS $dev) { $value = $dev['userid']; $label = construct_user_display($dev, false); eval('$select[dev] .= "' . $template->fetch('selectoption') . '";'); } } $pcv_select = construct_pcv_select('cansubmitbugs'); eval('$template->flush("' . $template->fetch('newreport') . '");'); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>