Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[livejournal] r20880: LJSUP-10910: View comments in My Style s...

Committer: anazarov
LJSUP-10910: View comments in My Style setting
U   trunk/cgi-bin/LJ/S2.pm
U   trunk/cgi-bin/LJ/Setting/CommentsStyleMine.pm
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2012-01-10 12:54:21 UTC (rev 20879)
+++ trunk/cgi-bin/LJ/S2.pm	2012-01-10 13:19:28 UTC (rev 20880)
@@ -98,10 +98,39 @@
             return;
         }
 
-        if ( LJ::is_enabled('commentsstylemine') and $view eq 'entry' || $view eq 'reply' ) {
+        if ( LJ::is_enabled('comments_style_mine') and $view eq 'entry' || $view eq 'reply' ) {
             if ( $remote and not $remote->opt_stylealwaysmine and $remote->opt_commentsstylemine ) {
-                ${$opts->{'handle_with_bml_ref'}} = 1;
-                return;
+                my $get_styleinfo = sub {
+                    my $journal = shift;
+
+                    my @needed_props = ("stylesys", "s2_style");
+                    LJ::load_user_props($journal, @needed_props);
+
+                    my $forceflag = 0;
+                    LJ::run_hooks("force_s1", $journal, \$forceflag);
+                    if ( !$forceflag && $journal->{'stylesys'} == 2 ) {
+                        return (2, $journal->{'s2_style'});
+                    }
+
+                    return (1, 0);
+                };
+
+                my ($stylesys, $styleid) = $get_styleinfo->($remote);
+
+                my $use_s1 = 1;
+                my $ctx = undef;
+                if ($stylesys == 2) {
+                    $ctx = LJ::S2::s2_context('UNUSED', $styleid);
+                    $LJ::S2::CURR_CTX = $ctx;
+
+                    $use_s1 = 0 if !$ctx->[S2::PROPS]->{'view_entry_disabled'} &&
+                                   LJ::get_cap($remote, "s2viewentry");
+                }
+
+                if ( $use_s1 ) {
+                    ${$opts->{'handle_with_bml_ref'}} = 1;
+                    return;
+                }
             }
         }
     }

Modified: trunk/cgi-bin/LJ/Setting/CommentsStyleMine.pm
===================================================================
--- trunk/cgi-bin/LJ/Setting/CommentsStyleMine.pm	2012-01-10 12:54:21 UTC (rev 20879)
+++ trunk/cgi-bin/LJ/Setting/CommentsStyleMine.pm	2012-01-10 13:19:28 UTC (rev 20880)
@@ -5,8 +5,38 @@
 
 sub should_render {
     my ($class, $u) = @_;
+    return 0 unless $u;
+    return 0 unless LJ::is_enabled('comments_style_mine');
+    return 0 unless $u->is_personal;
 
-    return LJ::is_enabled("comments_style_mine") && $u && $u->is_personal ? 1 : 0;
+    my $get_styleinfo = sub {
+        my $journal = shift;
+
+        my @needed_props = ("stylesys", "s2_style");
+        LJ::load_user_props($journal, @needed_props);
+
+        my $forceflag = 0;
+        LJ::run_hooks("force_s1", $journal, \$forceflag);
+        if ( !$forceflag && $journal->{'stylesys'} == 2 ) {
+            return (2, $journal->{'s2_style'});
+        }
+
+        return (1, 0);
+    };
+
+    my ($stylesys, $styleid) = $get_styleinfo->($u);
+
+    my $use_s1 = 1;
+    my $ctx = undef;
+    if ($stylesys == 2) {
+        $ctx = LJ::S2::s2_context('UNUSED', $styleid);
+        $LJ::S2::CURR_CTX = $ctx;
+
+        $use_s1 = 0 if !$ctx->[S2::PROPS]->{'view_entry_disabled'} &&
+                       LJ::get_cap($u, "s2viewentry");
+    }
+
+    return $use_s1? 1 : 0;
 }
 
 sub label {

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-01-10 12:54:21 UTC (rev 20879)
+++ trunk/cgi-bin/LJ/User.pm	2012-01-10 13:19:28 UTC (rev 20880)
@@ -4102,7 +4102,7 @@
 }
 
 sub can_use_commentsstylemine {
-    return 0 unless LJ::is_enabled('commentsstylemine');
+    return 0 unless LJ::is_enabled('comments_style_mine');
     return 1;
 }
 

Tags: anazarov, livejournal, nfokz, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments