Allow viewing s2id=XYZ for anybody if XYZ is entirely public.

        Patch by afuna. 

diffs (48 lines):

diff -r 54b7f59afe74 -r 85021e82c86e cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm  Thu Dec 03 05:31:37 2009 +0000
+++ b/cgi-bin/LJ/S2.pm  Thu Dec 03 05:34:55 2009 +0000
@@ -461,6 +461,22 @@ sub is_public_internal_layer {
         $layerid = $pub->{$layerid}->{b2lid};
     }
     return 0;
+}
+
+# whether all layers in this style are public
+sub style_is_public {
+    my $style = $_[0];
+    return 0 unless $style;
+
+    my %lay_info;
+    LJ::S2::load_layer_info( \%lay_info, [ $style->{layer}->{layout}, 
$style->{layer}->{theme}, $style->{layer}->{user}, $style->{layer}->{i18n}, 
$style->{layer}->{i18nc} ] );
+
+    my $pub = get_public_layers();
+    while ( my ( $layerid, $layerinfo ) = each %lay_info ) {
+        return 0 unless $pub->{$layerid} || $layerinfo->{is_public};
+    }
+
+    return 1;
 }
 
 # find existing re-distributed layers that are in the database
diff -r 54b7f59afe74 -r 85021e82c86e cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm        Thu Dec 03 05:31:37 2009 +0000
+++ b/cgi-bin/LJ/User.pm        Thu Dec 03 05:34:55 2009 +0000
@@ -8160,7 +8160,8 @@ sub make_journal
 
                 # remote can use s2id on this journal if:
                 # owner of the style is remote or managed by remote OR
-                # owner of the style has s2styles cap and remote is viewing 
owner's journal
+                # owner of the style has s2styles cap and remote is viewing 
owner's journal OR
+                # all layers in this style are public (public layer or 
is_public)
 
                 if ($u->id == $owner && $u->get_cap("s2styles")) {
                     $opts->{'style_u'} = LJ::load_userid($owner);
@@ -8180,6 +8181,8 @@ sub make_journal
                         return (2, $geta->{'s2id'});
                     } # else this style not allowed by policy
                 }
+
+                return ( 2, $geta->{s2id} ) if LJ::S2::style_is_public( $style 
);
             }
 
             # style=mine passed in GET?
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to