in['product']); if (!can_perform('cansubmitbugs', $product[0])) { $message->errorPermission(); } // ################################################################### 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']); $comment->set('parselinks', $bugsys->in['parselinks']); // ------------------------------------------------------------------- // 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 = explode(',', $bugsys->in['product']); $bug->set('product', $product[0]); $bug->set('component', $product[1]); $bug->set('version', $product[2]); process_custom_fields($bug, $message, true); if (!$message->hasErrors()) { $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(); $notif->set_bug_data($bug->objdata); $notif->finalize(); $message->redirect(T('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'; } } // ################################################################### if ($_REQUEST['do'] == 'add') { if (!is_array(bugdar::$datastore['product'])) { $message->error(T('No products have been setup, therefore no bugs can be added.')); } if (!is_array(bugdar::$datastore['version'])) { $message->error(T('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'); 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'); if (can_perform('canassign')) { foreach (bugdar::$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++; } $productSelect = ConstructProductSelect('cansubmitbugs', $bugsys->in['product'], false); $reporter = construct_user_display($bugsys->userinfo); eval('$template->flush("' . $template->fetch('newreport') . '");'); }