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

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

Committer: anazarov
LJSUP-10910: View comments in My Style setting
U   trunk/bin/upgrading/en.dat
U   trunk/bin/upgrading/proplists.dat
A   trunk/cgi-bin/LJ/Setting/CommentsStyleMine.pm
U   trunk/cgi-bin/LJ/User.pm
U   trunk/htdocs/manage/settings/index.bml
Modified: trunk/bin/upgrading/en.dat
===================================================================
--- trunk/bin/upgrading/en.dat	2012-01-10 09:08:39 UTC (rev 20877)
+++ trunk/bin/upgrading/en.dat	2012-01-10 12:52:27 UTC (rev 20878)
@@ -4710,6 +4710,9 @@
 setting.commentscreening.option.select.nonmembers|staleness=1
 setting.commentscreening.option.select.nonmembers=comments from non-members
 
+setting.commentsstylemine.label=Comments style
+setting.commentsstylemine.option=View comments in my style
+
 setting.contentpromotion.label|staleness=1
 setting.contentpromotion.label=Content Promotion
 

Modified: trunk/bin/upgrading/proplists.dat
===================================================================
--- trunk/bin/upgrading/proplists.dat	2012-01-10 09:08:39 UTC (rev 20877)
+++ trunk/bin/upgrading/proplists.dat	2012-01-10 12:52:27 UTC (rev 20878)
@@ -798,6 +798,14 @@
   multihomed: 0
   prettyname: Always my Style
 
+userproplist.opt_commentsstylemine:
+  cldversion: 8
+  datatype: char
+  des: 1: always use user style when viewing comments in any journal
+  indexed: 0
+  multihomed: 0
+  prettyname: Comments always in my Style
+
 userproplist.opt_stylemine:
   cldversion: 4
   datatype: bool

Added: trunk/cgi-bin/LJ/Setting/CommentsStyleMine.pm
===================================================================
--- trunk/cgi-bin/LJ/Setting/CommentsStyleMine.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Setting/CommentsStyleMine.pm	2012-01-10 12:52:27 UTC (rev 20878)
@@ -0,0 +1,50 @@
+package LJ::Setting::CommentsStyleMine;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+
+sub should_render {
+    my ($class, $u) = @_;
+
+    return LJ::is_enabled("comments_style_mine") && $u && $u->is_personal ? 1 : 0;
+}
+
+sub label {
+    my $class = shift;
+
+    return $class->ml('setting.commentsstylemine.label');
+}
+
+sub option {
+    my ($class, $u, $errs, $args) = @_;
+    my $key = $class->pkgkey;
+
+    my $stylealwaysmine = $class->get_arg($args, "stylealwaysmine") || $u->opt_stylealwaysmine;
+    my $commentsstylemine = $class->get_arg($args, "commentsstylemine") || $u->opt_commentsstylemine;
+    my $can_use_commentsstylemine = $u->can_use_commentsstylemine? 1 : 0;
+
+    $can_use_commentsstylemine = 0 if $stylealwaysmine;
+
+    my $ret = LJ::html_check({
+        name => "${key}commentsstylemine",
+        id => "${key}commentsstylemine",
+        value => 1,
+        selected => $commentsstylemine && $can_use_commentsstylemine? 1 : 0,
+        disabled => $can_use_commentsstylemine? 0 : 1,
+    });
+
+    $ret .= " <label for='${key}commentsstylemine'>" . $class->ml('setting.commentsstylemine.option') . "</label>";
+
+    return $ret;
+}
+
+sub save {
+    my ($class, $u, $args) = @_;
+
+    my $val = $class->get_arg($args, "commentsstylemine") ? "Y" : "N";
+    $u->set_prop( opt_commentsstylemine => $val );
+
+    return 1;
+}
+
+1;

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-01-10 09:08:39 UTC (rev 20877)
+++ trunk/cgi-bin/LJ/User.pm	2012-01-10 12:52:27 UTC (rev 20878)
@@ -4094,6 +4094,18 @@
     return $ret;
 }
 
+sub opt_commentsstylemine {
+    my $u = shift;
+
+    return 0 unless $u->can_use_commentsstylemine;
+    return $u->raw_prop('opt_commentsstylemine') eq 'Y'? 1 : 0;
+}
+
+sub can_use_commentsstylemine {
+    return 0 unless LJ::is_enabled('commentsstylemine');
+    return 1;
+}
+
 sub has_enabled_getting_started {
     my $u = shift;
 

Modified: trunk/htdocs/manage/settings/index.bml
===================================================================
--- trunk/htdocs/manage/settings/index.bml	2012-01-10 09:08:39 UTC (rev 20877)
+++ trunk/htdocs/manage/settings/index.bml	2012-01-10 12:52:27 UTC (rev 20878)
@@ -58,6 +58,7 @@
                 LJ::Setting::EmailFormat
                 LJ::Setting::EntryEditor
                 LJ::Setting::StyleAlwaysMine
+                LJ::Setting::CommentsStyleMine
                 LJ::Setting::StyleMine
                 LJ::Setting::GettingStarted
                 LJ::Setting::SiteScheme

Tags: anazarov, bml, dat, 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