input_clean('product', TYPE_UINT); if (!can_perform('cansubmitbugs', $bugsys->in['product'])) { $message->error_permission(); } // ################################################################### if (empty($_REQUEST['do'])) { $_REQUEST['do'] = 'add'; } // ################################################################### if ($_POST['do'] == 'insert') { $bug = new BugAPI($bugsys); $comment = new CommentAPI($bugsys); $notif = new NotificationCenter; $bug->set('userid', $bugsys->userinfo['userid']); $bug->set('username', $bugsys->userinfo['displayname']); $bug->set('summary', $bugsys->in['summary']); $bug->set('severity', $bugsys->in['severity']); $comment->set('userid', $bugsys->userinfo['userid']); $comment->set('comment', $bugsys->in['comment']); // ------------------------------------------------------------------- // check permissions on various input values if (!can_perform('canchangestatus', $bugsys->in['product'])) { $bug->set('priority', $bugsys->options['defaultpriority']); $bug->set('status', $bugsys->options['defaultstatus']); $bug->set('resolution', $bugsys->options['defaultresolve']); } else { $bug->set('priority', $bugsys->in['priority']); $bug->set('status', $bugsys->in['status']); $bug->set('resolution', $bugsys->in['resolution']); } if (!can_perform('canassign', $bugsys->in['product'])) { $bug->set('assignedto', $bugsys->options['defaultassign']); } else { // assigned person is not a dev or a valid user $bug->set('assignedto', $bugsys->in['assignedto']); } // ------------------------------------------------------------------- // product/component/version stuff $pcv = parse_pcv_select($bugsys->in['pcv_select'], true); if (!$pcv) { $message->add_error(_('Invalid product/component/version selected.')); } $bug->set('product', $pcv['product']); $bug->set('component', $pcv['component']); $bug->set('version', $pcv['version']); $cfields = process_custom_fields(null, $message, true); if (!$message->items) { $bug->insert(); $comment->set('bugid', $bug->insertid); $comment->insert(); $notif->send_new_bug_notice($bug->values, $comment->values); $bug = new BugAPI($bugsys); // need to destroy because update will think the insert fields need to be changed, too $bug->dorelations = array(); $bug->set('bugid', $comment->values['bugid']); $bug->set_condition(); $bug->fetch(); $bug->set('dateline', $comment->values['dateline']); $bug->set('initialreport', $comment->insertid); $bug->set('lastposttime', $comment->values['dateline']); $bug->set('lastpostby', $bugsys->userinfo['userid']); $bug->set('lastpostbyname', $bugsys->userinfo['displayname']); $bug->set('hiddenlastposttime', $comment->values['dateline']); $bug->set('hiddenlastpostby', $bugsys->userinfo['userid']); $bug->set('hiddenlastpostbyname', $bugsys->userinfo['displayname']); $bug->update(); if ($cfields) { $db->query(sprintf($cfields, $comment->values['bugid'])); } $notif->set_bug_data($bug->objdata); $notif->finalize(); $message->redirect(_('The bug has been added to the database.'), ($bugsys->in['submit_reload'] == '' ? "showreport.php?bugid=" . $bug->values['bugid'] : 'newreport.php')); } else { $show['errors'] = true; $_REQUEST['do'] = 'add'; $message->error_list_process(); } } // ################################################################### if ($_REQUEST['do'] == 'add') { if (!is_array($bugsys->datastore['product'])) { $message->error(_('No products have been setup, therefore no bugs can be added.')); } if (!is_array($bugsys->datastore['version'])) { $message->error(_('No versions have been setup underneath your product(s), therefore no bugs can be added.')); } $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', ($bugsys->in['severity'] ? $bugsys->in['severity'] : $bugsys->options['defaultseverity'])); $show['changestatus'] = ((can_perform('canchangestatus')) ? true : false); if (can_perform('canchangestatus')) { $select['priority'] = construct_datastore_select('priority', 'priority', 'priorityid', ($bugsys->in['priority'] ? $bugsys->in['priority'] : $bugsys->options['defaultpriority'])); $select['status'] = construct_datastore_select('status', 'status', 'statusid', ($bugsys->in['status'] ? $bugsys->in['status'] : $bugsys->options['defaultstatus'])); $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', ($bugsys->in['resolution'] ? $bugsys->in['resolution'] : $bugsys->options['defaultresolve'])); } $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); $selected = ($bugsys->in['assignedto'] ? ($bugsys->in['assignedto'] == $dev['userid']) : ($dev['userid'] == $bugsys->options['defaultassign'])); eval('$select[dev] .= "' . $template->fetch('selectoption') . '";'); } } // custom fields $fields = construct_custom_fields($bugsys->in, true); $i = 0; foreach ($fields AS $field) { if ($i % 2 == 0) { $customfields['left'] .= $field; } else { $customfields['right'] .= $field; } $i++; } $pcv_select = construct_pcv_select('cansubmitbugs', $bugsys->in['pcv_select']); $reporter = construct_user_display($bugsys->userinfo); eval('$template->flush("' . $template->fetch('newreport') . '");'); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>