the beginnings of the message log replacement
This commit is contained in:
parent
3816ad750f
commit
518a65df78
3 changed files with 316 additions and 1 deletions
|
|
@ -17,7 +17,7 @@ package WebGUI::User;
|
|||
use strict;
|
||||
use WebGUI::Cache;
|
||||
use WebGUI::Group;
|
||||
|
||||
use WebGUI::User::Inbox;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -46,6 +46,8 @@ This package provides an object-oriented way of managing WebGUI users as well as
|
|||
$u->deleteFromGroups(\@arr);
|
||||
$u->delete;
|
||||
|
||||
my $inbox = $u->inbox;
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
|
@ -137,6 +139,7 @@ Deletes this user.
|
|||
sub delete {
|
||||
my $self = shift;
|
||||
$self->uncache;
|
||||
$self->inbox->delete;
|
||||
foreach my $groupId (@{$self->getGroups($self->userId)}) {
|
||||
WebGUI::Group->new($self->session,$groupId)->deleteUsers([$self->userId]);
|
||||
}
|
||||
|
|
@ -179,6 +182,7 @@ Deconstructor.
|
|||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
$self->{_inbox}->DESTROY if (exists $self->{_inbox});
|
||||
undef $self;
|
||||
}
|
||||
|
||||
|
|
@ -230,6 +234,23 @@ sub identifier {
|
|||
return $self->{_user}{"identifier"};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 inbox
|
||||
|
||||
Returns the user's WebGUI::User::Inbox object.
|
||||
|
||||
=cut
|
||||
|
||||
sub inbox {
|
||||
my $self = shift;
|
||||
unless ($self->{_inbox}) {
|
||||
$self->{_inbox} = WebGUI::User::Inbox->new($self);
|
||||
}
|
||||
return $self->{_inbox};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isInGroup ( [ groupId ] )
|
||||
|
|
|
|||
121
lib/WebGUI/User/Inbox.pm
Normal file
121
lib/WebGUI/User/Inbox.pm
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
package WebGUI::User::Inbox;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
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;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::User::Inbox;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This package provides an API for working with a User's inbox.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $inbox = $user->inbox;
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addMessage ( )
|
||||
|
||||
=cut
|
||||
|
||||
sub addMessage {
|
||||
my $self = shift;
|
||||
return WebGUI::User::Inbox::Message->create($self);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 deleteAllMessages
|
||||
|
||||
Deletes all the messages in this user's inbox.
|
||||
|
||||
=cut
|
||||
|
||||
sub deleteAllMessages {
|
||||
my $self = shift;
|
||||
my $sth = $self->session->db->prepare("delete from userInbox where userId=?");
|
||||
$sth->execute($self->user->userId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head DESTROY ( )
|
||||
|
||||
Deconstructor.
|
||||
|
||||
=cut
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
undef $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( user )
|
||||
|
||||
Constructor.
|
||||
|
||||
=head3 user
|
||||
|
||||
A reference to the user who's inbox that we'll be manipulating.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $user = shift;
|
||||
bless {_user=>$user}, $class;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session
|
||||
|
||||
Returns a reference to the current session.
|
||||
|
||||
=cut
|
||||
|
||||
sub session {
|
||||
my $self = shift;
|
||||
return $self->user->session;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 user
|
||||
|
||||
Returns a reference to the user who owns this inbox.
|
||||
|
||||
=cut
|
||||
|
||||
sub user {
|
||||
my $self = shift;
|
||||
return $self->{_user};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
173
lib/WebGUI/User/Inbox/Message.pm
Normal file
173
lib/WebGUI/User/Inbox/Message.pm
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
package WebGUI::User::Inbox::Message;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
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;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::User::Inbox::Message;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This package provides an API for working with a User's inbox messages.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 create ( )
|
||||
|
||||
=cut
|
||||
|
||||
sub create {
|
||||
my $self = shift;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 delete
|
||||
|
||||
Deletes this message from the inbox.
|
||||
|
||||
=cut
|
||||
|
||||
sub delete {
|
||||
my $self = shift;
|
||||
my $sth = $self->session->db->prepare("delete from userInbox where messageId=?");
|
||||
$sth->execute($self->getId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head DESTROY ( )
|
||||
|
||||
Deconstructor.
|
||||
|
||||
=cut
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
undef $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 get ( property )
|
||||
|
||||
Returns the value of a property.
|
||||
|
||||
=head3 property
|
||||
|
||||
The name of any property of an inbox message.
|
||||
|
||||
=head4 message
|
||||
|
||||
=head4 subject
|
||||
|
||||
=cut
|
||||
|
||||
sub get {
|
||||
my $self = shift;
|
||||
unless ($self->{_properties}) {
|
||||
$self->{_properties} = $self->session->db->getRow("userInbox","messageId",$self->getId);
|
||||
}
|
||||
return $self->{_properties}{shift};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getId ()
|
||||
|
||||
Returns the ID of this message.
|
||||
|
||||
=cut
|
||||
|
||||
sub getId {
|
||||
my $self = shift;
|
||||
return $self->{_messageId};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 inbox
|
||||
|
||||
Returns a reference to the user's inbox.
|
||||
|
||||
=cut
|
||||
|
||||
sub inbox {
|
||||
my $self = shift;
|
||||
return $self->{_inbox};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( inbox, messageId )
|
||||
|
||||
Constructor.
|
||||
|
||||
=head3 inbox
|
||||
|
||||
A reference to a user's inbox object.
|
||||
|
||||
=head3 messageId
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $inbox = shift;
|
||||
my $messageId = shift;
|
||||
bless {_inbox=>$inbox, _messageId=>$messageId}, $class;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session
|
||||
|
||||
Returns a reference to the current session.
|
||||
|
||||
=cut
|
||||
|
||||
sub session {
|
||||
my $self = shift;
|
||||
return $self->inbox->session;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 user
|
||||
|
||||
Returns a reference to the user who owns this inbox.
|
||||
|
||||
=cut
|
||||
|
||||
sub user {
|
||||
my $self = shift;
|
||||
return $self->inbox->user;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue