fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-09-12 07:29 am

[dw-free] Visibility of information and who can view information on profile page

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

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

Adds visual indicator of security level on profile information

Patch by [personal profile] emclaughlin.

Files modified:
  • cgi-bin/DW/Logic/ProfilePage.pm
  • htdocs/profile.bml
--------------------------------------------------------------------------------
diff -r 6183b2b0d469 -r bdd7981886a2 cgi-bin/DW/Logic/ProfilePage.pm
--- a/cgi-bin/DW/Logic/ProfilePage.pm	Fri Sep 09 19:53:54 2011 +0800
+++ b/cgi-bin/DW/Logic/ProfilePage.pm	Mon Sep 12 15:29:32 2011 +0800
@@ -402,15 +402,16 @@
         my $bdate = $u->prop( 'bdate' );
         if ( $bdate && $bdate ne "0000-00-00" ) {
             $ret->[0] = LJ::Lang::ml( '.label.birthdate' );
+            $ret->[1] = $self->security_image( $u->opt_sharebday );
             my ($year, $mon, $day) = split /-/, $bdate;
             my $moname = LJ::Lang::month_short_ml( $mon );
             $day += 0;
             if ( $u->bday_string =~ /\d+-\d+-\d+/ ) {
-                $ret->[1] = "$moname $day, $year";
+                $ret->[1] .= "$moname $day, $year";
             } elsif ( $u->bday_string =~ /\d+-\d+/ ) {
-                $ret->[1] = "$moname $day";
+                $ret->[1] .= "$moname $day";
             } else {
-                $ret->[1] = $u->bday_string;
+                $ret->[1] .= $u->bday_string;
             }
         }
     }
@@ -435,6 +436,7 @@
         my $ecity = LJ::eurl( $city );
         my $ecountry = LJ::eurl( $country );
         my $estate = "";
+        my $secimg = $self->security_image( $u->opt_showlocation );
 
         if ( $country ) {
             my %countries = ();
@@ -443,6 +445,9 @@
             $country_ret = LJ::is_enabled( 'directory' ) ?
                 { url => "$LJ::SITEROOT/directory?opt_sort=ut&s_loc=1&loc_cn=$ecountry", text => $countries{ $country } } :
                 $countries{ $country };
+            if ( !$state && !$city ) {
+                $country_ret->{secimg} = $secimg;
+            }
         }
 
         if ( $state ) {
@@ -456,6 +461,9 @@
             $state_ret = $country && LJ::is_enabled( 'directory' ) ?
                 { url => "$LJ::SITEROOT/directory?opt_sort=ut&s_loc=1&loc_cn=$ecountry&loc_st=$estate", text => LJ::ehtml( $state ) } :
                 LJ::ehtml( $state );
+            if ( !$city ) {
+                $state_ret->{secimg} = $secimg;
+            }
         }
 
         if ( $city ) {
@@ -463,6 +471,7 @@
             $city_ret = $country && LJ::is_enabled( 'directory' ) ?
                 { url => "$LJ::SITEROOT/directory?opt_sort=ut&s_loc=1&loc_cn=$ecountry&loc_st=$estate&loc_ci=$ecity", text => $city } :
                 $city;
+            $city_ret->{secimg} = $secimg;
         }
 
         push @$ret, $city_ret, $state_ret, $country_ret;
@@ -974,5 +983,22 @@
     return @ret;
 }
 
+# returns image link based on privacy settings
+sub security_image {
+    my ( $self, $code ) = @_;
+    my %img = (
+        R => [ 'registered', 'identity/user.png' ],
+        F => [ 'trusted', 'entry/locked.png' ],
+        N => [ 'private', 'entry/private.png' ],
+    );
+    return '' unless $img{$code};
+    my ( $text, $imgfile ) = @{ $img{$code} };
+    $text = LJ::Lang::ml( 'entryform.security' ) . " $text";
+    $imgfile = "$LJ::SITEROOT/img/silk/$imgfile";
+    return "&nbsp;(<img alt='$text' title='$text' width='16' height='16'"
+        . " style='vertical-align: bottom' src='$imgfile' />)&nbsp;&nbsp;";
+}
+
+
 
 1;
diff -r 6183b2b0d469 -r bdd7981886a2 htdocs/profile.bml
--- a/htdocs/profile.bml	Fri Sep 09 19:53:54 2011 +0800
+++ b/htdocs/profile.bml	Mon Sep 12 15:29:32 2011 +0800
@@ -175,6 +175,7 @@
         return $l unless ref $l eq 'HASH';
 
         if ( $l->{text} ) {
+            return qq($l->{secimg}<a href="$l->{url}">$l->{text}</a>) if $l->{secimg};
             return qq(<a href="$l->{url}">$l->{text}</a>) if $l->{url};
             return $l->{text};
         } elsif ( $l->{email} ) {
@@ -450,7 +451,8 @@
     }
 
     if ( my @contacts = $profile->contact_rows ) {
-        $bibody .= qq( <div class="contact"><p class="section_body_title">$ML{'.contact.header'}</p> );
+        my $secimg = $profile->security_image( $u->opt_showcontact );
+        $bibody .= qq( <div class="contact"><p class="section_body_title">$ML{'.contact.header'}$secimg</p> );
         $bibody .= join( '<br />', map { $linkify->( $_ ) } @contacts );
         $bibody .= q{ </div> };
     };
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org