[dw-free] Default View/Default filters should be default when adding from hover menu
[commit: http://hg.dwscoalition.org/dw-free/rev/9988329bc67f]
http://bugs.dwscoalition.org/show_bug.cgi?id=2344
Always add new subscriptions to default filters.
Patch by
afuna.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2344
Always add new subscriptions to default filters.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/User/ContentFilters/Filter.pm
- htdocs/manage/circle/add.bml
- htdocs/tools/endpoints/changerelation.bml
-------------------------------------------------------------------------------- diff -r 9c1befb01566 -r 9988329bc67f cgi-bin/DW/User/ContentFilters/Filter.pm --- a/cgi-bin/DW/User/ContentFilters/Filter.pm Fri Apr 02 03:46:01 2010 +0000 +++ b/cgi-bin/DW/User/ContentFilters/Filter.pm Fri Apr 02 11:27:37 2010 -0500 @@ -186,6 +186,13 @@ sub contains_userid { return 0; } +# check whether this filter qualifies as a default filter. Case-insensitive. +# e.g., Default, Default View, etc +sub is_default { + my $name = lc( $_[0]->{name} ); + return 1 if $name eq "default" || $name eq "default view"; + return 0; +} # called with an item hashref or LJ::Entry object, determines whether or not this # filter allows this entry to be shown diff -r 9c1befb01566 -r 9988329bc67f htdocs/manage/circle/add.bml --- a/htdocs/manage/circle/add.bml Fri Apr 02 03:46:01 2010 +0000 +++ b/htdocs/manage/circle/add.bml Fri Apr 02 11:27:37 2010 -0500 @@ -272,7 +272,8 @@ _c?> $body .= "$ML{'.groups.reading'} p?>\n"; my @sorted_content_filters = sort { $a->{sortorder} <=> $b->{sortorder} } @content_filters; foreach my $filter ( @sorted_content_filters ) { - my $ck = ( $filter->contains_userid( $u->userid ) ); + my $ck = ( $filter->contains_userid( $u->userid ) ) + || ( $action eq "subscribe" && ! $watched && $filter->is_default() ); my $fid = $filter->id; $body .= LJ::html_check( { name => "content_$fid", id => "content_$fid", diff -r 9c1befb01566 -r 9988329bc67f htdocs/tools/endpoints/changerelation.bml --- a/htdocs/tools/endpoints/changerelation.bml Fri Apr 02 03:46:01 2010 +0000 +++ b/htdocs/tools/endpoints/changerelation.bml Fri Apr 02 11:27:37 2010 -0500 @@ -58,6 +58,16 @@ _c?> unless $remote->can_watch( $targetu, errref => \$error ); $success = $remote->add_edge( $targetu, watch => {} ); + + if ( $success ) { + my @content_filters = $remote->content_filters; + foreach my $filter ( @content_filters ) { + next unless $filter->is_default(); + next if $filter->contains_userid( $targetu->userid ); + + $success = $filter->add_row( userid => $targetu->userid ) && $success; + } + } } elsif ( $action eq 'removeTrust' ) { $success = $remote->remove_edge( $targetu, trust => {} ); } elsif ( $action eq 'removeWatch' ) { --------------------------------------------------------------------------------