From 92502151f82f3c679b071eb8ea291ed345ba066c Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 23 Feb 2009 09:09:11 -0800 Subject: [PATCH 1/8] Add a test for setDelete. --- t/Inbox.t | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/t/Inbox.t b/t/Inbox.t index 9d2e99109..ff83715d3 100644 --- a/t/Inbox.t +++ b/t/Inbox.t @@ -17,7 +17,7 @@ use WebGUI::Session; use WebGUI::Inbox; use WebGUI::User; -use Test::More tests => 8; # increment this value for each test you create +use Test::More tests => 9; # increment this value for each test you create my $session = WebGUI::Test->session; @@ -59,7 +59,10 @@ ok($message->getId == $messageId, 'getMessage returns message object'); ######################################################### my $messageList = $inbox->getMessagesForUser($user); my $message_cnt = scalar(@{$messageList}); -ok($message_cnt > 0, 'Messages returned for user'); +is($message_cnt, 1, 'User only has 1 messages'); + +$message->setDeleted(3); +is(scalar(@{ $inbox->getMessagesForUser($user) }), 0, 'User has no undeleted messages'); END { $session->db->write('delete from inbox where messageId = ?', [$message->getId]); From 12de18502a916564921a77f0eeec42483f6769ca Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 23 Feb 2009 09:09:47 -0800 Subject: [PATCH 2/8] Beginning of Inbox/Message.t testing --- t/Inbox/Message.t | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 t/Inbox/Message.t diff --git a/t/Inbox/Message.t b/t/Inbox/Message.t new file mode 100644 index 000000000..36c026535 --- /dev/null +++ b/t/Inbox/Message.t @@ -0,0 +1,82 @@ +# vim:syntax=perl +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2009 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 +#------------------------------------------------------------------ + +# Write a little about what this script tests. +# +# + +use FindBin; +use strict; +use lib "$FindBin::Bin/../lib"; +use Test::More; +use Test::Deep; +use WebGUI::Test; # Must use this before any other WebGUI modules +use WebGUI::Session; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; + + +#---------------------------------------------------------------------------- +# Tests + + +my $numTests = 1; + +$numTests += 2; #For the use_ok + +plan tests => $numTests; + +#---------------------------------------------------------------------------- +# put your tests here + +my $module = 'WebGUI::Inbox::Message'; +my $loaded = use_ok($module); + +SKIP: { + +skip "Unable to load $module", $numTests-1 unless $loaded; + +############################################### +# +# statusCodes +# +############################################### + +my $statusCodes = WebGUI::Inbox::Message->statusCodes($session); +my $expectedCodes = { + active => ignore(), + pending => ignore(), + completed => ignore(), + unread => ignore(), + read => ignore(), + replied => ignore(), +}; + +cmp_deeply( $statusCodes, $expectedCodes, 'statusCodes as a class method works'); +undef $statusCodes; + +my $tempMessage = WebGUI::Inbox::Message->create($session, {}, {testing => 1}); +$statusCodes = $tempMessage->statusCodes; +cmp_deeply( $statusCodes, $expectedCodes, 'statusCodes as an object method works'); +undef $statusCodes; +$tempMessage->delete; + +} + + +#---------------------------------------------------------------------------- +# Cleanup +END { + +} +#vim:ft=perl From 9231eb9f460ceca82b06c740123f7d74b724f338 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 23 Feb 2009 09:10:31 -0800 Subject: [PATCH 3/8] Add an option to create, to not make emails. --- lib/WebGUI/Inbox/Message.pm | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/WebGUI/Inbox/Message.pm b/lib/WebGUI/Inbox/Message.pm index 9cbcfbd19..1aeb8b40f 100644 --- a/lib/WebGUI/Inbox/Message.pm +++ b/lib/WebGUI/Inbox/Message.pm @@ -97,12 +97,22 @@ Email message to use rather than inbox message contents. Email subject to use rather than inbox message subject. +=head3 options + +A hash reference containing options for handling the message. + +=head4 testing + +If testing is true, then no email will be made or sent. Only +the inbox message will be made. + =cut sub create { - my $class = shift; - my $session = shift; - my $properties = shift; + my $class = shift; + my $session = shift; + my $properties = shift; + my $options = shift || {}; my $self = {}; $self->{_properties}{messageId} = "new"; $self->{_properties}{status} = $properties->{status} || "pending"; @@ -149,11 +159,13 @@ sub create { } my $subject = (defined $properties->{emailSubject}) ? $properties->{emailSubject} : $self->{_properties}{subject}; - my $mail = WebGUI::Mail::Send->create($session, { - toUser=>$self->{_properties}{userId}, - toGroup=>$self->{_properties}{groupId}, - subject=>$subject, - }); + my $mail = $options->{testing} + ? undef + : WebGUI::Mail::Send->create($session, { + toUser=>$self->{_properties}{userId}, + toGroup=>$self->{_properties}{groupId}, + subject=>$subject, + }); if (defined $mail) { my $preface = ""; my $fromUser = WebGUI::User->new($session, $properties->{sentBy}); From a6c9d3c3d17bb893dfa2c321b896afe3976ed5be Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 23 Feb 2009 09:11:34 -0800 Subject: [PATCH 4/8] Peel off SQL so that others things can be selected. --- lib/WebGUI/Inbox.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Inbox.pm b/lib/WebGUI/Inbox.pm index 42afe686a..be0841821 100644 --- a/lib/WebGUI/Inbox.pm +++ b/lib/WebGUI/Inbox.pm @@ -439,6 +439,7 @@ sub getMessageSql { my $sortDir = $props->{sortDir}; my $whereClause = $props->{whereClause}; my $limit = $props->{limit}; + my $select = $props->{'select'}; if($sortBy) { $sortBy = qq{ORDER BY $sortBy $sortDir}; @@ -452,6 +453,14 @@ sub getMessageSql { $limit = qq{LIMIT $limit}; } + if(!$select) { + $select =< Date: Mon, 23 Feb 2009 12:27:11 -0800 Subject: [PATCH 5/8] API change to allow filtering messages by userId. Changes to getMessagesForUser, getMessagePaginator. With tests. --- lib/WebGUI/Inbox.pm | 31 +++++++++++++++------- t/Inbox.t | 64 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 82 insertions(+), 13 deletions(-) diff --git a/lib/WebGUI/Inbox.pm b/lib/WebGUI/Inbox.pm index be0841821..8fe51b311 100644 --- a/lib/WebGUI/Inbox.pm +++ b/lib/WebGUI/Inbox.pm @@ -154,7 +154,8 @@ sub getMessage { =head2 getNextMessage ( message [, userId] ) -Returns the message that was send after the message passed in for the user +Returns the message that was sent after the message passed in for the user. This is always assumed +to be in date order. =head3 message @@ -188,11 +189,12 @@ sub getNextMessage { =head2 getPreviousMessage ( message [, userId] ) -Returns the message that was sent before the message passed in for the user +Returns the message that was sent before the message passed in for the user. This is always assumed +to be sorted in date order. =head3 message -The message to find the previous message for +The message to find the previous message for. =head3 user @@ -240,6 +242,10 @@ An integer indication the page to return. Defaults to 1 The column to sort by +=head3 where + +An extra clause for filtering results. + =cut sub getMessagesForUser { @@ -248,13 +254,14 @@ sub getMessagesForUser { my $perpage = shift || 50; my $page = shift || 1; my $sortBy = shift; + my $where = shift; my $p = $self->getMessagesPaginator( $user , { sortBy => $sortBy, sortDir => "desc", paginateAfter => $perpage, - pageNumber => $page - + pageNumber => $page, + whereClause => $where, }); return $self->getMessagesOnPage($p); @@ -332,6 +339,10 @@ Specify the form variable the paginator should use in its links. Defaults to "p By default the page number will be determined by looking at $self->session->form->process("pn"). If that is empty the page number will be defaulted to "1". If you'd like to override the page number specify it here. +=head4 whereClause + +An extra clause to filter the results returned by the paginator. + =cut sub getMessagesPaginator { @@ -347,6 +358,7 @@ sub getMessagesPaginator { my $paginateAfter = $properties->{paginateAfter}; my $formVar = $properties->{formVar}; my $pageNumber = $properties->{pageNumber}; + my $whereClause = $properties->{whereClause} || ''; #Make sure a valid sortBy is passed in if($sortBy && !WebGUI::Utility::isIn($sortBy,qw( subject sentBy dateStamp status ))) { @@ -368,12 +380,13 @@ sub getMessagesPaginator { } my $sql = $self->getMessageSql($user, { - user => $user, - sortBy => $sortBy, - sortDir => $sortDir + user => $user, + sortBy => $sortBy, + sortDir => $sortDir, + whereClause => $whereClause, }); - #$session->log->warn($sql); + $session->log->warn("SQL: ".$sql); my $p = WebGUI::Paginator->new( $session, diff --git a/t/Inbox.t b/t/Inbox.t index ff83715d3..addf4cfda 100644 --- a/t/Inbox.t +++ b/t/Inbox.t @@ -17,12 +17,12 @@ use WebGUI::Session; use WebGUI::Inbox; use WebGUI::User; -use Test::More tests => 9; # increment this value for each test you create +use Test::More tests => 13; # increment this value for each test you create my $session = WebGUI::Test->session; # get a user so we can test retrieving messages for a specific user -my $user = WebGUI::User->new($session, 3); +my $admin = WebGUI::User->new($session, 3); # Begin tests by getting an inbox object my $inbox = WebGUI::Inbox->new($session); @@ -57,13 +57,69 @@ ok($message->getId == $messageId, 'getMessage returns message object'); ######################################################### # get a list (arrayref) of messages for a specific user # ######################################################### -my $messageList = $inbox->getMessagesForUser($user); +my $messageList = $inbox->getMessagesForUser($admin); my $message_cnt = scalar(@{$messageList}); is($message_cnt, 1, 'User only has 1 messages'); $message->setDeleted(3); -is(scalar(@{ $inbox->getMessagesForUser($user) }), 0, 'User has no undeleted messages'); +is(scalar(@{ $inbox->getMessagesForUser($admin) }), 0, 'User has no undeleted messages'); +$message->delete(3); + +######################################################### +# +# Check user filtering +# +######################################################### + +my @senders = (); + +push @senders, WebGUI::User->create($session); +push @senders, WebGUI::User->create($session); +push @senders, WebGUI::User->create($session); +$senders[0]->username('first'); +$senders[0]->profileField('firstName', 'First Only'); +$senders[1]->username('last'); +$senders[1]->profileField('lastName', 'Last Only'); +$senders[2]->username('wholename'); +$senders[2]->profileField('firstName', 'Tom'); +$senders[2]->profileField('lastName', 'Jones'); + +$inbox->addMessage({ + message => "First message", + userId => 3, + sentBy => $senders[0]->userId, +}); + +$inbox->addMessage({ + message => "Second message", + userId => 3, + sentBy => $senders[1]->userId, +}); + +$inbox->addMessage({ + message => "Third message", + userId => 3, + sentBy => $senders[2]->userId, +}); + +$inbox->addMessage({ + message => "Fourth message", + userId => 3, + sentBy => $senders[2]->userId, +}); + +is(scalar @{ $inbox->getMessagesForUser($admin) }, 4, 'Added 3 messages by various users'); +is(scalar @{ $inbox->getMessagesForUser($admin, '', '', '', 'sentBy='.$session->db->quote($senders[0]->userId)) }, 1, '1 message by sender[0]'); +is(scalar @{ $inbox->getMessagesForUser($admin, '', '', '', 'sentBy='.$session->db->quote($senders[1]->userId)) }, 1, '1 message by sender[1]'); +is(scalar @{ $inbox->getMessagesForUser($admin, '', '', '', 'sentBy='.$session->db->quote($senders[2]->userId)) }, 2, '2 messages by sender[2]'); END { $session->db->write('delete from inbox where messageId = ?', [$message->getId]); + foreach my $user (@senders) { + $user->delete; + } + foreach my $message (@{ $inbox->getMessagesForUser($admin, 1000) } ) { + $message->setDeleted(3); + $message->delete(3); + } } From 25482732199833ac1347492e73c69281c7281fbb Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 23 Feb 2009 12:28:13 -0800 Subject: [PATCH 6/8] Add UI for filtering based on sender. Adds a dropdown with JS on change for instant submit. Works with column sorting. --- lib/WebGUI/Account/Inbox.pm | 115 ++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/lib/WebGUI/Account/Inbox.pm b/lib/WebGUI/Account/Inbox.pm index 57d6b5af1..78ada8bca 100644 --- a/lib/WebGUI/Account/Inbox.pm +++ b/lib/WebGUI/Account/Inbox.pm @@ -223,7 +223,7 @@ sub editSettingsForm { label => $i18n->get("inbox rich editor label"), hoverHelp => $i18n->get("inbox rich editor description"), ); - + return $f->printRowsOnly; } @@ -575,7 +575,7 @@ sub www_deleteMessage { my $message = $inbox->getMessage($messageId); $self->store->{tab} = "inbox"; - + if (!(defined $message) || !$inbox->canRead($message)) { #View will handle displaying these errors return $self->www_viewMessage; @@ -593,7 +593,7 @@ sub www_deleteMessage { } } $message->delete; - + return $self->www_viewMessage($displayMessage->getId); } @@ -635,7 +635,7 @@ sub www_inviteUser { my $form = $session->form; my $setting = $session->setting; my $user = $session->user; - + my $displayError = shift; my $var = {}; @@ -644,11 +644,11 @@ sub www_inviteUser { #Add any error passed in to be displayed if the form reloads $var->{'message_display_error'} = $displayError; - + #Message From $var->{'message_from' } = $user->getWholeName; $var->{'message_from_id' } = $user->userId; - + #Message To $var->{'form_to' } = WebGUI::Form::email($session, { name => "to", @@ -699,7 +699,7 @@ sub www_inviteUser { action => $self->getUrl("module=inbox;do=inviteUserSave"), extras => q{name="inviteForm"} }); - + $var->{'submit_button' } = WebGUI::Form::submit($session,{}); $var->{'form_footer' } = WebGUI::Form::formFooter($session, {}); $var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_inbox_url'}; @@ -730,7 +730,7 @@ sub www_inviteUserSave { #Must have a person to send email to my $to = $form->get('to'); return $self->www_inviteUser($i18n->get('missing email')) unless $to; - + #Must have a subject my $defaultSubject = $setting->get("inboxInviteUserSubject"); WebGUI::Macro::process($session,\$defaultSubject); @@ -814,11 +814,11 @@ sub www_manageInvitations { my $i18n = WebGUI::International->new($session,'Account_Inbox'); $self->store->{tab} = "invitations"; - + #Deal with rows per page my $rpp = $session->form->get("rpp") || 25; my $rpp_url = ";rpp=$rpp"; - + #Cache the base url my $inboxUrl = $self->getUrl("op=account;module=inbox;do=manageInvitations"); @@ -830,15 +830,15 @@ sub www_manageInvitations { $rpp ); $p->setDataByQuery($sql,undef,undef,[$user->userId]); - + #Export page to template my @msg = (); foreach my $row ( @{$p->getPageData} ) { my $inviter = WebGUI::User->new($session,$row->{inviterId}); next if($inviter->isVisitor); # Inviter account got deleted - + my $epoch = WebGUI::DateTime->new(mysql => $row->{dateSent} )->epoch; - + my $hash = {}; $hash->{'invite_id' } = $row->{inviteId}; $hash->{'message_url' } = $self->getUrl("module=inbox;do=viewInvitation;inviteId=".$row->{inviteId}); @@ -854,7 +854,7 @@ sub www_manageInvitations { push(@msg,$hash); } my $msgCount = $p->getRowCount; - + $var->{'message_loop' } = \@msg; $var->{'has_messages' } = $msgCount > 0; $var->{'message_total' } = $msgCount; @@ -916,7 +916,7 @@ sub www_sendMessage { #Add common template variable for displaying the inbox my $inbox = WebGUI::Inbox->new($session); $self->appendCommonVars($var,$inbox); - + my $messageId = $form->get("messageId"); my $userId = $form->get("userId"); my $pageUrl = $session->url->page; @@ -926,7 +926,7 @@ sub www_sendMessage { if($messageId) { #This is a reply to a message - automate who the user is my $message = $inbox->getMessage($messageId); - + #Handle Errors if (!(defined $message)) { #Message doesn't exist @@ -973,14 +973,14 @@ sub www_sendMessage { $var->{'isInbox'} = "true"; return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId); } - + $var->{'isPrivateMessage'} = "true"; $var->{'message_to' } = $toUser->getWholeName; } else { #This is a new message $var->{'isNew' } = "true"; - + my $friends = $fromUser->friends->getUserList; my @checkedFriends = (); my @friendsChecked = $form->process("friend","checkList"); @@ -1018,7 +1018,7 @@ sub www_sendMessage { push (@friendsLoop, $friendHash); } - + #You can't send new messages if you don't have any friends to send to unless($activeFriendCount) { my $i18n = WebGUI::International->new($session,'Account_Inbox'); @@ -1030,9 +1030,9 @@ sub www_sendMessage { $var->{'friends_loop' } = \@friendsLoop; $var->{'checked_fiends_loop'} = \@checkedFriends; } - + $var->{'message_from' } = $fromUser->getWholeName; - + my $subject = $form->get("subject"); if($subject eq "" && $messageId) { $subject = "Re: ".$var->{'message_subject'}; @@ -1045,7 +1045,7 @@ sub www_sendMessage { }); $var->{'message_body' } = $form->get('message'); - + $var->{'form_message_text'} = WebGUI::Form::textarea($session, { name =>"message", value =>$var->{'message_body'} || "", @@ -1059,12 +1059,12 @@ sub www_sendMessage { width => "600", richEditId => $self->getRichEditorId, }); - + $var->{'form_header' } = WebGUI::Form::formHeader($session,{ action => $self->getUrl("module=inbox;do=sendMessageSave;messageId=$messageId;userId=$userId"), extras => q{name="messageForm"} }); - + $var->{'submit_button' } = WebGUI::Form::submit($session,{}); $var->{'form_footer' } = WebGUI::Form::formFooter($session, {}); $var->{'back_url' } = $backUrl; @@ -1093,7 +1093,7 @@ sub www_sendMessageSave { #Add common template variable for displaying the inbox my $inbox = WebGUI::Inbox->new($session); - + my $messageId = $form->get("messageId"); my $userId = $form->get("userId"); my @friends = $form->get("friend","checkList"); @@ -1182,11 +1182,11 @@ sub www_view { my $var = {}; $self->store->{tab} = "inbox"; - + #Deal with sort order my $sortBy = $session->form->get("sortBy") || undef; my $sort_url = ($sortBy)?";sortBy=$sortBy":""; - + #Deal with sort direction my $sortDir = $session->form->get("sortDir") || "desc"; my $sortDir_url = ";sortDir=".(($sortDir eq "desc")?"asc":"desc"); @@ -1194,26 +1194,37 @@ sub www_view { #Deal with rows per page my $rpp = $session->form->get("rpp") || 25; my $rpp_url = ";rpp=$rpp"; - + + #Deal with user filtering + my $userFilter = $session->form->get("userFilter") || 'all'; + my $userFilter_url = ";userFilter=$userFilter"; + #Cache the base url my $inboxUrl = $self->getUrl; + my $urlFrag = $sortDir_url . $rpp_url . $userFilter_url; + #Create sortBy headers - $var->{'subject_url' } = $inboxUrl.";sortBy=subject".$sortDir_url.$rpp_url; - $var->{'status_url' } = $inboxUrl.";sortBy=status".$sortDir_url.$rpp_url; - $var->{'from_url' } = $inboxUrl.";sortBy=sentBy".$sortDir_url.$rpp_url; - $var->{'dateStamp_url' } = $inboxUrl.";sortBy=dateStamp".$sortDir_url.$rpp_url; - $var->{'rpp_url' } = $inboxUrl.$sort_url.";sortDir=".$sortDir; - + $var->{'subject_url' } = $inboxUrl.";sortBy=subject" . $urlFrag; + $var->{'status_url' } = $inboxUrl.";sortBy=status" . $urlFrag; + $var->{'from_url' } = $inboxUrl.";sortBy=sentBy" . $urlFrag; + $var->{'dateStamp_url' } = $inboxUrl.";sortBy=dateStamp" . $urlFrag; + + $var->{'rpp_url' } = $inboxUrl.$sort_url.$sortDir_url.$userFilter_url; + #Create the paginator my $inbox = WebGUI::Inbox->new($session); - my $p = $inbox->getMessagesPaginator($session->user,{ + my $messageOptions = { sortBy => $sortBy, sortDir => $sortDir, - baseUrl => $inboxUrl.$sort_url.";sortDir=".$sortDir.$rpp_url, - paginateAfter => $rpp - }); - + baseUrl => $inboxUrl.$sort_url.$sortDir_url.$rpp_url.$userFilter_url, + paginateAfter => $rpp, + }; + if ($userFilter ne 'all') { + $messageOptions->{whereClause} = sprintf 'ibox.sentBy=%s', $session->db->quote($session->form->get('userFilter')); + } + my $p = $inbox->getMessagesPaginator($session->user, $messageOptions); + #Export page to template my @msg = (); foreach my $row ( @{$p->getPageData} ) { @@ -1242,7 +1253,7 @@ sub www_view { push(@msg,$hash); } my $msgCount = $p->getRowCount; - + $var->{'message_loop' } = \@msg; $var->{'has_messages' } = $msgCount > 0; $var->{'message_total' } = $msgCount; @@ -1258,6 +1269,20 @@ sub www_view { extras => q{onchange="location.href='}.$var->{'rpp_url'}.q{;rpp='+this.options[this.selectedIndex].value"} }); + my $userSql = $inbox->getMessageSql(undef, { 'select' => <new($session); + %userHash = ( 'all' => $i18n->echo('all users'), $session->db->buildHash($userSql) ); + $var->{'userFilter'} = WebGUI::Form::selectBox($session,{ + name => 'userFilter', + options => \%userHash, + value => $session->form->get('userFilter') || 'all', + extras => q{onchange="location.href='}.$inboxUrl.q{;userFilter='+this.options[this.selectedIndex].value"} + }); + $var->{'form_header'} = WebGUI::Form::formHeader($session,{ action => $self->getUrl("module=inbox;do=deleteMessages") }); @@ -1313,9 +1338,9 @@ sub www_viewInvitation { $var->{'isInvitation'} = "true"; return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId); } - + my $epoch = WebGUI::DateTime->new(mysql => $invitation->{dateSent} )->epoch; - + $var->{'invite_id' } = $inviteId; $var->{'message_from_id' } = $inviter->userId; $var->{'message_from' } = $inviter->getWholeName; @@ -1332,7 +1357,7 @@ sub www_viewInvitation { || $var->{'message_body'} =~ /\

