From 1f8302ef52a8befa502b429a98590d108503ec21 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 4 Jul 2009 21:28:52 +0000 Subject: [PATCH] Add missing to the Product. --- lib/WebGUI/Asset/Sku/Product.pm | 271 +++++++++++++++++++++++++++++++- 1 file changed, 265 insertions(+), 6 deletions(-) diff --git a/lib/WebGUI/Asset/Sku/Product.pm b/lib/WebGUI/Asset/Sku/Product.pm index 03e0a6ef2..08d59a72a 100644 --- a/lib/WebGUI/Asset/Sku/Product.pm +++ b/lib/WebGUI/Asset/Sku/Product.pm @@ -394,6 +394,17 @@ sub getConfiguredTitle { #------------------------------------------------------------------- + +=head2 getFileIconUrl ( $store ) + +Return a file icon URL for file collateral. + +=head3 $store + +A WebGUI::Storage object. The returned icon will be for the first file in the storage object. + +=cut + sub getFileIconUrl { my $self = shift; my $store = $_[0]; @@ -401,6 +412,17 @@ sub getFileIconUrl { } #------------------------------------------------------------------- + +=head2 getFilename ( $store ) + +Return a filename from a WebGUI::Storage object. + +=head3 $store + +The WebGUI::Storage object to look up the file. + +=cut + sub getFilename { my $self = shift; my $store = $_[0]; @@ -414,6 +436,17 @@ sub getFilename { } #------------------------------------------------------------------- + +=head2 getFileUrl ( $store ) + +Return a URL for file collateral. + +=head3 $store + +A WebGUI::Storage object. The returned URL will be for the first file in the storage object. + +=cut + sub getFileUrl { my $self = shift; my $store = $_[0]; @@ -714,12 +747,19 @@ sub prepareView { #------------------------------------------------------------------- + +=head2 purge + +Extend the base class to handle all file collateral. + +=cut + sub purge { my $self = shift; - my $sth = $self->session->db->read("select image1, image2, image3, brochure, manual, warranty from Product where assetId=".$self->session->db->quote($self->getId)); + my $sth = $self->session->db->read("select image1, image2, image3, brochure, manual, warranty from Product where assetId=?", [$self->getId]); while (my @array = $sth->array) { - foreach my $id (@array){ - next if ($id eq ""); + ID: foreach my $id (@array){ + next ID if ($id eq ""); WebGUI::Storage->get($self->session,$id)->delete; } } @@ -731,7 +771,7 @@ sub purge { =head2 purgeCache ( ) -See WebGUI::Asset::purgeCache() for details. +Extends the base class to handle cleaning up the cache for this asset. =cut @@ -745,7 +785,7 @@ sub purgeCache { =head2 purgeRevision ( ) -See WebGUI::Asset::purgeRevision() for details. +Extend the base method to handle deleting file collateral. =cut @@ -838,6 +878,14 @@ sub setCollateral { } #------------------------------------------------------------------- + +=head2 www_addAccessory + +Builds a form that lists other Products that could be accessories for this one, and allows +the user to select them. + +=cut + sub www_addAccessory { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -885,6 +933,13 @@ sub www_addAccessory { } #------------------------------------------------------------------- + +=head2 www_addAccessorySave + +Process the addAccessory form. + +=cut + sub www_addAccessorySave { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -904,6 +959,13 @@ sub www_addAccessorySave { } #------------------------------------------------------------------- + +=head2 www_addRelated + +Provides a form for the user to pick Products related to this one. + +=cut + sub www_addRelated { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -952,6 +1014,13 @@ sub www_addRelated { } #------------------------------------------------------------------- + +=head2 www_addRelatedSave + +Process the addRelated form. + +=cut + sub www_addRelatedSave { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1006,6 +1075,13 @@ sub www_deleteAccessoryConfirm { } #------------------------------------------------------------------- + +=head2 www_deleteBenefitConfirm + +Delete a benefit from the Product, given the form variable C. + +=cut + sub www_deleteBenefitConfirm { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1014,6 +1090,13 @@ sub www_deleteBenefitConfirm { } #------------------------------------------------------------------- + +=head2 www_deleteFeatureConfirm + +Delete a feature from the Product, given the form variable C. + +=cut + sub www_deleteFeatureConfirm { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1022,6 +1105,13 @@ sub www_deleteFeatureConfirm { } #------------------------------------------------------------------- + +=head2 www_deleteFileConfirm + +Delete a piece of file collateral, as given by the form variable C. + +=cut + sub www_deleteFileConfirm { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1035,6 +1125,13 @@ sub www_deleteFileConfirm { } #------------------------------------------------------------------- + +=head2 www_deleteRelatedConfirm + +Remove a Product from the list of related products, as given by the form variable C. + +=cut + sub www_deleteRelatedConfirm { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1043,6 +1140,13 @@ sub www_deleteRelatedConfirm { } #------------------------------------------------------------------- + +=head2 www_deleteVariantConfirm + +Remove a variant from this Product, as given by the form variable C. + +=cut + sub www_deleteVariantConfirm { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1051,6 +1155,13 @@ sub www_deleteVariantConfirm { } #------------------------------------------------------------------- + +=head2 www_deleteSpecificationConfirm + +Remove a specification from this Product, as given by the form variable C. + +=cut + sub www_deleteSpecificationConfirm { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1060,6 +1171,13 @@ sub www_deleteSpecificationConfirm { #------------------------------------------------------------------- + +=head2 www_editBenefit + +Form to edit, or add benefits to this Product. + +=cut + sub www_editBenefit { my $self = shift; my $bid = shift || $self->session->form->process('bid'); @@ -1091,6 +1209,13 @@ sub www_editBenefit { } #------------------------------------------------------------------- + +=head2 www_editBenefitSave + +Process the editBenefit form. + +=cut + sub www_editBenefitSave { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1109,6 +1234,13 @@ sub www_editBenefitSave { } #------------------------------------------------------------------- + +=head2 www_editFeature + +Form to add or edit features to thie Product. + +=cut + sub www_editFeature { my $self = shift; my $fid = shift || $self->session->form->process('fid'); @@ -1140,6 +1272,13 @@ sub www_editFeature { } #------------------------------------------------------------------- + +=head2 www_editFeatureSave + +Process the editFeature form. + +=cut + sub www_editFeatureSave { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1158,6 +1297,13 @@ sub www_editFeatureSave { } #------------------------------------------------------------------- + +=head2 www_editSpecification + +Form to add or edit a specification. + +=cut + sub www_editSpecification { my $self = shift; my $sid = shift || $self->session->form->process('sid'); @@ -1203,6 +1349,13 @@ sub www_editSpecification { } #------------------------------------------------------------------- + +=head2 www_editSpecificationSave + +Process the editSpecification form. + +=cut + sub www_editSpecificationSave { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1224,6 +1377,13 @@ sub www_editSpecificationSave { } #------------------------------------------------------------------- + +=head2 www_editVariant + +Form to add or edit a variant. + +=cut + sub www_editVariant { my $self = shift; my $vid = shift || $self->session->form->process("vid"); @@ -1280,6 +1440,13 @@ sub www_editVariant { } #------------------------------------------------------------------- + +=head2 www_editVariantSave + +Process the editVariant form. + +=cut + sub www_editVariantSave { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1303,6 +1470,13 @@ sub www_editVariantSave { } #------------------------------------------------------------------- + +=head2 www_moveAccessoryDown + +Move an accessory, given by C, down one place. + +=cut + sub www_moveAccessoryDown { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1311,6 +1485,13 @@ sub www_moveAccessoryDown { } #------------------------------------------------------------------- + +=head2 www_moveAccessoryUp + +Move an accessory, given by C, up one place. + +=cut + sub www_moveAccessoryUp { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1319,6 +1500,13 @@ sub www_moveAccessoryUp { } #------------------------------------------------------------------- + +=head2 www_moveBenefitDown + +Move an benefit, given by C, down one place. + +=cut + sub www_moveBenefitDown { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1327,6 +1515,13 @@ sub www_moveBenefitDown { } #------------------------------------------------------------------- + +=head2 www_moveBenefitUp + +Move an benefit, given by C, up one place. + +=cut + sub www_moveBenefitUp { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1335,6 +1530,13 @@ sub www_moveBenefitUp { } #------------------------------------------------------------------- + +=head2 www_moveFeatureDown + +Move an feature, given by C, down one place. + +=cut + sub www_moveFeatureDown { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1343,6 +1545,13 @@ sub www_moveFeatureDown { } #------------------------------------------------------------------- + +=head2 www_moveFeatureUp + +Move an feature, given by C, up one place. + +=cut + sub www_moveFeatureUp { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1351,6 +1560,13 @@ sub www_moveFeatureUp { } #------------------------------------------------------------------- + +=head2 www_moveRelatedDown + +Move a related asset, given by C, down one place. + +=cut + sub www_moveRelatedDown { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1359,6 +1575,13 @@ sub www_moveRelatedDown { } #------------------------------------------------------------------- + +=head2 www_moveRelatedUp + +Move a related asset, given by C, up one place. + +=cut + sub www_moveRelatedUp { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1367,6 +1590,13 @@ sub www_moveRelatedUp { } #------------------------------------------------------------------- + +=head2 www_moveSpecificationDown + +Move an specification, given by C, down one place. + +=cut + sub www_moveSpecificationDown { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1375,6 +1605,13 @@ sub www_moveSpecificationDown { } #------------------------------------------------------------------- + +=head2 www_moveSpecificationUp + +Move an specification, given by C, up one place. + +=cut + sub www_moveSpecificationUp { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1383,6 +1620,13 @@ sub www_moveSpecificationUp { } #------------------------------------------------------------------- + +=head2 www_moveVariantDown + +Move an variant, given by C, down one place. + +=cut + sub www_moveVariantDown { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1391,6 +1635,13 @@ sub www_moveVariantDown { } #------------------------------------------------------------------- + +=head2 www_moveVariantUp + +Move an variant, given by C, up one place. + +=cut + sub www_moveVariantUp { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); @@ -1399,6 +1650,14 @@ sub www_moveVariantUp { } #------------------------------------------------------------------- + +=head2 view + +Render the view screen for the Product, with variants, specification, related products, +file collateral, and everything else. + +=cut + sub view { my $self = shift; my $error = shift; @@ -1610,7 +1869,7 @@ sub view { =head2 www_view ( ) -See WebGUI::Asset::Sku::www_view() for details. +Extend the base method to handle caching. =cut