Better cleanup of Inbox messages. Encapsulate all SQL in Inbox/Message. Fix workflow. Upgrade script to cleanup state table. Fixes bug #11595.

This commit is contained in:
Colin Kuskie 2010-06-07 10:44:12 -07:00
parent 28eabdd997
commit 30e869b66d
6 changed files with 72 additions and 30 deletions

View file

@ -132,6 +132,28 @@ sub DESTROY {
#-------------------------------------------------------------------
=head2 deleteMessagesForUser ( $user )
Deletes all messages for a user.
=head3 $user
A WebGUI::User object, representing the user who will have all their messages deleted.
=cut
sub deleteMessagesForUser {
my $self = shift;
my $user = shift;
my $db = $self->session->db;
my $userId = $user->userId;
$db->write("DELETE FROM inbox_messageState WHERE userId=?",[$userId]);
$db->write("DELETE FROM inbox WHERE userId=? AND (groupId IS NULL OR groupId='')",[$userId]);
}
#-------------------------------------------------------------------
=head2 getMessage ( messageId [, userId] )
Returns a WebGUI::Inbox::Message object.