{'message_body'} =~ s/\n/\
\n/g; } - + #Build the action URLs my $nextInvitation = $friends->getPreviousInvitation($invitation); #Messages sorted descending so next is actually previous if( $nextInvitation->{inviteId} ) { @@ -1388,7 +1413,7 @@ sub www_viewMessage { #Add common template variable for displaying the inbox $self->appendCommonVars($var,$inbox); - + #Handler Errors if (!(defined $message)) { my $i18n = WebGUI::International->new($session,'Account_Inbox'); @@ -1404,7 +1429,7 @@ sub www_viewMessage { $var->{'isInvitation'} = "true"; return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId); } - + $message->setStatus("read") unless ($message->isRead); $var->{'message_id' } = $messageId; From 2173a202f893c04637bf23796481e68e659b7565 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 23 Feb 2009 13:41:15 -0800 Subject: [PATCH 7/8] Add Help for new template variable, and i18n. --- lib/WebGUI/Account/Inbox.pm | 4 ++-- lib/WebGUI/Help/Account_Inbox.pm | 1 + lib/WebGUI/i18n/English/Account_Inbox.pm | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Account/Inbox.pm b/lib/WebGUI/Account/Inbox.pm index 78ada8bca..87ad58f65 100644 --- a/lib/WebGUI/Account/Inbox.pm +++ b/lib/WebGUI/Account/Inbox.pm @@ -1274,8 +1274,8 @@ ibox.sentBy, (IF(userProfileData.firstName != '' and userProfileData.firstName is not null and userProfileData.lastName !='' and userProfileData.lastName is not null, concat(userProfileData.firstName,' ',userProfileData.lastName),users.username)) as fullName EOSQL tie my %userHash, 'Tie::IxHash'; - my $i18n = WebGUI::International->new($session); - %userHash = ( 'all' => $i18n->echo('all users'), $session->db->buildHash($userSql) ); + my $i18n = WebGUI::International->new($session, 'Account_Inbox'); + %userHash = ( 'all' => $i18n->get('All users'), $session->db->buildHash($userSql) ); $var->{'userFilter'} = WebGUI::Form::selectBox($session,{ name => 'userFilter', options => \%userHash, diff --git a/lib/WebGUI/Help/Account_Inbox.pm b/lib/WebGUI/Help/Account_Inbox.pm index 99231a5ec..ed431ae2a 100644 --- a/lib/WebGUI/Help/Account_Inbox.pm +++ b/lib/WebGUI/Help/Account_Inbox.pm @@ -23,6 +23,7 @@ our $HELP = { { name => 'invitations_enabled', }, { name => 'user_invitations_enabled', }, { name => 'invite_friend_url', }, + { name => 'userFilter', }, ], related => [ ], }, diff --git a/lib/WebGUI/i18n/English/Account_Inbox.pm b/lib/WebGUI/i18n/English/Account_Inbox.pm index bd13a590e..2da36616b 100644 --- a/lib/WebGUI/i18n/English/Account_Inbox.pm +++ b/lib/WebGUI/i18n/English/Account_Inbox.pm @@ -546,6 +546,19 @@ our $I18N = { lastUpdated => 0, context => "Description of Inbox setting", }, + + 'userFilter' => { + message => q{A select box form element to filter the list of messages by who sent them.}, + lastUpdated => 1235421123, + context => "Description of Inbox setting", + }, + + 'All users' => { + message => q{All users}, + lastUpdated => 1235421123, + context => "Default setting for filtering in the Inbox. Short for Show messages from all users.", + }, + }; 1; From 715d2ff6b6fd7c1a20ccf82f67d3c405d214a716 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 23 Feb 2009 13:43:28 -0800 Subject: [PATCH 8/8] New template with user filter. --- ...count_inbox_default-inbox-view-template.wgpkg | Bin 0 -> 2191 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 root_import_account_inbox_default-inbox-view-template.wgpkg diff --git a/root_import_account_inbox_default-inbox-view-template.wgpkg b/root_import_account_inbox_default-inbox-view-template.wgpkg new file mode 100644 index 0000000000000000000000000000000000000000..6f349707ae529dae37a23e5cd2746d2e9471e8c9 GIT binary patch literal 2191 zcmV;A2ypiwiwFP!00000|LqxRPa`>&&+{v+NV^?0kP89>gh({E1l>JD8g_d!9XVA_ za8oIlY*#`U^?%>@?7C8^YJ#?rRx3(MD)IBX58KbRwby?djmB=fy|#w$oo(}OZo``- zPh+jwY_=Qi-R<_y)*5Lx8?E*l0hHH&LZzt$(H!A%|Dl{;sF+mcU{nqsqnvsFVCw%8 z$VlB>`fiz#R_&V-{(mhl(Aq(N!@I!$&7Iw??VSI&cXyg=1g!b`&ujU=_WGj#3=V() z0!dg=T1Yx(6|ztM{A z_@U<|V8}9U=vRVp=y7$=+!WVmvpep)VrGaoQh=KKB2avpoS6Aceuk91bn}9+M=j|E zqi&Cm4PvFE9LWPs^gLjP{fdSe^>1`a?Qp+BlyqSH>nUQY>OAE2VaPqVKBxCWY`S8y z$)?QL`Tvj|>j(Wxw^O&2x_!UzKgSFv{rl+Rue z{ObDOeIM&%JV3a*W=esVj_;ZC@LoJt3G>(l@X0!fCL;nLRip8mPbZ8V9+G}#Vp02* zbt0J#rBAdB*@0z&SkdT+dMY0NZlLBX5kiac*kebYXM|vGl}&Yq`;ng{Y@iUG;umT{6Z-zry_>)cp$lx;y9oP(1dA z3mis5k}9&{K)rDQuTF+z&13#p-^1{)zh*Q7EmEoe{AiCpm=K+++8yXGu9lw%bOS6P3#dMSi&To%$b{mH6-%lI=(r0@o z{PyW;md*{OXA(vVq3e8t`C6xrBSHvoW3;-Vms2 z^9`+LcKnkRT41K-b9pR97+kuiF4q>Tm7*mKu&8u2a2uebz+;oaJ>&(GkTxBcPl*F{ zMnSUPodcs0_t-$PF&I-)%o<2W%s~@;(N_*D4Gh9vLnj>p+$?7NyAvc_hg2FCF)05| zMaS*JU<4I#fJxXTouMT45(Y@6qXOzDeD2OCY%*lX?CYhkne>f%)T`QYqPXv{jU(&0 z!6iof`oTZ_p$ZPZo>c$ww2_m1*@RefR^|8umV=!k3h8Y^e8ZRjo8L54c8dY5(IBl0Em&ID7KZ% z6!$p4N-82`K@#gp{TmEEo}3H@-Me$)x;^CKxw6^hz}b{Z z=3=NkTj>&UxWbcgS9oqM@W&ZRV5eqA5+Tfjx^m`ZrAaEY-JF_phTV2OlZVfxTw>jb zFk~ERpYX#J1Quoy`$4u9vWb1Wv`9u-wF+H09Au6LNtT!+!AhmB(26#k%S=}mwbqYi zkyJN#_I5hStVspupSRNqEM`%g z1sY-41jEw_w!{k05G2zhi<-{^(^G}TzXZdaJmN-YytG5-lzLr~+qXwhVkmCBTj=^h zv#FSY?c!x?rGC5JOKWZPIf8o=L9ZYC`>W|B=p{|9? zM;tDgu$$a$ZMCc|Dtz&wX8Z`(Akq0CJj zI(5!N5>6T0-iz6#e+E%%FZh}%2+!G&xQ?Y7rApnnw{9GmTwyTZk@LW`dyE7b=`