adding POD
This commit is contained in:
parent
61a859d862
commit
1e32fa5bd4
3 changed files with 172 additions and 0 deletions
|
|
@ -1,5 +1,19 @@
|
||||||
package WebGUI::Forum::Post;
|
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 strict;
|
||||||
use WebGUI::DateTime;
|
use WebGUI::DateTime;
|
||||||
use WebGUI::Forum::Thread;
|
use WebGUI::Forum::Thread;
|
||||||
|
|
@ -7,6 +21,38 @@ use WebGUI::Session;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
use WebGUI::Utility;
|
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 {
|
sub canEdit {
|
||||||
my ($self, $userId) = @_;
|
my ($self, $userId) = @_;
|
||||||
$userId = $session{user}{userId} unless ($userId);
|
$userId = $session{user}{userId} unless ($userId);
|
||||||
|
|
@ -14,6 +60,22 @@ sub canEdit {
|
||||||
&& $self->getThread->getForum->get("editTimeout") < (WebGUI::DateTime::time() - $self->get("dateOfPost"))));
|
&& $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 {
|
sub create {
|
||||||
my ($self, $data) = @_;
|
my ($self, $data) = @_;
|
||||||
$data->{dateOfPost} = WebGUI::DateTime::time();
|
$data->{dateOfPost} = WebGUI::DateTime::time();
|
||||||
|
|
@ -28,6 +90,22 @@ sub create {
|
||||||
return $self;
|
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 {
|
sub get {
|
||||||
my ($self, $key) = @_;
|
my ($self, $key) = @_;
|
||||||
if ($key eq "") {
|
if ($key eq "") {
|
||||||
|
|
@ -36,6 +114,14 @@ sub get {
|
||||||
return $self->{_properties}->{$key};
|
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 {
|
sub getReplies {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my @replies = ();
|
my @replies = ();
|
||||||
|
|
@ -54,6 +140,14 @@ sub getReplies {
|
||||||
return \@replies;
|
return \@replies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 getThread ( )
|
||||||
|
|
||||||
|
Returns the thread object that is related to this post.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub getThread {
|
sub getThread {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
unless (exists $self->{_thread}) {
|
unless (exists $self->{_thread}) {
|
||||||
|
|
@ -62,6 +156,26 @@ sub getThread {
|
||||||
return $self->{_thread};
|
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 {
|
sub hasRated {
|
||||||
my ($self, $userId, $ipAddress) = @_;
|
my ($self, $userId, $ipAddress) = @_;
|
||||||
$userId = $session{user}{userId} unless ($userId);
|
$userId = $session{user}{userId} unless ($userId);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,19 @@
|
||||||
package WebGUI::Forum::Thread;
|
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 strict;
|
||||||
use WebGUI::DateTime;
|
use WebGUI::DateTime;
|
||||||
use WebGUI::Forum;
|
use WebGUI::Forum;
|
||||||
|
|
@ -8,6 +22,22 @@ use WebGUI::Session;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
use WebGUI::Utility;
|
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 {
|
sub create {
|
||||||
my ($self, $data, $postData) = @_;
|
my ($self, $data, $postData) = @_;
|
||||||
$data->{forumThreadId} = "new";
|
$data->{forumThreadId} = "new";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,19 @@
|
||||||
package WebGUI::Forum::UI;
|
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 strict qw(vars subs);
|
||||||
use WebGUI::DateTime;
|
use WebGUI::DateTime;
|
||||||
use WebGUI::Form;
|
use WebGUI::Form;
|
||||||
|
|
@ -14,6 +28,20 @@ use WebGUI::Session;
|
||||||
use WebGUI::Template;
|
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 {
|
sub chopSubject {
|
||||||
return substr(formatSubject($_[0]),0,30);
|
return substr(formatSubject($_[0]),0,30);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue