From c02a3019c2426016fadde0afe6da9aa076941918 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 21 Dec 2005 18:49:03 +0000 Subject: [PATCH] POD for two small files --- lib/WebGUI/Operation/WebGUI.pm | 23 +++++++++ lib/WebGUI/Subscription.pm | 87 +++++++++++++++++++++++++++++++++- 2 files changed, 109 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/Operation/WebGUI.pm b/lib/WebGUI/Operation/WebGUI.pm index a480e99c6..7adc6f2ff 100644 --- a/lib/WebGUI/Operation/WebGUI.pm +++ b/lib/WebGUI/Operation/WebGUI.pm @@ -22,6 +22,13 @@ use WebGUI::URL; use WebGUI::User; #------------------------------------------------------------------- + +=head2 www_genesis ( ) + +The beginning of WebGUI. + +=cut + sub www_genesis { $session{page}{useEmptyStyle} = 1; my $output = 'About WebGUI @@ -39,6 +46,14 @@ sub www_genesis { return $output; } +=head2 www_setup ( ) + +Initial setup for a brand new WebGUI install. Sets the administrator name, +password and email address, as well as some other WebGUI settings. + +=cut + + #------------------------------------------------------------------- sub www_setup { return "" unless ($session{setting}{specialState} eq "init"); @@ -138,6 +153,14 @@ sub www_setup { } +=head2 theWg ( ) + +The core WebGUI function. All WebGUI Assets, Operations and functions require this +to work, even superseding the session variable. + +=cut + + #------------------------------------------------------------------- sub www_theWg { $session{page}{useEmptyStyle} = 1; diff --git a/lib/WebGUI/Subscription.pm b/lib/WebGUI/Subscription.pm index ee80909bf..05b7808f2 100644 --- a/lib/WebGUI/Subscription.pm +++ b/lib/WebGUI/Subscription.pm @@ -8,6 +8,25 @@ use WebGUI::Utility; use WebGUI::Commerce::Payment; use WebGUI::DateTime; +=head1 NAME + +Package WebGUI::Subscription + +=head1 DESCRIPTION + +Base class for subscriptions + +=head2 _getDuration ( $duration ) + +Internal utility function for calculating when a subscription expires. +Returns the date in epoch format when it expires. + +=head3 $duration + +Text description of how long the subscription lasts. + +=cut + sub _getDuration { my $duration = shift; @@ -21,8 +40,23 @@ sub _getDuration { } #------------------------------------------------------------------- + +=head2 apply ( [ $userId ] ) + +Method for subscribing a user. Adds user to the proper group and sets the expiration date, +adds karma to the user for purchasing a subscription, and then runs any external commands +as specified by the executeOnSubscription property. Macros in executeOnSubscription are +expanded before the command is executed. + +=head3 userId + +ID of the user purchasing the subscription. If omitted, uses the current user as +specified by the session variable. + +=cut + sub apply { - my ($self, $userId, $groupId, $expirationDate); + my ($self, $userId, $groupId); $self = shift; $userId = shift || $session{user}{userId}; $groupId = $self->{_properties}{subscriptionGroup}; @@ -40,6 +74,14 @@ sub apply { } #------------------------------------------------------------------- + +=head2 delete + +Method for deleting a subscription. Marks the subscription as deleted in the database +but does not remove it from the database. + +=cut + sub delete { my ($self); $self = shift; @@ -49,6 +91,19 @@ sub delete { } #------------------------------------------------------------------- + +=head2 get ( $key ) + +Generic assessor method for Subscription objects. + +=head3 key + +Returns only the requested property. Returns undef if the key does not exist +in the object properties. Returns the entire property hash if the key is +false (0, undef, ''); + +=cut + sub get { my ($self, $key) = @_; return $self->{_properties}{$key} if ($key); @@ -56,6 +111,19 @@ sub get { } #------------------------------------------------------------------- + +=head2 new ( $subscriptionId ) + +Object creation method. + +=head3 subscriptionId + +ID of the subscription to create. If this subscriptionId exists in the +database, the object created will be fully populated with properties +from the database. + +=cut + sub new { my ($class, $subscriptionId, %properties); $class = shift; @@ -72,6 +140,23 @@ sub new { } #------------------------------------------------------------------- + +=head2 set ( $properties ) + +Returns the date in epoch format when it expires. + +=head3 $properties + +A hashref containing properties to set in the object. Only valid properties will be +set. Also updates the subscription record in the database with properties that have +been set. + +=head3 Valid Object properties + +name price description subscriptionGroup duration executeOnSubscribe karma + +=cut + sub set { my ($self, $properties, @fieldsToUpdate); $self = shift;