diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 462a7008e..1fa5716d7 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -23,6 +23,7 @@ elements (eg. check lists) only one of the selected elements was taken into account in the search query. ( Martin Kamerbeek / Oqapi ) - fixed #10439: Call to insufficient is wrong (lrobinson / Orchard Solutions ) + - fixed #10373: Admin groups inbox messages linger after task complete - fixed a bug in Thingy where the defaultValue of multi value form elements would not be applied ( Martin Kamerbeek / Oqapi ) diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 764ddecba..a80955280 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -8,6 +8,16 @@ versions. Be sure to heed the warnings contained herein as they will save you many hours of grief. +7.7.8 +-------------------------------------------------------------------- + * A basic behavior of the Inbox has been changed. If a message is + sent to a Group of WebGUI users, and any member of the group reads + the message, then that message is marked as read by all members. This + most often happens for commit reminders for version tags that require + approval. The old behavior often resulted in several users trying + to approve version tags that had already been approved. + + 7.7.7 -------------------------------------------------------------------- * WebGUI now requires Digest::SHA. diff --git a/docs/upgrades/upgrade_7.7.7-7.7.8.pl b/docs/upgrades/upgrade_7.7.7-7.7.8.pl index 3a3066094..fb7434706 100644 --- a/docs/upgrades/upgrade_7.7.7-7.7.8.pl +++ b/docs/upgrades/upgrade_7.7.7-7.7.8.pl @@ -31,6 +31,7 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +messageStateCleanup($session); finish($session); # this line required @@ -44,6 +45,37 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +#---------------------------------------------------------------------------- + +sub messageStateCleanup { + my $session = shift; + my $db = $session->db; + + # Acquire messageIds to fine orphans (no inbox message associated) and those with group delivered system messages marked as completed + # + my $messageListRef = $db->buildArrayRef("SELECT distinct messageId FROM inbox_messageState WHERE isRead=0 AND deleted = 0"); + my $sth = $db->read("SELECT status,groupId FROM inbox WHERE messageId=?"); + for my $messageId (@$messageListRef) { + $sth->execute([$messageId]); + my $rows = $sth->rows; + + # No reference to any current message in the inbox + # + if ( !$rows ) { + $db->write( "DELETE FROM inbox_messageState WHERE messageId=?", [$messageId] ); + } + else { + # test messages for values of completed status and group delivery + # + while ( my ( $status, $groupId ) = $sth->array ) { + next if $status ne "completed" || !$groupId; + $db->write( "UPDATE inbox_messageState SET isRead=1 WHERE messageId=?", [$messageId] ); + } + } + } ## end for my $messageId (@$messageListRef) + $sth->finish; +} ## end sub messageStateCleanup + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/lib/WebGUI/Inbox/Message.pm b/lib/WebGUI/Inbox/Message.pm index cb13dd034..41850fc51 100644 --- a/lib/WebGUI/Inbox/Message.pm +++ b/lib/WebGUI/Inbox/Message.pm @@ -428,8 +428,8 @@ sub setCompleted { $self->{_inbox}{completedBy} = $userId; $self->{_inbox}{completedOn} = time(); $self->session->db->setRow("inbox","messageId",$self->{_inbox}); - #Completed messages should also be marked read - $self->setRead($userId); + #Completed messages should also be marked read for all users connected to this message + $self->setReadAll; } #------------------------------------------------------------------- @@ -478,6 +478,23 @@ sub setRead { #------------------------------------------------------------------- +=head2 setReadAll ( ) + +Marks a message read for all users who are connected to this message + +=cut + +sub setReadAll { + my $self = shift; + + $self->session->db->write( + q{update inbox_messageState set isRead=1 where messageId=?}, + [$self->getId] + ); +} + +#------------------------------------------------------------------- + =head2 setReplied ( [ userId ] ) Marks a message replied.