summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-02-17 03:05:05 +0100
committermkanat%kerio.com <>2005-02-17 03:05:05 +0100
commitfc3aa3e7aa78106e8148b3ecbd92e65e5ad63985 (patch)
tree8d2496e53e9ac2ab4db8b013ec9b9bd75b252a5a
parente8e8e8394944fb0d2e0f285b4f4104c27db1771a (diff)
downloadbugzilla-fc3aa3e7aa78106e8148b3ecbd92e65e5ad63985.tar.gz
bugzilla-fc3aa3e7aa78106e8148b3ecbd92e65e5ad63985.tar.xz
Bug 280412: Templatize the 'list products' bit of editproducts
Patch By Gavin Shelly <bugzilla@chimpychompy.org> r=wurblzap, a=myk
-rwxr-xr-xeditproducts.cgi100
-rw-r--r--template/en/default/admin/products/footer.html.tmpl86
-rw-r--r--template/en/default/admin/products/list.html.tmpl119
-rw-r--r--template/en/default/admin/table.html.tmpl15
-rw-r--r--template/en/default/filterexceptions.pl9
5 files changed, 283 insertions, 46 deletions
diff --git a/editproducts.cgi b/editproducts.cgi
index 3faa88563..0fa2ddbae 100755
--- a/editproducts.cgi
+++ b/editproducts.cgi
@@ -22,6 +22,7 @@
# Terry Weissman <terry@mozilla.org>
# Dawn Endico <endico@mozilla.org>
# Joe Robins <jmrobins@tgix.com>
+# Gavin Shelley <bugzilla@chimpychompy.org>
#
# Direct any questions on this source code to
#
@@ -117,6 +118,28 @@ sub CheckClassification ($)
}
}
+# For the transition period, as this file is templatised bit by bit,
+# we need this routine, which does things properly, and will
+# eventually be the only version. (The older versions assume a
+# PutHeader() call has been made)
+sub CheckClassificationNew ($)
+{
+ my $cl = shift;
+
+ # do we have a classification?
+ unless ($cl) {
+ ThrowUserError('classification_not_specified');
+ exit;
+ }
+
+ unless (TestClassification $cl) {
+ ThrowUserError('classification_doesnt_exist',
+ {'name' => $cl});
+ exit;
+ }
+}
+
+
sub CheckClassificationProduct ($$)
{
my $cl = shift;
@@ -308,59 +331,50 @@ if (Param('useclassification')) {
#
unless ($action) {
+
if (Param('useclassification')) {
- PutHeader("Select product in " . $classification);
- } else {
- PutHeader("Select product");
+ CheckClassificationNew($classification);
}
- my $query="SELECT products.name,products.description,disallownew,
- votesperuser,maxvotesperbug,votestoconfirm,COUNT(bug_id)
- FROM products";
+ my $dbh = Bugzilla->dbh;
+ my @execute_params = ();
+ my @products = ();
+
+ my $query = "SELECT products.name,
+ COALESCE(products.description,'') AS description,
+ NOT(disallownew) AS status,
+ votesperuser, maxvotesperbug, votestoconfirm,
+ COUNT(bug_id) AS bug_count
+ FROM products";
+
if (Param('useclassification')) {
- $query .= ",classifications";
+ $query .= ", classifications";
}
+
$query .= " LEFT JOIN bugs ON products.id = bugs.product_id";
+
if (Param('useclassification')) {
- $query .= " WHERE classifications.name=" .
- SqlQuote($classification) .
- " AND classifications.id=products.classification_id";
+ $query .= " WHERE classifications.name = ? " .
+ " AND classifications.id = products.classification_id";
+
+ # trick_taint is OK because we use this in a placeholder in a SELECT
+ trick_taint($classification);
+
+ push(@execute_params,
+ $classification);
}
+
$query .= " GROUP BY products.name ORDER BY products.name";
- SendSQL($query);
- print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0><TR BGCOLOR=\"#6666FF\">\n";
- print " <TH ALIGN=\"left\">Edit product ...</TH>\n";
- print " <TH ALIGN=\"left\">Description</TH>\n";
- print " <TH ALIGN=\"left\">Status</TH>\n";
- print " <TH ALIGN=\"left\">Votes<br>per<br>user</TH>\n";
- print " <TH ALIGN=\"left\">Max<br>Votes<br>per<br>bug</TH>\n";
- print " <TH ALIGN=\"left\">Votes<br>to<br>confirm</TH>\n";
- print " <TH ALIGN=\"left\">Bugs</TH>\n";
- print " <TH ALIGN=\"left\">Action</TH>\n";
- print "</TR>";
- while ( MoreSQLData() ) {
- my ($product, $description, $disallownew, $votesperuser,
- $maxvotesperbug, $votestoconfirm, $bugs) = FetchSQLData();
- $description ||= "<FONT COLOR=\"red\">missing</FONT>";
- $disallownew = $disallownew ? 'closed' : 'open';
- $bugs ||= 'none';
- print "<TR>\n";
- print " <TD VALIGN=\"top\"><A HREF=\"editproducts.cgi?action=edit&product=", url_quote($product), $classhtmlvar,"\"><B>$product</B></A></TD>\n";
- print " <TD VALIGN=\"top\">$description</TD>\n";
- print " <TD VALIGN=\"top\">$disallownew</TD>\n";
- print " <TD VALIGN=\"top\" ALIGN=\"right\">$votesperuser</TD>\n";
- print " <TD VALIGN=\"top\" ALIGN=\"right\">$maxvotesperbug</TD>\n";
- print " <TD VALIGN=\"top\" ALIGN=\"right\">$votestoconfirm</TD>\n";
- print " <TD VALIGN=\"top\" ALIGN=\"right\">$bugs</TD>\n";
- print " <TD VALIGN=\"top\"><A HREF=\"editproducts.cgi?action=del&product=", url_quote($product), $classhtmlvar, "\">Delete</A></TD>\n";
- print "</TR>";
- }
- print "<TR>\n";
- print " <TD VALIGN=\"top\" COLSPAN=7>Add a new product</TD>\n";
- print " <TD VALIGN=\"top\" ALIGN=\"center\"><A HREF=\"editproducts.cgi?action=add&classification=", url_quote($classification),"\">Add</A></TD>\n";
- print "</TR></TABLE>\n";
- PutTrailer();
+ $vars->{'products'} = $dbh->selectall_arrayref($query,
+ {'Slice' => {}},
+ @execute_params);
+
+ $vars->{'classification'} = $classification;
+ $template->process("admin/products/list.html.tmpl",
+ $vars)
+ || ThrowTemplateError($template->error());
+
exit;
}
diff --git a/template/en/default/admin/products/footer.html.tmpl b/template/en/default/admin/products/footer.html.tmpl
new file mode 100644
index 000000000..0276437f3
--- /dev/null
+++ b/template/en/default/admin/products/footer.html.tmpl
@@ -0,0 +1,86 @@
+[%# 1.0@bugzilla.org %]
+[%# The contents of this file are subject to the Mozilla Public
+ # License Version 1.1 (the "License"); you may not use this file
+ # except in compliance with the License. You may obtain a copy of
+ # the License at http://www.mozilla.org/MPL/
+ #
+ # Software distributed under the License is distributed on an "AS
+ # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ # implied. See the License for the specific language governing
+ # rights and limitations under the License.
+ #
+ # The Original Code is the Bugzilla Bug Tracking System.
+ #
+ # Contributor(s): Gavin Shelley <bugzilla@chimpychompy.org>
+ #%]
+
+[%# INTERFACE:
+ # name: string; the name of the product
+ #
+ # classification: string; If classifications are enabled, then this is
+ # the currently selected classification
+ #
+ # no_XXX_link: boolean; if defined, then don't show the corresponding
+ # link. Supported parameters are:
+ #
+ # no_edit_product_link
+ # no_edit_other_products_link
+ # no_add_product_link
+ #%]
+
+[% IF classification %]
+ [% classification_url_part = BLOCK %]&amp;classification=
+ [%- classification FILTER url_quote %]
+ [% END %]
+ [% classification_text = BLOCK %]
+ of classification '[% classification FILTER html %]'
+ [% END %]
+[% END %]
+
+<p>
+
+<hr>
+
+[% UNLESS no_add_product_link %]
+ <a title="Add a product"
+ href="editproducts.cgi?action=add">Add</a> a product
+
+
+ [%# Strictly speaking, we should not have to check for a
+ classification if they are enabled, but I'm just being paranoid %]
+ [% IF Param('useclassification') && classification %]
+ (<a title="Add a product to classification '
+ [%- classification FILTER html %]'"
+ href="editproducts.cgi?action=add
+ [%- classification_url_part %]">to
+ classification '[% classification FILTER html %]'</a>)
+ [% END %].
+[% END %]
+
+[% IF name && !no_edit_product_link %]
+ Edit product <a
+ title="Edit Product '[% name FILTER html %]'
+ [% classification_text %]"
+ href="editproducts.cgi?action=edit&amp;product=
+ [%- name FILTER url_quote %][% classification_url_part %]">
+ '[% name FILTER html %]'</a>FRED
+[% END %]
+
+
+[% UNLESS no_edit_other_products_link %]
+ Edit other products [% classification_text %]<a
+ href="editproducts.cgi?product=
+ [%- name FILTER url_quote %]
+ [%- classification_url_part %]">'
+ [%- classification FILTER html %]'</a>
+
+[% END %]
+
+[% IF Param('useclassification') && classification %]
+ Edit classification <a href="editclassifications.cgi?action=edit
+ [%- classification_url_part %]">'
+ [%- classification FILTER html %]'</a>.
+
+[% END %]
+
+</p>
diff --git a/template/en/default/admin/products/list.html.tmpl b/template/en/default/admin/products/list.html.tmpl
new file mode 100644
index 000000000..98676e198
--- /dev/null
+++ b/template/en/default/admin/products/list.html.tmpl
@@ -0,0 +1,119 @@
+[%# 1.0@bugzilla.org %]
+[%# The contents of this file are subject to the Mozilla Public
+ # License Version 1.1 (the "License"); you may not use this file
+ # except in compliance with the License. You may obtain a copy of
+ # the License at http://www.mozilla.org/MPL/
+ #
+ # Software distributed under the License is distributed on an "AS
+ # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ # implied. See the License for the specific language governing
+ # rights and limitations under the License.
+ #
+ # The Original Code is the Bugzilla Bug Tracking System.
+ #
+ # Contributor(s): Gavin Shelley <bugzilla@chimpychompy.org>
+ #%]
+
+[%# INTERFACE:
+ # products: array of hashes having the following properties:
+ # - name: string; The name of the product
+ # - description: string; The product description (html allowed)
+ # - status: boolean; Can new bugs be created for the product?
+ # - votesperuser: number; The number of votes a user is allowed
+ # in the product
+ # - maxvotersperbug: number; Maximum votes allowed per bug in this
+ # product
+ # - votestoconfirm: number; The number of votes that are needed to
+ # auto-confirm a bug in this product
+ # - bug_count: number; The number of bugs in this product
+ #
+ # classification: string; If classifications are enabled, then this is
+ # the currently selected classification
+ #%]
+
+[% PROCESS global/variables.none.tmpl %]
+
+[% IF classification %]
+ [% classification_url_part = BLOCK %]&amp;classification=
+ [%- classification FILTER url_quote %]
+ [%- END %]
+ [% classification_title = BLOCK %]
+ in classification '[% classification FILTER html %]'
+ [% END %]
+[% END %]
+
+[% PROCESS global/header.html.tmpl
+ title = "Select product $classification_title"
+%]
+
+[% edit_contentlink = BLOCK %]
+ editproducts.cgi?action=edit&amp;product=%%name%%
+ [%- classification_url_part %]
+[% END %]
+[% delete_contentlink = BLOCK %]
+ editproducts.cgi?action=del&amp;product=%%name%%
+ [%- classification_url_part %]
+[% END %]
+[% bug_count_contentlink = BLOCK %]buglist.cgi?product=%%name%%&amp;
+ [%- classification_url_part %][% END %]
+
+
+[% columns = [
+ {
+ name => "name"
+ heading => "Edit product..."
+ contentlink => edit_contentlink
+ },
+ {
+ name => "description"
+ heading => "Description"
+ allow_html_content => 1
+ },
+ {
+ name => "status"
+ heading => "Open For New $terms.Bugs"
+ yesno_field => 1
+ },
+ {
+ name => "votesperuser"
+ heading => "Votes Per User"
+ align => 'right'
+ },
+ {
+ name => "maxvotesperbug"
+ heading => "Maximum Votes Per $terms.Bug"
+ align => 'right'
+ },
+ {
+ name => "votestoconfirm"
+ heading => "Votes To Confirm"
+ align => 'right'
+ },
+ {
+ name => "bug_count"
+ heading => "$terms.Bug Count"
+ align => 'right'
+ contentlink => bug_count_contentlink
+ },
+ ]
+%]
+
+[% columns.push({
+ heading => "Action"
+ content => "Delete"
+ contentlink => delete_contentlink
+ })
+%]
+
+[% PROCESS admin/table.html.tmpl
+ columns = columns
+ data = products
+%]
+
+<p>
+
+[% PROCESS admin/products/footer.html.tmpl
+ no_edit_other_products_link = 1
+ %]
+
+[% PROCESS global/footer.html.tmpl %]
diff --git a/template/en/default/admin/table.html.tmpl b/template/en/default/admin/table.html.tmpl
index ac4e5a666..fd1382b14 100644
--- a/template/en/default/admin/table.html.tmpl
+++ b/template/en/default/admin/table.html.tmpl
@@ -37,6 +37,7 @@
# text in the column.
# allow_html_content: if defined, then this column allows html content
# so it will not be filtered
+ # yesno_field: Turn the data from 0/!0 into Yes/No
#
# data:
# array of hashes representing the data for the table.
@@ -79,10 +80,18 @@
[% IF c.content %]
[% c.content %]
[% ELSE %]
- [% IF c.allow_html_content %]
- [% row.${c.name} FILTER none %]
+ [% IF c.yesno_field %]
+ [% IF row.${c.name} %]
+ Yes
+ [% ELSE %]
+ No
+ [% END %]
[% ELSE %]
- [% row.${c.name} FILTER html %]
+ [% IF c.allow_html_content %]
+ [% row.${c.name} FILTER none %]
+ [% ELSE %]
+ [% row.${c.name} FILTER html %]
+ [% END %]
[% END %]
[% END %]
diff --git a/template/en/default/filterexceptions.pl b/template/en/default/filterexceptions.pl
index 8f297ef42..9fc4232b0 100644
--- a/template/en/default/filterexceptions.pl
+++ b/template/en/default/filterexceptions.pl
@@ -526,6 +526,15 @@
'const.CONTROLMAPMANDATORY',
],
+'admin/products/list.html.tmpl' => [
+ 'classification_url_part',
+],
+
+'admin/products/footer.html.tmpl' => [
+ 'classification_url_part',
+ 'classification_text',
+],
+
'admin/keywords/edit.html.tmpl' => [
'keyword_id',
'bug_count',