summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Product.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-07-19 09:05:10 +0200
committerlpsolit%gmail.com <>2005-07-19 09:05:10 +0200
commit534173a0d5d06a945cd48da84815e4f003ebf727 (patch)
tree17c8d114e1d3eb194be1aaab9fe0a2a958d94374 /Bugzilla/Product.pm
parent0b6e85450a54b205afcda501b78d2dd2982d269e (diff)
downloadbugzilla-534173a0d5d06a945cd48da84815e4f003ebf727.tar.gz
bugzilla-534173a0d5d06a945cd48da84815e4f003ebf727.tar.xz
Bug 300532: Update editversions.cgi to use routines from Version.pm and Product.pm - Patch by Tiago R. Mello <timello@async.com.br> r=LpSolit a=myk
Diffstat (limited to 'Bugzilla/Product.pm')
-rw-r--r--Bugzilla/Product.pm46
1 files changed, 45 insertions, 1 deletions
diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm
index 28f1e73c0..37ef86a62 100644
--- a/Bugzilla/Product.pm
+++ b/Bugzilla/Product.pm
@@ -205,6 +205,33 @@ sub get_products_by_classification ($) {
return $products;
}
+sub get_all_products () {
+ my $dbh = Bugzilla->dbh;
+
+ my $ids = $dbh->selectcol_arrayref(q{
+ SELECT id FROM products ORDER BY name});
+
+ my @products;
+ foreach my $id (@$ids) {
+ push @products, new Bugzilla::Product($id);
+ }
+ return @products;
+}
+
+sub check_product ($) {
+ my ($product_name) = @_;
+
+ unless ($product_name) {
+ ThrowUserError('product_not_specified');
+ }
+ my $product = new Bugzilla::Product({name => $product_name});
+ unless ($product) {
+ ThrowUserError('product_doesnt_exist',
+ {'product' => $product_name});
+ }
+ return $product;
+}
+
1;
__END__
@@ -326,11 +353,28 @@ Product.pm represents a product object.
Description: Returns all products for a specific classification id.
- Params: none.
+ Params: $class_id - Integer with classification id.
Returns: A hash with product id as key and a Bugzilla::Product
object as value.
+=item C<get_all_products()>
+
+ Description: Returns all products from the database.
+
+ Params: none.
+
+ Returns: Bugzilla::Product object list.
+
+=item C<check_product($product_name)>
+
+ Description: Checks if the product name was passed in and if is a valid
+ product.
+
+ Params: $product_name - String with a product name.
+
+ Returns: Bugzilla::Product object.
+
=back
=cut