Added sendNotification flag to WebGUI::Friends::rejectAddRequest. Added setting which supresses friend rejection notices from the inbox.

This commit is contained in:
khenn 2010-05-13 17:15:41 -05:00
parent 6dbd389c86
commit b0c7c1162d
6 changed files with 50 additions and 11 deletions

View file

@ -15,6 +15,7 @@
- fixed #11540: Pending version tags are not completed on approval under certain conditions - 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 #11566: Group API: group membership cannot be checked without consideration of expiration dates.
- fixed #11567: EMS: Build badge page, ticket tab, pagination - 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 7.9.4
- We're shipping underscore.js now for its suite of extremely handy utility - We're shipping underscore.js now for its suite of extremely handy utility

View file

@ -34,6 +34,7 @@ my $session = start(); # this line required
# upgrade functions go here # upgrade functions go here
modifySortItems( $session ); modifySortItems( $session );
fixRequestForApprovalScratch($session); fixRequestForApprovalScratch($session);
addRejectNoticeSetting($session);
finish($session); # this line required finish($session); # this line required
@ -46,6 +47,15 @@ finish($session); # this line required
# print "DONE!\n" unless $quiet; # 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 # Describe what our function does
sub fixRequestForApprovalScratch { sub fixRequestForApprovalScratch {

View file

@ -237,6 +237,12 @@ sub editSettingsForm {
hoverHelp => $i18n->get('send inbox notifications only help'), hoverHelp => $i18n->get('send inbox notifications only help'),
defaultValue => $setting->get('sendInboxNotificationsOnly'), 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( $f->text(
name => 'inboxNotificationsSubject', name => 'inboxNotificationsSubject',
label => $i18n->get('inbox notifications subject'), label => $i18n->get('inbox notifications subject'),
@ -305,6 +311,7 @@ sub editSettingsFormSave {
$setting->set("inboxNotificationsSubject", $form->process("inboxNotificationsSubject", "text")); $setting->set("inboxNotificationsSubject", $form->process("inboxNotificationsSubject", "text"));
$setting->set("inboxNotificationTemplateId", $form->process("inboxNotificationTemplateId","template")); $setting->set("inboxNotificationTemplateId", $form->process("inboxNotificationTemplateId","template"));
$setting->set("inboxSmsNotificationTemplateId", $form->process("inboxSmsNotificationTemplateId","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 ($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 next unless ($session->user->userId eq $invite->{friendId}); #Protect against malicious stuff
if($deny) { if($deny) {
$friends->rejectAddRequest($inviteId); $friends->rejectAddRequest($inviteId,$session->setting->get("sendRejectNotice"));
} }
elsif($approve) { elsif($approve) {
$friends->approveAddRequest($inviteId); $friends->approveAddRequest($inviteId);

View file

@ -288,7 +288,7 @@ sub new {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 rejectAddRequest ( inviteId ) =head2 rejectAddRequest ( inviteId[,sendNotification] )
Sends a rejection notice, and deletes the invitation. 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. The id of an invitation.
=head3 sendNotification
Boolean indicating whether or not to send out the deny notification. Defaults to true
=cut =cut
sub rejectAddRequest { sub rejectAddRequest {
my $self = shift; my $self = shift;
my $inviteId = shift; my $inviteId = shift;
my $notify = shift;
my $db = $self->session->db; my $db = $self->session->db;
my $invite = $self->getAddRequest($inviteId); my $invite = $self->getAddRequest($inviteId);
my $i18n = WebGUI::International->new($self->session, "Friends"); my $i18n = WebGUI::International->new($self->session, "Friends");
my $inbox = WebGUI::Inbox->new($self->session); my $inbox = WebGUI::Inbox->new($self->session);
$inbox->addMessage({
message => sprintf($i18n->get("friends invitation not accepted by user"), $self->user->getWholeName), unless (defined $notify && !$notify) { #Notify is defined but not true
subject => $i18n->get('friends invitation not accepted'), $inbox->addMessage({
userId => $invite->{inviterId}, message => sprintf($i18n->get("friends invitation not accepted by user"), $self->user->getWholeName),
status => 'unread', subject => $i18n->get('friends invitation not accepted'),
}); userId => $invite->{inviterId},
status => 'unread',
});
}
$inbox->getMessage($invite->{messageId})->setStatus('completed'); $inbox->getMessage($invite->{messageId})->setStatus('completed');
$self->session->db->deleteRow("friendInvitations", "inviteId", $inviteId); $self->session->db->deleteRow("friendInvitations", "inviteId", $inviteId);
} }

View file

@ -87,7 +87,7 @@ sub execute {
while (my $invite = $pending->hashRef) { while (my $invite = $pending->hashRef) {
my $sentOn = WebGUI::DateTime->new($session, $invite->{dateSent}); my $sentOn = WebGUI::DateTime->new($session, $invite->{dateSent});
if (DateTime::Duration->compare($now - $sentOn, $outdated) == 1) { 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) { if (time() - $start > $ttl) {
$pending->finish; $pending->finish;

View file

@ -431,7 +431,7 @@ our $I18N = {
}, },
'invitation confirm message' => { 'invitation confirm message' => {
message => q{The following users were notified:}, message => q{The following actions were taken:},
lastUpdated => 1225724810, lastUpdated => 1225724810,
}, },
@ -818,6 +818,18 @@ our $I18N = {
lastUpdated => 1242274703, 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; 1;