From 69a98ed3fd7c74ca399c0bd1cc35296bae28d4d4 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 15 Jan 2006 09:01:58 +0000 Subject: [PATCH] r729: Error box for newreport.php --- newreport.php | 125 +++++++++++++++++++++------------------- templates/newreport.tpl | 11 +++- 2 files changed, 76 insertions(+), 60 deletions(-) diff --git a/newreport.php b/newreport.php index 7d15c66..df5f2ee 100755 --- a/newreport.php +++ b/newreport.php @@ -81,83 +81,92 @@ if ($_POST['do'] == 'insert') // sanity checks if (!$pcv) { - $message->error($lang->string('Invalid product/component/version selected.')); + $message->items[] = $lang->string('Invalid product/component/version selected.'); } if (!$bugsys->in['summary']) { - $message->error($lang->string('Please enter a title for the bug')); + $message->items[] = $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')); + $message->items[] = $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']) + if (!$message->items) { - $bugsys->in['comment_parsed'] = $bugsys->sanitize($bugsys->in['comment_parsed']); + // ------------------------------------------------------------------- + // 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.'), ($bugsys->in['submit_reload'] == '' ? "showreport.php?bugid=$bugid" : 'newreport.php')); + } + else + { + $show['errors'] = true; + $_REQUEST['do'] = 'add'; + $message->error_list_process(); } - - // 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.'), ($bugsys->in['submit_reload'] == '' ? "showreport.php?bugid=$bugid" : 'newreport.php')); } // ################################################################### if ($_REQUEST['do'] == 'add') { - $select['severity'] = construct_datastore_select('severity', 'severity', 'severityid', $bugsys->options['defaultseverity']); + $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->options['defaultpriority']); - $select['status'] = construct_datastore_select('status', 'status', 'statusid', $bugsys->options['defaultstatus']); - $select['resolution'] = construct_datastore_select('resolution', 'resolution', 'resolutionid', $bugsys->options['defaultresolve']); + $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); @@ -168,12 +177,12 @@ if ($_REQUEST['do'] == 'add') { $value = $dev['userid']; $label = construct_user_display($dev, false); - $selected = ($dev['userid'] == $bugsys->options['defaultassign']); + $selected = ($bugsys->in['assignedto'] ? ($bugsys->in['assignedto'] == $dev['userid']) : ($dev['userid'] == $bugsys->options['defaultassign'])); eval('$select[dev] .= "' . $template->fetch('selectoption') . '";'); } } - $pcv_select = construct_pcv_select('cansubmitbugs'); + $pcv_select = construct_pcv_select('cansubmitbugs', $bugsys->in['pcv_select']); $reporter = construct_user_display($bugsys->userinfo); diff --git a/templates/newreport.tpl b/templates/newreport.tpl index 538ef6e..ee53a43 100644 --- a/templates/newreport.tpl +++ b/templates/newreport.tpl @@ -11,6 +11,13 @@ $headinclude $header + +
+ {@"The following errors occurred"}: + {$message->process} +
+
+
@@ -57,7 +64,7 @@ $header
{@"Summary"} $help[summary] -
+
@@ -99,7 +106,7 @@ $header
{@"Description/Initial Report"} - +
-- 2.43.5