From b0c7c1162dfa2280faa5372e29fcbc76e91d35cf Mon Sep 17 00:00:00 2001 From: khenn Date: Thu, 13 May 2010 17:15:41 -0500 Subject: [PATCH] Added sendNotification flag to WebGUI::Friends::rejectAddRequest. Added setting which supresses friend rejection notices from the inbox. --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.9.4-7.9.5.pl | 10 ++++++++ lib/WebGUI/Account/Inbox.pm | 9 ++++++- lib/WebGUI/Friends.pm | 25 +++++++++++++------ .../Activity/DenyUnansweredFriends.pm | 2 +- lib/WebGUI/i18n/English/Account_Inbox.pm | 14 ++++++++++- 6 files changed, 50 insertions(+), 11 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 6736c0f9d..ad26621bc 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -15,6 +15,7 @@ - fixed #11540: Pending version tags are not completed on approval under certain conditions - fixed #11566: Group API: group membership cannot be checked without consideration of expiration dates. - fixed #11567: EMS: Build badge page, ticket tab, pagination + - added: a new inbox setting which allows administrators to choose not to send out friend rejection notices 7.9.4 - We're shipping underscore.js now for its suite of extremely handy utility diff --git a/docs/upgrades/upgrade_7.9.4-7.9.5.pl b/docs/upgrades/upgrade_7.9.4-7.9.5.pl index d0f03e388..a39f8dc46 100644 --- a/docs/upgrades/upgrade_7.9.4-7.9.5.pl +++ b/docs/upgrades/upgrade_7.9.4-7.9.5.pl @@ -34,6 +34,7 @@ my $session = start(); # this line required # upgrade functions go here modifySortItems( $session ); fixRequestForApprovalScratch($session); +addRejectNoticeSetting($session); finish($session); # this line required @@ -46,6 +47,15 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +#---------------------------------------------------------------------------- +# Adds setting which allows users to set whether or not to send reject notices +sub addRejectNoticeSetting { + my $session = shift; + print "\tAdding reject notice setting... " unless $quiet; + $session->setting->add('sendRejectNotice',1); + print "DONE!\n" unless $quiet; +} + #---------------------------------------------------------------------------- # Describe what our function does sub fixRequestForApprovalScratch { diff --git a/lib/WebGUI/Account/Inbox.pm b/lib/WebGUI/Account/Inbox.pm index 560d05608..609f78416 100644 --- a/lib/WebGUI/Account/Inbox.pm +++ b/lib/WebGUI/Account/Inbox.pm @@ -237,6 +237,12 @@ sub editSettingsForm { hoverHelp => $i18n->get('send inbox notifications only help'), defaultValue => $setting->get('sendInboxNotificationsOnly'), ); + $f->yesNo( + name => 'sendRejectNotice', + label => $i18n->get('send reject notice'), + hoverHelp => $i18n->get('send reject notice help'), + defaultValue => $setting->get('sendRejectNotice'), + ); $f->text( name => 'inboxNotificationsSubject', label => $i18n->get('inbox notifications subject'), @@ -305,6 +311,7 @@ sub editSettingsFormSave { $setting->set("inboxNotificationsSubject", $form->process("inboxNotificationsSubject", "text")); $setting->set("inboxNotificationTemplateId", $form->process("inboxNotificationTemplateId","template")); $setting->set("inboxSmsNotificationTemplateId", $form->process("inboxSmsNotificationTemplateId","template")); + $setting->set("sendRejectNotice", $form->process("sendRejectNotice","yesNo")); } @@ -604,7 +611,7 @@ sub www_approveDenyInvitations { next unless ($invite->{inviterId}); #Not sure how this could ever happen, but check for it next unless ($session->user->userId eq $invite->{friendId}); #Protect against malicious stuff if($deny) { - $friends->rejectAddRequest($inviteId); + $friends->rejectAddRequest($inviteId,$session->setting->get("sendRejectNotice")); } elsif($approve) { $friends->approveAddRequest($inviteId); diff --git a/lib/WebGUI/Friends.pm b/lib/WebGUI/Friends.pm index e3c6a4d0f..a8fbdea9f 100644 --- a/lib/WebGUI/Friends.pm +++ b/lib/WebGUI/Friends.pm @@ -288,7 +288,7 @@ sub new { #------------------------------------------------------------------- -=head2 rejectAddRequest ( inviteId ) +=head2 rejectAddRequest ( inviteId[,sendNotification] ) Sends a rejection notice, and deletes the invitation. @@ -296,21 +296,30 @@ Sends a rejection notice, and deletes the invitation. The id of an invitation. +=head3 sendNotification + +Boolean indicating whether or not to send out the deny notification. Defaults to true + =cut sub rejectAddRequest { - my $self = shift; + my $self = shift; my $inviteId = shift; + my $notify = shift; + my $db = $self->session->db; my $invite = $self->getAddRequest($inviteId); my $i18n = WebGUI::International->new($self->session, "Friends"); my $inbox = WebGUI::Inbox->new($self->session); - $inbox->addMessage({ - message => sprintf($i18n->get("friends invitation not accepted by user"), $self->user->getWholeName), - subject => $i18n->get('friends invitation not accepted'), - userId => $invite->{inviterId}, - status => 'unread', - }); + + unless (defined $notify && !$notify) { #Notify is defined but not true + $inbox->addMessage({ + message => sprintf($i18n->get("friends invitation not accepted by user"), $self->user->getWholeName), + subject => $i18n->get('friends invitation not accepted'), + userId => $invite->{inviterId}, + status => 'unread', + }); + } $inbox->getMessage($invite->{messageId})->setStatus('completed'); $self->session->db->deleteRow("friendInvitations", "inviteId", $inviteId); } diff --git a/lib/WebGUI/Workflow/Activity/DenyUnansweredFriends.pm b/lib/WebGUI/Workflow/Activity/DenyUnansweredFriends.pm index 990a5ffa1..d3efa337c 100644 --- a/lib/WebGUI/Workflow/Activity/DenyUnansweredFriends.pm +++ b/lib/WebGUI/Workflow/Activity/DenyUnansweredFriends.pm @@ -87,7 +87,7 @@ sub execute { while (my $invite = $pending->hashRef) { my $sentOn = WebGUI::DateTime->new($session, $invite->{dateSent}); if (DateTime::Duration->compare($now - $sentOn, $outdated) == 1) { - WebGUI::Friends->new($session, WebGUI::User->new($session, $invite->{friendId}))->rejectAddRequest($invite->{inviteId}); + WebGUI::Friends->new($session, WebGUI::User->new($session, $invite->{friendId}))->rejectAddRequest($invite->{inviteId},,$session->setting->get("sendRejectNotice")); } if (time() - $start > $ttl) { $pending->finish; diff --git a/lib/WebGUI/i18n/English/Account_Inbox.pm b/lib/WebGUI/i18n/English/Account_Inbox.pm index 1bf5849bf..775593448 100644 --- a/lib/WebGUI/i18n/English/Account_Inbox.pm +++ b/lib/WebGUI/i18n/English/Account_Inbox.pm @@ -431,7 +431,7 @@ our $I18N = { }, 'invitation confirm message' => { - message => q{The following users were notified:}, + message => q{The following actions were taken:}, lastUpdated => 1225724810, }, @@ -818,6 +818,18 @@ our $I18N = { lastUpdated => 1242274703, }, + + 'send reject notice' => { + message => q|Send Reject Friend Notifications|, + context => q|Site setting. A notification is an email that is sent to the user being rejected.|, + lastUpdated => 1242274705, + }, + + 'send reject notice help' => { + message => q|Choose whether or not, upon rejecting a friend request, a notification should be sent to the user being rejected.|, + lastUpdated => 1242274703, + }, + }; 1;