From c1ffd1bc2e236ebf890959e4299201bebf24c64e Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 4 Mar 2006 01:07:40 +0000 Subject: [PATCH] POD, and missing session objects --- lib/WebGUI/Operation/ProductManager.pm | 210 +++++++++++++++++++++++++ lib/WebGUI/Operation/Subscription.pm | 195 ++++++++++++++++++++++- 2 files changed, 398 insertions(+), 7 deletions(-) diff --git a/lib/WebGUI/Operation/ProductManager.pm b/lib/WebGUI/Operation/ProductManager.pm index 769091133..6c1274fe8 100755 --- a/lib/WebGUI/Operation/ProductManager.pm +++ b/lib/WebGUI/Operation/ProductManager.pm @@ -11,6 +11,29 @@ use WebGUI::Product; use WebGUI::HTML; #------------------------------------------------------------------- + +=head2 _submenu ( $session ) + +Returns a rendered Admin Console view, with a standard list of five submenu items. + +=head3 $session + +The current WebGUI session object. + +=head3 workarea + +A scalar of HTML that defines the current workarea. + +=head3 title + +The i18n key of the title of this workarea. + +=head3 help + +The i18n key of the help link for this workarea. + +=cut + sub _submenu { my $session = shift; my $i18n = WebGUI::International->new($session, "ProductManager"); @@ -35,6 +58,17 @@ sub _submenu { } #------------------------------------------------------------------- + +=head2 www_deleteProductParameterOption ( $session ) + +Deletes a product parameter option specified by form parameter 'optionId'. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_deleteProductParameterOption { my $session = shift; my $optionId = $session->form->process("optionId"); @@ -47,6 +81,17 @@ sub www_deleteProductParameterOption { } #------------------------------------------------------------------- + +=head2 www_deleteProductParameter ( $session ) + +Deletes a product parameter specified by form parameter 'parameterId'. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_deleteProductParameter { my $session = shift; my $parameterId = $session->form->process("parameterId"); @@ -59,6 +104,17 @@ sub www_deleteProductParameter { } #------------------------------------------------------------------- + +=head2 www_deleteProduct ( $session ) + +Deletes a product specified by form parameter 'productId'. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_deleteProduct { my $session = shift; my $productId = $session->form->process("productId"); @@ -71,6 +127,17 @@ sub www_deleteProduct { } #------------------------------------------------------------------- + +=head2 www_editProduct ( $session ) + +Returns a form to edit or add a new product. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editProduct { my $session = shift; my ($productId, $product, $f, $i18n); @@ -147,6 +214,17 @@ sub www_editProduct { } #------------------------------------------------------------------- + +=head2 www_editProductSave ( $session ) + +Saves the properties of a product. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editProductSave { my $session = shift; my ($self, @error, $productId, $product, $i18n); @@ -179,6 +257,17 @@ sub www_editProductSave { } #------------------------------------------------------------------- + +=head2 www_editProductParameter ( $session ) + +Returns a form to edit a product parameter. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editProductParameter { my $session = shift; my ($parameterId, $product, $productId, $parameter, $f, $i18n); @@ -226,6 +315,17 @@ sub www_editProductParameter { } #------------------------------------------------------------------- + +=head2 www_editProductParameterSave ( $session ) + +Saves the properties of a product parameter. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editProductParameterSave { my $session = shift; my (@error, $parameterId, $product, $i18n, $skuTemplate, $oldName, $newName); @@ -265,6 +365,17 @@ sub www_editProductParameterSave { } #------------------------------------------------------------------- + +=head2 www_editProductParameterOption ( $session ) + +Edits the options of a product parameter. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editProductParameterOption { my $session = shift; my ($self, $optionId, $option, $f, $i18n); @@ -329,6 +440,17 @@ sub www_editProductParameterOption { } #------------------------------------------------------------------- + +=head2 www_editProductParameterOptionSave ( $session ) + +Saves the properties of a Product Parameter Option + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editProductParameterOptionSave { my $session = shift; my ($self, @error, $optionId, $product, $i18n); @@ -356,6 +478,17 @@ sub www_editProductParameterOptionSave { } #------------------------------------------------------------------- + +=head2 www_editProductVariant ( $session ) + +Returns a form to edit a Product Variant. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editProductVariant { my $session = shift; my ($variantId, $variant, $f, $i18n); @@ -410,6 +543,17 @@ sub www_editProductVariant { } #------------------------------------------------------------------- + +=head2 www_editProductVariantSave ( $session ) + +Saves the properties of a Product Variant. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editProductVariantSave { my $session = shift; my $variantId = $session->form->process("variantId"); @@ -422,6 +566,17 @@ my $variantId = $session->form->process("variantId"); } #------------------------------------------------------------------- + +=head2 www_editSkuTemplate ( $session ) + +Returns a form to edit a Sku Template. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editSkuTemplate { my $session = shift; my ($product, $productId, $output, $f, $name, $i18n); @@ -462,6 +617,17 @@ sub www_editSkuTemplate { } #------------------------------------------------------------------- + +=head2 www_editSkuTemplateSave ( $session ) + +Saves the properties of a Sku Template. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_editSkuTemplateSave { my $session = shift; my ($productId) = $session->form->process("productId"); @@ -476,6 +642,17 @@ sub www_editSkuTemplateSave { } #------------------------------------------------------------------- + +=head2 www_listProducts ( $session ) + +Returns a list of products with manage and delete buttons. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_listProducts { my $session = shift; my ($self, $sth, $output, $row, $i18n); @@ -504,6 +681,17 @@ sub www_listProducts { } #------------------------------------------------------------------- + +=head2 www_listProductVariants ( $session ) + +Returns a list of Product Variants. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_listProductVariants { my $session = shift; my ($productId, $product, @variants, %parameters, %options, $output, %composition, $i18n); @@ -567,6 +755,17 @@ sub www_listProductVariants { } #------------------------------------------------------------------- + +=head2 www_listProductVariantsSave ( $session ) + +Saves the properties of some product variants. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_listProductVariantsSave { my $session = shift; @@ -586,6 +785,17 @@ sub www_listProductVariantsSave { } #------------------------------------------------------------------- + +=head2 www_manageProduct ( $session ) + +Returns a screen that displays lots of options for editing all aspects of a product. + +=head3 $session + +The current WebGUI session object. + +=cut + sub www_manageProduct { my $session = shift; my ($productId, $product, $output, $parameter, $option, $optionId, $i18n); diff --git a/lib/WebGUI/Operation/Subscription.pm b/lib/WebGUI/Operation/Subscription.pm index 174c529e7..393bce9ae 100644 --- a/lib/WebGUI/Operation/Subscription.pm +++ b/lib/WebGUI/Operation/Subscription.pm @@ -12,6 +12,29 @@ use WebGUI::Asset::Template; use WebGUI::Form; use WebGUI::International; +=head1 NAME + +Package WebGUI::Operation::Subscription + +=head1 DESCRIPTION + +Operational handler for viewing, editing, listing, purchasing/redeeming, and deleting Subscriptions and Subscription Code Batches. + +=head2 _generateCode ( $session, codeLength ) + +Generates a human-readable subscription code, meant to be typed/pasted in somewhere. + +=head3 $session + +The current WebGUI session object. + +=head3 codeLength + +The whole number amount of characters you want returned. + +=cut + + #------------------------------------------------------------------- sub _generateCode { my $session = shift; @@ -26,6 +49,28 @@ sub _generateCode { return $code; } +=head2 _submenu ( $session ) + +Returns a rendered Admin Console view, with a standard list of five submenu items. + +=head3 $session + +The current WebGUI session object. + +=head3 workarea + +A scalar of HTML that defines the current workarea. + +=head3 title + +The i18n key of the title of this workarea. + +=head3 help + +The i18n key of the help link for this workarea. + +=cut + #------------------------------------------------------------------- sub _submenu { my $session = shift; @@ -47,6 +92,21 @@ sub _submenu { return $ac->render($workarea, $title); } +=head2 www_createSubscriptionCodeBatch ( $session, error ) + +Form to accept parameters to create a batch of subscription codes. + +=head3 $session + +The current WebGUI session object. + +=head3 error + +An HTML scalar of an error message to be returned to the user. + +=cut + + #------------------------------------------------------------------- sub www_createSubscriptionCodeBatch { my $session = shift; @@ -104,7 +164,18 @@ sub www_createSubscriptionCodeBatch { return _submenu($session,$errorMessage.$f->print, 'create batch menu', 'create batch'); } - + +=head2 www_createSubscriptionCodeBatchSave ( $session ) + +Method that accepts the form parameters to create a batch of subscription codes. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_createSubscriptionCodeBatchSave { my $session = shift; @@ -123,7 +194,7 @@ sub www_createSubscriptionCodeBatchSave { push(@error, $i18n->get('no association error')) unless ($session->form->process("subscriptionId")); push(@error, $i18n->get('code length error')) unless ($session->form->process("codeLength") >= 10 && $session->form->process("codeLength") <= 64 && $session->form->process("codeLength") =~ m/^\d\d$/); - return www_createSubscriptionCodeBatch(\@error) if (@error); + return www_createSubscriptionCodeBatch($session,\@error) if (@error); $creationEpoch =$session->datetime->time(); @@ -143,18 +214,40 @@ sub www_createSubscriptionCodeBatchSave { } } - return www_listSubscriptionCodeBatches(); + return www_listSubscriptionCodeBatches($session); } +=head2 www_deleteSubscription ( $session ) + +Method that deletes the subscription passed by the user through the form variable 'sid'. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_deleteSubscription { my $session = shift; return $session->privilege->adminOnly() unless ($session->user->isInGroup(3)); WebGUI::Subscription->new($session,$session->form->process("sid"))->delete; - return www_listSubscriptions(); + return www_listSubscriptions($session); } +=head2 www_deleteSubscriptionCodeBatch ( $session ) + +Method that deletes the subscription code batch passed by the user through the form variable 'bid'. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_deleteSubscriptionCodeBatch { my $session = shift; @@ -163,9 +256,20 @@ sub www_deleteSubscriptionCodeBatch { $session->db->write("delete from subscriptionCodeBatch where batchId=".$session->db->quote($session->form->process("bid"))); $session->db->write("delete from subscriptionCode where batchId=".$session->db->quote($session->form->process("bid"))); - return www_listSubscriptionCodeBatches(); + return www_listSubscriptionCodeBatches($session); } +=head2 www_deleteSubscriptionCodes ( $session ) + +Method that deletes some subscription codes. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_deleteSubscriptionCodes { my $session = shift; @@ -179,9 +283,20 @@ sub www_deleteSubscriptionCodes { ' and dateUsed <= '.$session->db->quote($session->form->process("duStop"))); } - return www_listSubscriptionCodes(); + return www_listSubscriptionCodes($session); } +=head2 www_editSubscription ( $session ) + +Returns a form so the user can edit the properties of a subscription. Uses the form variable 'sid'. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_editSubscription { my $session = shift; @@ -259,6 +374,17 @@ sub www_editSubscription { return _submenu($session,$f->print, 'edit subscription title', 'subscription add/edit'); } +=head2 www_editSubscriptionSave ( $session ) + +Saves the properties of a subscription. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_editSubscriptionSave { my $session = shift; @@ -267,9 +393,20 @@ sub www_editSubscriptionSave { @relevantFields = qw(subscriptionId name price description subscriptionGroup duration executeOnSubscription karma); WebGUI::Subscription->new($session,$session->form->process("sid"))->set({map {$_ => $session->form->process($_)} @relevantFields}); - return www_listSubscriptions(); + return www_listSubscriptions($session); } +=head2 www_listSubscriptionCodeBatches ( $session ) + +Returns a paginated list of batches of subscription codes, along with various links for each one. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_listSubscriptionCodeBatches { my $session = shift; @@ -300,6 +437,17 @@ sub www_listSubscriptionCodeBatches { return _submenu($session,$output, 'manage batches', 'manage batch'); } +=head2 www_listSubscriptionCodes ( $session ) + +Non-templated. Returns a paginated list of subscription codes. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_listSubscriptionCodes { my $session = shift; @@ -382,6 +530,17 @@ sub www_listSubscriptionCodes { return _submenu($session,$output, 'listSubscriptionCodes title', 'subscription codes manage'); } +=head2 www_listSubscriptions ( $session ) + +Returns a paginated list of subscriptions along with edit and delete links. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_listSubscriptions { my $session = shift; @@ -411,6 +570,17 @@ sub www_listSubscriptions { return _submenu($session,$output, 'manage subscriptions', 'subscription manage'); } +=head2 www_purchaseSubscription ( $session ) + +Adds subscription 'sid' to the user's shopping cart and returns the checkout screen. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_purchaseSubscription { my $session = shift; @@ -419,6 +589,17 @@ sub www_purchaseSubscription { return $session->http->setRedirect($session->url->page('op=checkout')); } +=head2 www_redeemSubscriptionCode ( $session ) + +Returns a form so the user can redeem a subscription code, or actually redeems the subscription code. + +=head3 $session + +The current WebGUI session object. + +=cut + + #------------------------------------------------------------------- sub www_redeemSubscriptionCode { my $session = shift;