fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2012-03-29 06:41 am

[dw-free] add system notices filter to inbox

[commit: http://hg.dwscoalition.org/dw-free/rev/622fda33b130]

http://bugs.dwscoalition.org/show_bug.cgi?id=2234

Add a filter "Site Notices", with the events: import status, official post
notifications, security attribute changed, user expunged, vgift approved,
crosspost success & failure.

Patch by [personal profile] ninetydegrees.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/LJ/NotificationInbox.pm
  • cgi-bin/LJ/Widget/InboxFolderNav.pm
--------------------------------------------------------------------------------
diff -r fc8e704f0211 -r 622fda33b130 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Thu Mar 29 14:33:56 2012 +0800
+++ b/bin/upgrading/en.dat	Thu Mar 29 14:42:48 2012 +0800
@@ -1837,6 +1837,8 @@
 
 inbox.menu.sent=Sent
 
+inbox.menu.site_notices=Site Notices
+
 inbox.menu.unread=Unread
 
 inbox.message=Message
diff -r fc8e704f0211 -r 622fda33b130 cgi-bin/LJ/NotificationInbox.pm
--- a/cgi-bin/LJ/NotificationInbox.pm	Thu Mar 29 14:33:56 2012 +0800
+++ b/cgi-bin/LJ/NotificationInbox.pm	Thu Mar 29 14:42:48 2012 +0800
@@ -177,6 +177,15 @@
     return grep { $community_events{$_->event->class} } $self->items;
 }
 
+sub sitenotices_items {
+    my $self = shift;
+
+    my @site_events = sitenotices_event_list();
+
+    my %site_events = map { "LJ::Event::" . $_ => 1 } @site_events;
+    return grep { $site_events{$_->event->class} } $self->items;
+}
+
 # return a subset of notificationitems
 sub subset_items {
     my ($self, @subset) = @_;
@@ -596,6 +605,8 @@
         @items = $self->pollvote_items;
     } elsif ( $view eq 'communitymembership' ) {
         @items = $self->communitymembership_items;
+    } elsif ( $view eq 'sitenotices' ) {
+        @items = $self->sitenotices_items;
     } elsif ( $view eq 'unread' ) {
         @items = $self->unread_items;
     }
@@ -648,6 +659,8 @@
         @items = $self->pollvote_items;
     } elsif ( $view eq 'communitymembership' ) {
         @items = $self->communitymembership_items;
+    } elsif ( $view eq 'sitenotices' ) {
+        @items = $self->sitenotices_items;
     } elsif ( $view eq 'unread' ) {
         @items = $self->unread_items;
     }
@@ -747,6 +760,11 @@
     return $self->subset_unread_count(communitymembership_event_list());
 }
 
+sub sitenotices_event_count {
+    my $self = shift;
+    return $self->subset_unread_count(sitenotices_event_list());
+}
+
 # Methods that return Arrays of Event categories
 sub friend_event_list {
     my @events = qw(
@@ -783,4 +801,17 @@
     return @events;
 }
 
+sub sitenotices_event_list {
+    my @events = (
+        'ImportStatus',
+        'OfficialPost',
+        'SecurityAttributeChanged',
+        'UserExpunged',
+        'VgiftApproved',
+        'XPostFailure',
+        'XPostSuccess'
+    );
+    return @events;
+}
+
 1;
diff -r fc8e704f0211 -r 622fda33b130 cgi-bin/LJ/Widget/InboxFolderNav.pm
--- a/cgi-bin/LJ/Widget/InboxFolderNav.pm	Thu Mar 29 14:33:56 2012 +0800
+++ b/cgi-bin/LJ/Widget/InboxFolderNav.pm	Thu Mar 29 14:42:48 2012 +0800
@@ -91,6 +91,7 @@
     $body .= $subfolder_link->( "entrycomment", "inbox.menu.entries_and_comments", "subs", $unread_html->( $inbox->entrycomment_event_count ) );
     $body .= $subfolder_link->( "pollvote", "inbox.menu.poll_votes", "subs", $unread_html->( $inbox->pollvote_event_count ) );
     $body .= $subfolder_link->( "communitymembership", "inbox.menu.community_membership", "subs", $unread_html->( $inbox->communitymembership_event_count ) );
+    $body .= $subfolder_link->( "sitenotices", "inbox.menu.site_notices", "subs", $unread_html->( $inbox->sitenotices_event_count ) );
     $body .= qq{<span class="subs">---</span>\n};
     $body .= $subfolder_link->( "unread", "inbox.menu.unread", "subs", $unread_all_html );
     $body .= $subfolder_link->( "bookmark", "inbox.menu.bookmarks", "subs", "", LJ::img( 'flag', '' ) );
--------------------------------------------------------------------------------