New profile email setting (manage/settings); additional options under
manage/profile to choose which emails to display.
Patch by denise.
diffs (367 lines):
diff -r 090bb06795f7 -r fb1c5aa54ae8 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Mon Jul 06 16:17:30 2009 +0000
+++ b/bin/upgrading/en.dat Tue Jul 07 14:17:57 2009 +0000
@@ -2785,6 +2785,8 @@ setting.notifyweblogs.option.self=Notify
setting.prod.display.title=New Setting!
+setting.profileemail.label=Email to display on your profile
+
setting.safesearch.error.invalid=Invalid safe search setting.
setting.safesearch.label=Safe Search Filter
diff -r 090bb06795f7 -r fb1c5aa54ae8 bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat Mon Jul 06 16:17:30 2009 +0000
+++ b/bin/upgrading/proplists.dat Tue Jul 07 14:17:57 2009 +0000
@@ -742,6 +742,14 @@ userproplist.opt_no_quickreply:
multihomed: 0
prettyname: Disable QuickReply
+userproplist.opt_profileemail:
+ cldversion: 4
+ datatype: char
+ des: Email address to show on the profile
+ indexed: 0
+ multihomed: 0
+ prettyname: Displayed Email
+
userproplist.opt_sharebday:
cldversion: 4
datatype: char
@@ -857,7 +865,7 @@ userproplist.opt_whatemailshow:
userproplist.opt_whatemailshow:
cldversion: 4
datatype: char
- des: N: none, A: actual, L: livejournal, B: both
+ des: N: none, A: actual, L: local, B: both actual + local, D: display email,
V: both display + local
indexed: 1
multihomed: 0
prettyname: Which email address to display
diff -r 090bb06795f7 -r fb1c5aa54ae8 cgi-bin/DW/Setting/ProfileEmail.pm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Setting/ProfileEmail.pm Tue Jul 07 14:17:57 2009 +0000
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+#
+# DW::Setting::ProfileEmail
+#
+# LJ::Setting module for specifying a displayed email.
+#
+# Authors:
+# Denise Paolucci <[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::ProfileEmail;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+use LJ::Constants;
+
+sub should_render {
+ my ( $class, $u ) = @_;
+ return 1;
+}
+
+sub label {
+ my $class = shift;
+ return $class->ml( 'setting.profileemail.label' );
+}
+
+sub option {
+ my ( $class, $u, $errs, $args ) = @_;
+
+ my $key = $class->pkgkey;
+ my $ret;
+
+ $ret .= LJ::html_text({
+ name => "${key}email",
+ id => "${key}email",
+ class => "text",
+ value => $errs ? $class->get_arg( $args, "email" ) :
$u->profile_email,
+ size => 70,
+ maxlength => 255,
+ });
+
+ my $errdiv = $class->errdiv( $errs, "email" );
+ $ret .= "<br />$errdiv" if $errdiv;
+
+ return $ret;
+}
+
+sub save {
+ my ( $class, $u, $args ) = @_;
+
+ my $email = $class->get_arg( $args, "email" );
+ $email = LJ::trim( $email || "" );
+
+ $u->profile_email( $email );
+
+ return 1;
+}
+
+1;
diff -r 090bb06795f7 -r fb1c5aa54ae8 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Mon Jul 06 16:17:30 2009 +0000
+++ b/cgi-bin/LJ/User.pm Tue Jul 07 14:17:57 2009 +0000
@@ -2067,9 +2067,9 @@ sub opt_whatemailshow {
# return prop value if it exists and is valid
my $prop_val = $u->prop( 'opt_whatemailshow' );
if ( $user_email ) {
- return $prop_val if $prop_val =~ /^[ALBN]$/;
- } else {
- return $prop_val if $prop_val =~ /^[AN]$/;
+ return $prop_val if $prop_val =~ /^[ALBNDV]$/;
+ } else {
+ return $prop_val if $prop_val =~ /^[AND]$/;
}
# otherwise, return the default: no email shown
@@ -2089,6 +2089,19 @@ sub profile_url {
$url .= "?mode=full" if $opts{full};
}
return $url;
+}
+
+
+# get/set the displayed email on profile (if user has specified)
+sub profile_email {
+ my ( $u, $email ) = @_;
+
+ if ( defined $email ) {
+ $u->set_prop( opt_profileemail => $email );
+ return $email;
+ }
+
+ return $u->prop( 'opt_profileemail' );
}
@@ -3449,6 +3462,12 @@ sub email_visible {
return scalar $u->emails_visible($remote);
}
+# returns an array of emails based on the user's display prefs
+# A: actual email address
+# D: display email address
+# L: local email address
+# B: both actual + local email address
+# V: both display + local email address
sub emails_visible {
my ($u, $remote) = @_;
@@ -3475,13 +3494,17 @@ sub emails_visible {
$whatemail eq "L" && ($u->prop("no_mail_alias") || ! $useremail_cap ||
! $LJ::USER_EMAIL) ||
$hide_contactinfo->();
- my @emails = ($u->email_raw);
- if ($whatemail eq "L") {
- @emails = ();
- }
+ my @emails = ();
+
+ if ( $u->prop( 'opt_whatemailshow' ) eq "A" || $u->prop(
'opt_whatemailshow' ) eq "B" ) {
+ push @emails, $u->email_raw;
+ } elsif ( $u->prop( 'opt_whatemailshow' ) eq "D" || $u->prop(
'opt_whatemailshow' ) eq "V" ) {
+ push @emails, $u->prop( 'opt_profileemail' );
+ }
+
if ($LJ::USER_EMAIL && $useremail_cap) {
- unless ($whatemail eq "A" || $u->prop('no_mail_alias')) {
- push @emails, "$u->{'user'}...@$lj::USER_DOMAIN";
+ if ($whatemail eq "B" || $whatemail eq "V" || $whatemail eq "L") {
+ push @emails, "$u->{'user'}...@$lj::USER_DOMAIN" unless
$u->prop('no_mail_alias');
}
}
return wantarray ? @emails : $emails[0];
diff -r 090bb06795f7 -r fb1c5aa54ae8 htdocs/manage/profile/index.bml
--- a/htdocs/manage/profile/index.bml Mon Jul 06 16:17:30 2009 +0000
+++ b/htdocs/manage/profile/index.bml Tue Jul 07 14:17:57 2009 +0000
@@ -311,22 +311,28 @@ body<=
$ret .= "</td></tr>\n";
# email
- $ret .= "<tr><td class='field_name'>$ML{'.fn.email'}</td><td>\n";
- if ($LJ::EMAIL_CHANGE_REQUIRES_PASSWORD) {
- $ret .= "<b>" . $u->email_raw . "</b> <a
href='$LJ::SITEROOT/changeemail.bml$getextra'>$ML{'.email.change'}</a>";
- } else {
- $ret .= LJ::html_text({ 'name' => 'email', 'value' =>
$u->email_raw, 'size' => '40', 'maxlength' => '50' });
- }
+
+ $ret .= "<tr><td class='field_name'>
$ML{'.fn.email.system'}</td><td>\n";
+ $ret .= "<b>" . $u->email_raw . "</b> <a
href='$LJ::SITEROOT/changeemail.bml$getextra'>$ML{'.email.change.system'}</a></td></tr>";
+
+ $ret .= "<tr><td class='field_name'>
$ML{'.fn.email.display'}</td><td>\n";
+
+ my $emailsettingurl = $getextra ? "<a
href='$LJ::SITEROOT/manage/settings/$getextra&cat=privacy'>" : "<a
href='$LJ::SITEROOT/manage/settings/?cat=privacy'>";
+
+ $ret .= "<b>" . $u->prop( 'opt_profileemail' ) . "</b> " .
$emailsettingurl . "$ML{'.email.change.display'}</a></td></tr>";
# opt_whatemailshow
- $ret .= "<br />\n$ML{'.fn.emaildisplay'}: ";
+ $ret .= "<tr><td class='field_name'> $ML{'.fn.emaildisplay'}</td><td>
";
my $cur = $u->opt_whatemailshow;
my @vals = ( ($LJ::USER_EMAIL && LJ::get_cap($u, "useremail"))
- ? ("A" => BML::ml(".email.opt.prime"),
+ ? ("A" => BML::ml(".email.opt.actual"),
+ "D" => BML::ml(".email.opt.display"),
"L" => BML::ml(".email.opt.site", { sitenameshort =>
$LJ::SITENAMESHORT } ),
- "B" => BML::ml(".email.opt.both", { sitenameshort =>
$LJ::SITENAMESHORT } ),
- "N" => BML::ml(".email.opt.dont"))
- : ("A" => BML::ml(".email.opt.show"),
+ "B" => BML::ml(".email.opt.both.actual", {
sitenameshort => $LJ::SITENAMESHORT } ),
+ "V" => BML::ml(".email.opt.both.display", {
sitenameshort => $LJ::SITENAMESHORT } ),
+ "N" => BML::ml(".email.opt.none"))
+ : ("A" => BML::ml(".email.opt.actual"),
+ "D" => BML::ml(".email.opt.display"),
"N" => BML::ml(".email.opt.no_show")));
$ret .= LJ::html_select({ 'name' => 'opt_whatemailshow', 'selected' =>
$cur }, @vals) . "\n";
@@ -545,25 +551,6 @@ body<=
push @errors, $ML{'.error.day.notinmonth'};
}
- # email
- unless ($LJ::EMAIL_CHANGE_REQUIRES_PASSWORD) {
- if (!$POST{'email'}) {
- push @errors, $ML{'.error.email.none'};
- }
-
- if ($LJ::USER_EMAIL and $POST{'email'} =~
/\...@\q$lj::USER_DOMAIN\E$/i) {
- push @errors, BML::ml(".error.email.lj_domain2", { 'user' =>
$remote->{'user'}, 'domain' => $LJ::USER_DOMAIN, 'aopts' =>
"href='$LJ::SITEROOT/manage/profile/'" });
- }
-
- if ($POST{'email'} =~ /\s/) {
- push @errors, $ML{'.error.email.no_space'};
- }
-
- unless (@errors) {
- LJ::check_email($POST{'email'}, \...@errors);
- }
- }
-
if ($POST{'LJ__Setting__UserMessaging_opt_usermsg'} &&
!$POST{'LJ__Setting__UserMessaging_opt_usermsg'} =~ /^[MFNY]$/) {
push @errors, BML::ml(".error.usermessaging");
}
@@ -598,20 +585,6 @@ body<=
my $dbh = LJ::get_db_writer();
- my $email_changed = (($u->email_raw ne $POST{'email'}) &&
!$LJ::EMAIL_CHANGE_REQUIRES_PASSWORD);
- if ($email_changed) {
- # record old email address;
- LJ::infohistory_add($u, 'email', $u->email_raw, $u->{status});
-
- $u->log_event('email_change', { remote => $remote, new =>
$POST{'email'} });
-
- LJ::run_hook('post_email_change',
- {
- user => $u,
- newemail => $POST{'email'},
- });
- }
-
$POST{'url'} =~ s/\s+$//; $POST{'url'} =~ s/^\s+//;
if ($POST{'url'} && $POST{'url'} !~ /^https?:\/\//) {
$POST{'url'} =~ s/^http\W*//;
@@ -629,13 +602,10 @@ body<=
my %update = (
'name' => $newname,
'bdate' => sprintf("%04d-%02d-%02d", $POST{'year'},
$POST{'month'}, $POST{'day'}),
- 'status' => ($email_changed && $u->{'status'} eq "A") ?
"T" : $u->{'status'},
'has_bio' => $has_bio,
'allow_getljnews' => $POST{'allow_getljnews'} ? "Y" :
"N",
'txtmsg_status' => $txtmsg_status,
);
-
- $update{'email'} = $POST{'email'} unless
$LJ::EMAIL_CHANGE_REQUIRES_PASSWORD;
if ($POST{'allow_contactshow'}) {
$update{'allow_contactshow'} = $POST{'allow_contactshow'} if
$POST{'allow_contactshow'} =~ m/^(N|R|Y|F)$/;
@@ -761,25 +731,6 @@ body<=
LJ::set_interests($u, \%interests, \...@valid_ints);
}
- # actions if email changed
- if ($email_changed) {
- my $aa = {};
- $aa = LJ::register_authaction($u->{'userid'},
- "validateemail", $POST{'email'});
-
- LJ::send_mail({
- 'to' => $POST{'email'},
- 'from' => $LJ::ADMIN_EMAIL,
- 'charset' => 'utf-8',
- 'subject' => $ML{'/changeemail.bml.newemail.subject'},
- 'body' => BML::ml('/changeemail.bml.newemail.body2',
- { username => $u->{user},
- sitename => $LJ::SITENAME,
- sitelink => $LJ::SITEROOT,
- conflink =>
"$LJ::SITEROOT/confirm/$aa->{'aaid'}.$aa->{'authcode'}" }),
- });
- }
-
LJ::run_hooks('profile_save', $u);
LJ::run_hook('set_profile_settings_extra', $u, \%POST);
diff -r 090bb06795f7 -r fb1c5aa54ae8 htdocs/manage/profile/index.bml.text
--- a/htdocs/manage/profile/index.bml.text Mon Jul 06 16:17:30 2009 +0000
+++ b/htdocs/manage/profile/index.bml.text Tue Jul 07 14:17:57 2009 +0000
@@ -23,19 +23,21 @@
.email=Email
-.email.change=Change email
+.email.change.system=Change email used by system
-.email.opt.both=Both (primary email + [[sitenameshort]] email)
+.email.change.display=Change email shown on profile
-.email.opt.dont=Don't display my email address
+.email.opt.actual=Show actual email address
+
+.email.opt.both.actual=Show actual email + [[sitenameshort]] email
+
+.email.opt.both.display=Show display email + [[sitenameshort]] email
+
+.email.opt.display=Show display email address
+
+.email.opt.none=Don't show any email address
.email.opt.site=[[sitenameshort]] email only
-
-.email.opt.no_show=Don't show email address
-
-.email.opt.prime=Primary email only
-
-.email.opt.show=Show email address
.error.bio.toolong=Your user bio is too long.
@@ -93,7 +95,9 @@
.fn.country=Country
-.fn.email=Primary email
+.fn.email.display=Profile email
+
+.fn.email.system=System email
.fn.emaildisplay=Display
diff -r 090bb06795f7 -r fb1c5aa54ae8 htdocs/manage/settings/index.bml
--- a/htdocs/manage/settings/index.bml Mon Jul 06 16:17:30 2009 +0000
+++ b/htdocs/manage/settings/index.bml Tue Jul 07 14:17:57 2009 +0000
@@ -111,6 +111,7 @@ body<=
LJ::Setting::CommentCaptcha
LJ::Setting::CommentIP
LJ::Setting::Display::BanUsers
+ DW::Setting::ProfileEmail
)],
},
history => {
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog