Respect cuts in the inbox, allow users to turn this on/off.  Woo bug 48.

        Patch by afuna. 

diffs (158 lines):

diff -r bf8c00eeb61f -r e5edb7c3bc86 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat      Tue Nov 10 02:29:24 2009 +0000
+++ b/bin/upgrading/en.dat      Tue Nov 10 03:05:21 2009 +0000
@@ -2553,6 +2553,10 @@ setting.cutdisable.sel.none=No, honor cu
 
 setting.cutdisable.sel.reading=Yes, when viewing reading pages
 
+setting.cutinbox.label=Cut Tag in Inbox
+
+setting.cutinbox.option=Cut entries in inbox
+
 setting.display.accountstatus.actionlink.contactabuse=Contact Abuse
 
 setting.display.accountstatus.actionlink.delete=Delete
diff -r bf8c00eeb61f -r e5edb7c3bc86 bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat       Tue Nov 10 02:29:24 2009 +0000
+++ b/bin/upgrading/proplists.dat       Tue Nov 10 03:05:21 2009 +0000
@@ -381,6 +381,14 @@ userproplist.import_job:
   indexed: 0
   multihomed: 0
   prettyname: Import JobID
+
+userproplist.cut_inbox:
+  cldversion: 4
+  datatype: bool
+  des: Respect cut tag in inbox
+  indexed: 0
+  multihomed: 0
+  prettyname: Cut for Inbox
 
 userproplist.init_bdate:
   cldversion: 4
diff -r bf8c00eeb61f -r e5edb7c3bc86 cgi-bin/DW/Setting/CutInbox.pm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Setting/CutInbox.pm    Tue Nov 10 03:05:21 2009 +0000
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+#
+# DW::Setting::CutInbox
+#
+# LJ::Setting module which controls whether to respect cuts in the inbox
+#
+# Authors:
+#      Afuna <[email protected]>
+#
+# Copyright (c) 2009 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself.  For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+
+package DW::Setting::CutInbox;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+
+sub should_render {
+    my ( $class, $u ) = @_;
+    return $u && $u->is_individual;
+}
+
+sub label {
+    my $class = shift;
+    return $class->ml( 'setting.cutinbox.label' );
+}
+
+sub option {
+    my ( $class, $u, $errs, $args ) = @_;
+    my $key = $class->pkgkey;
+
+    my $inbox_cut = $class->get_arg( $args, "cutinbox" ) || ( $u->cut_inbox || 
"" ) eq "Y";
+
+    my $ret = LJ::html_check( {
+        name => "${key}cutinbox",
+        id => "${key}cutinbox",
+        value => 1,
+        selected => $inbox_cut ? 1 : 0,
+    } );
+    $ret .= " <label for='${key}cutinbox'>" . $class->ml( 
'setting.cutinbox.option' ) . "</label>";
+
+    return $ret;
+}
+
+sub save {
+    my ( $class, $u, $args ) = @_;
+
+    my $val = $class->get_arg( $args, "cutinbox" ) ? "Y" : "N";
+    $u->cut_inbox( $val );
+
+    return 1;
+}
+
+1;
diff -r bf8c00eeb61f -r e5edb7c3bc86 cgi-bin/LJ/Event/JournalNewEntry.pm
--- a/cgi-bin/LJ/Event/JournalNewEntry.pm       Tue Nov 10 02:29:24 2009 +0000
+++ b/cgi-bin/LJ/Event/JournalNewEntry.pm       Tue Nov 10 03:05:21 2009 +0000
@@ -68,7 +68,11 @@ sub content {
     my $entry = $self->entry;
     return undef unless $self->_can_view_content( $entry, $target );
 
-    return $entry->event_html . $self->as_html_actions;
+    return $entry->event_html( {
+            # double negatives, ouch!
+            ljcut_disable => ! $target->cut_inbox,
+            cuturl => $entry->url } )
+        . $self->as_html_actions;
 }
 
 sub content_summary {
diff -r bf8c00eeb61f -r e5edb7c3bc86 cgi-bin/LJ/Event/OfficialPost.pm
--- a/cgi-bin/LJ/Event/OfficialPost.pm  Tue Nov 10 02:29:24 2009 +0000
+++ b/cgi-bin/LJ/Event/OfficialPost.pm  Tue Nov 10 03:05:21 2009 +0000
@@ -18,8 +18,11 @@ sub entry {
 }
 
 sub content {
-    my $self = shift;
-    return $self->entry->event_html;
+    my ( $self, $target ) = @_;
+    return $self->entry->event_html( {
+            # double negatives, ouch!
+            ljcut_disable => ! $target->cut_inbox,
+            cuturl => $self->entry->url } );
 }
 
 sub content_summary {
diff -r bf8c00eeb61f -r e5edb7c3bc86 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm        Tue Nov 10 02:29:24 2009 +0000
+++ b/cgi-bin/LJ/User.pm        Tue Nov 10 03:05:21 2009 +0000
@@ -2092,6 +2092,16 @@ sub hide_join_post_link {
     return $u->prop( 'hide_join_post_link' );
 }
 
+# whether to respect cut tags in the inbox
+sub cut_inbox {
+    my $u = $_[0];
+
+    if ( defined $_[1] ) {
+        $u->set_prop( cut_inbox => $_[1] );
+    }
+
+    return  ( $_[1] || $u->prop( 'cut_inbox' ) || "N" ) eq 'Y' ? 1 : 0;
+}
 
 # tests to see if a user is in a specific named class. class
 # names are site-specific.
diff -r bf8c00eeb61f -r e5edb7c3bc86 htdocs/manage/settings/index.bml
--- a/htdocs/manage/settings/index.bml  Tue Nov 10 02:29:24 2009 +0000
+++ b/htdocs/manage/settings/index.bml  Tue Nov 10 03:05:21 2009 +0000
@@ -58,6 +58,7 @@ body<=
                 LJ::Setting::ImagePlaceholders
                 LJ::Setting::EmbedPlaceholders
                 DW::Setting::CutDisable
+                DW::Setting::CutInbox
                 LJ::Setting::EmailFormat
                 LJ::Setting::EntryEditor
                 LJ::Setting::NCTalkLinks
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to