mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2010-02-17 04:49 am

[dw-free] Ability to opt-out of account creation community promo

[commit: http://hg.dwscoalition.org/dw-free/rev/582a6fe26f6c]

http://bugs.dwscoalition.org/show_bug.cgi?id=1746

Add ability for maintainers to opt their community out of the account
creation promo flow.

Patch by [personal profile] afuna.

Files modified:
  • bin/upgrading/en.dat
  • bin/upgrading/proplists.dat
  • cgi-bin/DW/Setting/CommunityPromo.pm
  • cgi-bin/LJ/User.pm
  • htdocs/manage/settings/index.bml
--------------------------------------------------------------------------------
diff -r b6ad03cd95b5 -r 582a6fe26f6c bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Wed Feb 17 04:45:29 2010 +0000
+++ b/bin/upgrading/en.dat	Wed Feb 17 04:49:29 2010 +0000
@@ -2395,6 +2395,10 @@ setting.commentscreening.option.select.n
 
 setting.commentscreening.option.select.nonmembers=comments from non-members
 
+setting.communitypromo.label=Community Promo
+
+setting.communitypromo.option=Opt out of putting this community in the list of promoted communities, when a user you invite creates an account
+
 setting.contactinfo.error.invalid=Invalid selection.
 
 setting.contactinfo.label=Contact Info Security
diff -r b6ad03cd95b5 -r 582a6fe26f6c bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat	Wed Feb 17 04:45:29 2010 +0000
+++ b/bin/upgrading/proplists.dat	Wed Feb 17 04:49:29 2010 +0000
@@ -61,6 +61,14 @@ userproplist.city:
   indexed: 1
   multihomed: 0
   prettyname: City
+
+userproplist.optout_community_promo:
+  cldversion: 4
+  datatype: char
+  des: Promote this community to invited users when they create their account
+  indexed: 0 
+  multihomed: 0
+  prettyname: Account creation community promo
 
 userproplist.comm_promo_blurb:
   cldversion: 4
diff -r b6ad03cd95b5 -r 582a6fe26f6c cgi-bin/DW/Setting/CommunityPromo.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Setting/CommunityPromo.pm	Wed Feb 17 04:49:29 2010 +0000
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+#
+# DW::Setting::CommunityPromo
+#
+# DW::Setting module for choosing whether a community should appear on the list of 
+# promoted communities, on account creation
+#
+# Authors:
+#      Afuna <coder.dw@afunamatata.com>
+#
+# 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::CommunityPromo;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+
+sub should_render {
+    my ( $class, $u ) = @_;
+
+    return $u->is_community;
+}
+
+sub label {
+    my $class = $_[0];
+
+    return $class->ml( 'setting.communitypromo.label' );
+}
+
+sub option {
+    my ( $class, $u, $errs, $args ) = @_;
+    my $key = $class->pkgkey;
+
+    my $communitypromo = $class->get_arg( $args, 'communitypromo' ) || $u->optout_community_promo;
+    
+    my $ret = LJ::html_check({
+        name => "${key}communitypromo",
+        id => "${key}communitypromo",
+        value => 1,
+        selected => $communitypromo,
+    });
+    $ret .= " <label for='${key}communitypromo'>";
+    $ret .= $class->ml( 'setting.communitypromo.option' );
+    $ret .= "</label>";
+
+    return $ret;
+}
+
+sub save {
+    my ( $class, $u, $args ) = @_;
+
+    $u->optout_community_promo( $class->get_arg( $args, "communitypromo" ) ? "1" : "0" );
+
+    return 1;
+}
+
+1;
diff -r b6ad03cd95b5 -r 582a6fe26f6c cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Wed Feb 17 04:45:29 2010 +0000
+++ b/cgi-bin/LJ/User.pm	Wed Feb 17 04:49:29 2010 +0000
@@ -2031,6 +2031,17 @@ sub clear_daycounts
     }
 }
 
+sub optout_community_promo {
+    my ( $u, $val ) = @_;
+
+    if ( defined $val && $val =~ /^[01]$/ ) {
+        $u->set_prop( optout_community_promo => $val );
+        return $val;
+    }
+
+    return $u->prop( 'optout_community_promo' ) ? 1 : 0;
+}
+
 sub control_strip_display {
     my $u = shift;
 
@@ -3523,10 +3534,12 @@ sub relevant_communities {
     my $memberships = LJ::load_userids( @ids );
 
     # get all communities that $u is a member of that aren't closed membership
+    # and that wish to be included in the community promo
     foreach my $membershipid ( keys %$memberships ) {
         my $membershipu = $memberships->{$membershipid};
 
         next unless $membershipu->is_community;
+        next if $membershipu->optout_community_promo;
         next unless $membershipu->is_visible;
         next if $membershipu->is_closed_membership;
 
diff -r b6ad03cd95b5 -r 582a6fe26f6c htdocs/manage/settings/index.bml
--- a/htdocs/manage/settings/index.bml	Wed Feb 17 04:45:29 2010 +0000
+++ b/htdocs/manage/settings/index.bml	Wed Feb 17 04:49:29 2010 +0000
@@ -120,6 +120,7 @@ body<=
                 DW::Setting::RandomPaidGifts
                 DW::Setting::GlobalSearch
                 DW::Setting::AllowSearchBy
+                DW::Setting::CommunityPromo
             )],
         },
         history => {
--------------------------------------------------------------------------------