diff --git a/lib/WebGUI/Forum/Post.pm b/lib/WebGUI/Forum/Post.pm index 3e5647a43..1bbe49c89 100644 --- a/lib/WebGUI/Forum/Post.pm +++ b/lib/WebGUI/Forum/Post.pm @@ -1,5 +1,19 @@ package WebGUI::Forum::Post; +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2003 Plain Black LLC. + ------------------------------------------------------------------- + Please read the legal notices (docs/legal.txt) and the license + (docs/license.txt) that came with this distribution before using + this software. + ------------------------------------------------------------------- + http://www.plainblack.com info@plainblack.com + ------------------------------------------------------------------- + +=cut + use strict; use WebGUI::DateTime; use WebGUI::Forum::Thread; @@ -7,6 +21,38 @@ use WebGUI::Session; use WebGUI::SQL; use WebGUI::Utility; +=head1 DESCRIPTION + +Data management class for forum posts. + +=head1 SYNOPSIS + + use WebGUI::Forum::Post; + $forum = WebGUI::Forum::Post->create(\%params); + $forum = WebGUI::Forum::Post->new($postId); + +=head1 METHODS + +These methods are available from this class: + +=cut + +#------------------------------------------------------------------- + +=head2 canEdit ( [ userId ] ) + +Returns a boolean indicating whether the user can edit the current post. + +=over + +=item userId + +The unique identifier to check privileges against. Defaults to the current user. + +=back + +=cut + sub canEdit { my ($self, $userId) = @_; $userId = $session{user}{userId} unless ($userId); @@ -14,6 +60,22 @@ sub canEdit { && $self->getThread->getForum->get("editTimeout") < (WebGUI::DateTime::time() - $self->get("dateOfPost")))); } +#------------------------------------------------------------------- + +=head2 create ( [ data ] ) + +Creates a new post. + +=over + +=item data + +A hash reference containing the data to use to create the post. See the forumPost table for details. + +=back + +=cut + sub create { my ($self, $data) = @_; $data->{dateOfPost} = WebGUI::DateTime::time(); @@ -28,6 +90,22 @@ sub create { return $self; } +#------------------------------------------------------------------- + +=head2 get ( [ param ] ) + +Returns a hash reference containing all of the parameters of this post. + +=over + +=item param + +The name of a parameter to get. If specified then the method will return only the value for this parameter as a scalar. + +=back + +=cut + sub get { my ($self, $key) = @_; if ($key eq "") { @@ -36,6 +114,14 @@ sub get { return $self->{_properties}->{$key}; } +#------------------------------------------------------------------- + +=head2 getReplies ( ) + +Returns an array reference containing a list of post objects that are direct decendants to this post. + +=cut + sub getReplies { my ($self) = @_; my @replies = (); @@ -54,6 +140,14 @@ sub getReplies { return \@replies; } +#------------------------------------------------------------------- + +=head2 getThread ( ) + +Returns the thread object that is related to this post. + +=cut + sub getThread { my ($self) = @_; unless (exists $self->{_thread}) { @@ -62,6 +156,26 @@ sub getThread { return $self->{_thread}; } +#------------------------------------------------------------------- + +=head2 hasRated ( [ userId, ipAddress ] ) + +Returns a boolean indicating whether this user has already rated this post. + +=over + +=item userId + +A unique identifier for a user to check. Defaults to the current user. + +=item ipAddress + +If the user ID equals 1 (visitor) then an IP address is used to distinguish the user. Defaults to the current user's ip address. + +=back + +=cut + sub hasRated { my ($self, $userId, $ipAddress) = @_; $userId = $session{user}{userId} unless ($userId); diff --git a/lib/WebGUI/Forum/Thread.pm b/lib/WebGUI/Forum/Thread.pm index b9531cfd8..330cb3680 100644 --- a/lib/WebGUI/Forum/Thread.pm +++ b/lib/WebGUI/Forum/Thread.pm @@ -1,5 +1,19 @@ package WebGUI::Forum::Thread; +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2003 Plain Black LLC. + ------------------------------------------------------------------- + Please read the legal notices (docs/legal.txt) and the license + (docs/license.txt) that came with this distribution before using + this software. + ------------------------------------------------------------------- + http://www.plainblack.com info@plainblack.com + ------------------------------------------------------------------- + +=cut + use strict; use WebGUI::DateTime; use WebGUI::Forum; @@ -8,6 +22,22 @@ use WebGUI::Session; use WebGUI::SQL; use WebGUI::Utility; +=head1 DESCRIPTION + +Data management class for forum threads. + +=head1 SYNOPSIS + + use WebGUI::Forum; + $forum = WebGUI::Forum::Thread->create(\%params); + $forum = WebGUI::Forum::Thread->new($threadId); + +=head1 METHODS + +These methods are available from this class: + +=cut + sub create { my ($self, $data, $postData) = @_; $data->{forumThreadId} = "new"; diff --git a/lib/WebGUI/Forum/UI.pm b/lib/WebGUI/Forum/UI.pm index 826674645..f58eb4604 100644 --- a/lib/WebGUI/Forum/UI.pm +++ b/lib/WebGUI/Forum/UI.pm @@ -1,5 +1,19 @@ package WebGUI::Forum::UI; +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2003 Plain Black LLC. + ------------------------------------------------------------------- + Please read the legal notices (docs/legal.txt) and the license + (docs/license.txt) that came with this distribution before using + this software. + ------------------------------------------------------------------- + http://www.plainblack.com info@plainblack.com + ------------------------------------------------------------------- + +=cut + use strict qw(vars subs); use WebGUI::DateTime; use WebGUI::Form; @@ -14,6 +28,20 @@ use WebGUI::Session; use WebGUI::Template; +=head1 DESCRIPTION + +User interface package for forums. + +=head1 SYNOPSIS + + use WebGUI::Forum::UI; + +=head1 FUNCTIONS + +These functions are available from this package: + +=cut + sub chopSubject { return substr(formatSubject($_[0]),0,30); }