From 303fee5d9a82ce060ac0f5fae1088a2b657f69c7 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 18 Aug 2008 12:13:07 -0400 Subject: [PATCH] Working on newreport.php * includes/api_bug.php * includes/api_comment.php * includes/functions.php: (construct_datastore_select) (ConstructVersionSelect) (ConstructOptGroup) * newreport.php * templates/bugfield_input_checkbox.tpl * templates/bugfield_input_text.tpl * templates/newreport.tpl --- includes/api_bug.php | 4 +-- includes/api_comment.php | 4 +-- includes/functions.php | 48 ++++++++++++++++----------- includes/functions_product.php | 20 +++++++---- newreport.php | 14 ++++---- templates/bugfield_input_checkbox.tpl | 2 +- templates/bugfield_input_text.tpl | 2 +- templates/newreport.tpl | 26 +++++++-------- 8 files changed, 68 insertions(+), 52 deletions(-) diff --git a/includes/api_bug.php b/includes/api_bug.php index 213d1c1..5d51140 100644 --- a/includes/api_bug.php +++ b/includes/api_bug.php @@ -19,7 +19,7 @@ || ################################################################### \*=====================================================================*/ -$GLOBALS['isso:callback']->load('api', null); +require_once ISSO . '/Api.php'; /** * API: Bug @@ -33,7 +33,7 @@ $GLOBALS['isso:callback']->load('api', null); * @package Bugdar * */ -class BugAPI extends API +class BugAPI extends BSApi { /** * Database fields diff --git a/includes/api_comment.php b/includes/api_comment.php index 719ed8a..cd9e0a5 100644 --- a/includes/api_comment.php +++ b/includes/api_comment.php @@ -19,7 +19,7 @@ || ################################################################### \*=====================================================================*/ -$GLOBALS['isso:callback']->load('api', null); +require_once ISSO . '/Api.php'; /** * API: Comment @@ -30,7 +30,7 @@ $GLOBALS['isso:callback']->load('api', null); * @package Bugdar * */ -class CommentAPI extends API +class CommentAPI extends BSApi { /** * Fields diff --git a/includes/functions.php b/includes/functions.php index ac960bc..cbc8df8 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -150,22 +150,21 @@ function can_perform($bitmask, $productid = 0, $userinfo = null) return ($userinfo['permissions'] & $bugsys->permissions["$bitmask"]); } -// ################################################################### /** -* Runs through a given datastore item and creates a series of + * options. + * + * @access public + * + * @param string Datastore name + * @param string Array index for the label + * @param string Array index for the value + * @param mixed The selected value(s) + * @param bool Include a blank option? TRUE will set a null value, FALSE turns it off, anything else is used as the value for the blank option + * @param bool Generate it using admin printers? + * + * @return string Unelss in admin mode, returns the constructed options + */ function construct_datastore_select($datastore, $labelname, $valuename, $selectedvalue = 0, $includeblank = false, $adminmode = false) { global $bugsys; @@ -186,10 +185,13 @@ function construct_datastore_select($datastore, $labelname, $valuename, $selecte } else { - $label = ''; - $value = $newval; - $selected = ((!$selectedvalue OR (is_array($selectedvalue) AND in_array($newval, $selectedvalue))) ? true : false); - eval('$select .= "' . $bugsys->template->fetch('selectoption') . '";'); + $tpl = new BSTemplate('selectoption'); + $tpl->vars = array( + 'label' => '', + 'value' => $newval, + 'selected' => (!$selectedvalue || (is_array($selectedvalue) && in_array($newval, $selectedvalue))) + ); + $select .= $tpl->evaluate()->getTemplate(); } } @@ -205,7 +207,13 @@ function construct_datastore_select($datastore, $labelname, $valuename, $selecte } else { - eval('$select .= "' . $bugsys->template->fetch('selectoption') . '";'); + $tpl = new BSTemplate('selectoption'); + $tpl->vars = array( + 'label' => $label, + 'value' => $value, + 'selected' => $selected + ); + $select .= $tpl->evaluate()->getTemplate(); } } diff --git a/includes/functions_product.php b/includes/functions_product.php index 21b54f9..ddbc7ab 100644 --- a/includes/functions_product.php +++ b/includes/functions_product.php @@ -106,10 +106,13 @@ function ConstructVersionSelect($productid, $select, $obsolete) { if ((!$version['productid'] OR $version['productid'] == $component['productid'] OR $version['productid'] == $product['productid']) AND (!$version['obsolete'] OR ($version['obsolete'] AND $obsolete))) { - $value = intval($product['productid']) . ',' . intval($component['productid']) . ',' . intval($versionid); - $label = $version['version']; - $selected = ($value == $select); - eval('$build .= "' . $bugsys->template->fetch('selectoption') . '";'); + $tpl = new BSTemplate('selectoption'); + $tpl->vars = array( + 'value' => intval($product['productid']) . ',' . intval($component['productid']) . ',' . intval($versionid), + 'label' => $version['version'], + 'selected' => ($value == $select) + ); + $build .= $tpl->evaluate()->getTemplate(); } } @@ -128,9 +131,12 @@ function ConstructVersionSelect($productid, $select, $obsolete) */ function ConstructOptionGroup($glabel, $optbits) { - global $bugsys; - eval('$HTML = "' . $bugsys->template->fetch('selectoptgroup') . '";'); - return $HTML; + $tpl = new BSTemplate('selectoptgroup'); + $tpl->vars = array( + 'glabel' => $glabel, + 'optbits' => $optbits + ); + return $tpl->evaluate()->getTemplate(); } /*=====================================================================*\ diff --git a/newreport.php b/newreport.php index 541c1a7..0b02ecc 100755 --- a/newreport.php +++ b/newreport.php @@ -34,7 +34,6 @@ require_once('./includes/api_bug.php'); require_once('./includes/api_comment.php'); require_once('./includes/class_api_error.php'); -APIError(array(new API_Error_Handler($message), 'user_cumulative')); $product = explode(',', $bugsys->in['product']); if (!can_perform('cansubmitbugs', $product[0])) @@ -188,11 +187,14 @@ if ($_REQUEST['do'] == 'add') $i++; } - $productSelect = ConstructProductSelect('cansubmitbugs', $bugsys->in['product'], false); - - $reporter = construct_user_display(bugdar::$userinfo); - - eval('$template->flush("' . $template->fetch('newreport') . '");'); + $tpl = new BSTemplate('newreport'); + $tpl->vars = array( + 'reporter' => construct_user_display(bugdar::$userinfo), + 'productSelect' => ConstructProductSelect('cansubmitbugs', $bugsys->in['product'], false), + 'select' => $select, + 'customfields' => $customfields + ); + $tpl->evaluate()->flush(); } /*=====================================================================*\ diff --git a/templates/bugfield_input_checkbox.tpl b/templates/bugfield_input_checkbox.tpl index 8b12cbf..27008fd 100644 --- a/templates/bugfield_input_checkbox.tpl +++ b/templates/bugfield_input_checkbox.tpl @@ -1,6 +1,6 @@
- <%- $field[name] %> <%- $help['field' . $field['fieldid']] %> + <%- $field['name'] %> help[field<%- $field['fieldid'] %>]
<% if ($searchMode): %><% else: %> /><% endif %>
\ No newline at end of file diff --git a/templates/bugfield_input_text.tpl b/templates/bugfield_input_text.tpl index 7a1895f..b1e420b 100644 --- a/templates/bugfield_input_text.tpl +++ b/templates/bugfield_input_text.tpl @@ -1,6 +1,6 @@
- <%- $field['name'] %> <%- $help['field' . $field['fieldid']] %> + <%- $field['name'] %> help[field<%- $field['fieldid'] %>]
maxlength="<%- $field['maxlength'] %>"<% endif %> />
diff --git a/templates/newreport.tpl b/templates/newreport.tpl index 058a7ed..1c004aa 100644 --- a/templates/newreport.tpl +++ b/templates/newreport.tpl @@ -9,7 +9,7 @@ -$header +<%- $header %> <% if ($show['errors']): %>
@@ -27,22 +27,22 @@ $header
- <%-T("Reporter")%> <%- $help['reporter'] %> + <%-T("Reporter")%> $help[reporter]
<%- $reporter %>
- {@"Product/Version"} <%- $help['product'] %> -
+ <%-T("Product/Version")%> $help[product] +
<% if ($show['changestatus']): %>
- <%-T("Status")%> <%- $help['status'] %> + <%-T("Status")%> $help[status]
@@ -50,7 +50,7 @@ $header
- <%-T("Severity")%> <%- $help['severity'] %> + <%-T("Severity")%> $help[severity]
@@ -65,7 +65,7 @@ $header
- <%-T("Summary")%> <%- $help['summary'] %> + <%-T("Summary")%> $help[summary]
@@ -73,7 +73,7 @@ $header <% if ($show['assign']): %>
- <%-T("Assignment")%> <%- $help['assignedto'] %> + <%-T("Assignment")%> $help[assignedto]
@@ -82,7 +82,7 @@ $header <% if ($show['changestatus']): %>
- <%-T("Resolution")%> <%- $help['resolution'] %> + <%-T("Resolution")%> $help[resolution]
@@ -91,7 +91,7 @@ $header <% if ($show['changestatus']): %>
- <%-T("Priority")%> <%- $help['priority'] %> + <%-T("Priority")%> $help[priority]
@@ -108,11 +108,11 @@ $header
- {@"Description/Initial Report"} + <%-T("Description/Initial Report")%> - + -
checked="checked"<% endif %> /> <%-T("Parse Links in the Comment")%>
+
in['parselinks']): %> checked="checked"<% endif %> /> <%-T("Parse Links in the Comment")%>
-- 2.22.5