Move contact information visibility to be a setting widget.

        Patch by kareila. 

diffs (121 lines):

diff -r aa45028acb2a -r 0491ae584041 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat      Fri Oct 09 04:11:27 2009 +0000
+++ b/bin/upgrading/en.dat      Fri Oct 09 04:20:19 2009 +0000
@@ -2507,6 +2507,14 @@ setting.commentscreening.option.select.n
 
 setting.commentscreening.option.select.nonmembers=comments from non-members
 
+setting.contactinfo.error.invalid=Invalid selection.
+
+setting.contactinfo.label=Contact Info Security
+
+setting.contactinfo.option=Who can view your contact info?
+
+setting.contactinfo.option.note=This setting controls who can view your 
contact information for any external services, in addition to your selected 
email address(es), on your profile page.
+
 setting.ctxpopup.label=Hover Menu
 
 setting.ctxpopup.option=Show menu when I hover over userhead images or userpics
diff -r aa45028acb2a -r 0491ae584041 cgi-bin/DW/Setting/ContactInfo.pm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Setting/ContactInfo.pm Fri Oct 09 04:20:19 2009 +0000
@@ -0,0 +1,88 @@
+#!/usr/bin/perl
+#
+# DW::Setting::ContactInfo
+#
+# LJ::Setting module for selecting the default security level for
+# a journal user's contact information.
+#
+# Authors:
+#      Jen Griffin <[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::ContactInfo;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+
+sub should_render {
+    my ( $class, $u ) = @_;
+    return 1;
+}
+
+sub label {
+    return $_[0]->ml( 'setting.contactinfo.label' );
+}
+
+sub option {
+    my ( $class, $u, $errs, $args ) = @_;
+    my $key = $class->pkgkey;
+
+    my $contactinfo = $class->get_arg( $args, "contactinfo" ) || 
$u->opt_showcontact;
+
+    my @options = (
+        "Y" => $class->ml( 'settings.usermessaging.opt.a' ),
+        "R" => $class->ml( 'settings.usermessaging.opt.y' ),
+        "F" => $class->ml( 'settings.usermessaging.opt.f' ),
+        "N" => $class->ml( 'settings.usermessaging.opt.n' ),
+    );
+
+    my $ret;
+
+    $ret .= " <label for='${key}contactinfo'>";
+    $ret .= $class->ml( 'setting.contactinfo.option' );
+    $ret .= "</label> ";
+
+    $ret .= LJ::html_select( {
+        name => "${key}contactinfo",
+        id => "${key}contactinfo",
+        selected => $contactinfo,
+    }, @options );
+    
+    $ret .= "<p class='details'>";
+    $ret .= $class->ml( 'setting.contactinfo.option.note' );
+    $ret .= "</p>";
+
+
+    my $errdiv = $class->errdiv( $errs, "contactinfo" );
+    $ret .= "<br />$errdiv" if $errdiv;
+
+    return $ret;
+}
+
+sub error_check {
+    my ( $class, $u, $args ) = @_;
+    my $val = $class->get_arg( $args, "contactinfo" );
+
+    $class->errors( contactinfo => $class->ml( 
'setting.contactinfo.error.invalid' ) )
+        unless ! $val || $val =~ /^[YRFN]$/;
+
+    return 1;
+}
+
+sub save {
+    my ( $class, $u, $args ) = @_;
+    $class->error_check( $u, $args );
+
+    my $val = $class->get_arg( $args, "contactinfo" );
+    LJ::update_user( $u, { allow_contactshow => $val } );
+
+    return 1;
+}
+
+1;
diff -r aa45028acb2a -r 0491ae584041 htdocs/manage/settings/index.bml
--- a/htdocs/manage/settings/index.bml  Fri Oct 09 04:11:27 2009 +0000
+++ b/htdocs/manage/settings/index.bml  Fri Oct 09 04:20:19 2009 +0000
@@ -105,6 +105,7 @@ body<=
             desc => $ML{'.cat.privacy.desc'},
             settings => [qw(
                 DW::Setting::EmailAlias
+                DW::Setting::ContactInfo
                 LJ::Setting::MinSecurity
                 DW::Setting::SynLevel
                 LJ::Setting::SearchInclusion
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to