Remove zip code support from the frontend (we don't use it, and it's 
not much use in the code base without a zip-to-city mapping, as well)

        Patch by jld. 

diffs (365 lines):

diff -r 75e2a7c9b3e5 -r 207c7ed022f8 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat      Thu Sep 23 16:59:32 2010 +0800
+++ b/bin/upgrading/en.dat      Thu Sep 23 17:50:28 2010 +0800
@@ -3069,17 +3069,6 @@ settings.error.locale.invalid_country=So
 
 settings.error.locale.state_ne_country=You specified a non-US country but 
selected a US state.
 
-settings.error.locale.zip_ne_state<<
-Your zip code does not match the state you specified.__
-Either correct the information, or erase one or both of the state and zip code 
fields.
-.
-
-settings.error.locale.zip_requires_us<<
-You entered a zip code but you did not select United States as your country.
-We only collect zip code information about people in the US.
-Please go back and remove the zip code or select United States as your country.
-.
-
 settings.error.year.notenoughdigits=Invalid birthday year. Enter a 4-digit 
year.
 
 settings.error.year.outofrange=Invalid birthday year.
@@ -3141,8 +3130,6 @@ settings.usermessaging.question=Receive 
 settings.usermessaging.question=Receive messages from:
 
 settings.yearofbirth=Year of Birth
-
-settings.zipcode=ZIP Code
 
 shop.email.accounttype=[[type]] for [[nummonths]] [[?nummonths|month|months]]
 
@@ -4681,10 +4668,6 @@ widget.location.error.locale.invalid_cou
 
 widget.location.error.locale.state_ne_country=You specified a non-US country 
but selected a US state.
 
-widget.location.error.locale.zip_ne_state=Your zip code does not match the 
state you specified. Either correct the information, or erase one or both of 
the state and zip code fields.
-
-widget.location.error.locale.zip_requires_us=You entered a zip code but you 
did not select United States as your country. We only collect zip code 
information about people in the US. Please go back and remove the zip code or 
select United States as your country.
-
 widget.location.fn.city=City
 
 widget.location.fn.city.inline=city
@@ -4699,10 +4682,6 @@ widget.location.fn.state.inline=state
 
 widget.location.fn.timezone=Timezone
 
-widget.location.fn.zip=ZIP Code
-
-widget.location.fn.zip.inline=zip
-
 widget.location.location=Show your location to
 
 widget.location.section.location=Location
@@ -4718,8 +4697,6 @@ widget.location.state.loading=Loading st
 widget.location.state.loading=Loading states...
 
 widget.location.timezone.select=(Select your timezone)
-
-widget.location.zip.usonly=5 digit ZIP code; US residents only
 
 widget.moodthemechooser.desc=Mood themes are small icons that describe your 
mood or the mood of a post. Select from a variety of faces and characters.
 
diff -r 75e2a7c9b3e5 -r 207c7ed022f8 cgi-bin/LJ/Widget/Location.pm
--- a/cgi-bin/LJ/Widget/Location.pm     Thu Sep 23 16:59:32 2010 +0800
+++ b/cgi-bin/LJ/Widget/Location.pm     Thu Sep 23 17:50:28 2010 +0800
@@ -18,7 +18,7 @@ use Carp qw(croak);
 use Carp qw(croak);
 use DateTime::TimeZone;
 
-my @location_props = qw/ country state city zip sidx_loc /;
+my @location_props = qw/ country state city sidx_loc /;
 
 
 sub authas {1}
@@ -29,7 +29,6 @@ sub need_res { qw(js/countryregions.js) 
 ##      city            - initial city value
 ##      state           - initial state value
 ##      skip_timezone   - timezone input is not displayed if true, defaults to 0
-##      skip_zip        - zip input is not displayed if true, defaults to 0
 ##      skip_city       - city input is not displayed if true, defaults to 0
 sub render_body {
     my $class = shift;
@@ -61,7 +60,6 @@ sub render_body {
 
 
     my $state_inline_desc = $class->ml('widget.location.fn.state.inline');
-    my $zip_inline_desc = $class->ml('widget.location.fn.zip.inline');
     my $city_inline_desc = $class->ml('widget.location.fn.city.inline');
 
     my $ret;
@@ -80,7 +78,7 @@ sub render_body {
                                  %{ $opts{'country_input_attributes'} or {} },
                                );
     if ($minimal_display) {
-        $ret .= " ";
+        $ret .= "<br />";
     } else {
         $ret .= "</td></tr>\n";
 
@@ -130,36 +128,6 @@ sub render_body {
         $ret .= "</td></tr>\n";
     }
 
-    # zip
-    unless ($opts{'skip_zip'}) {
-        my $zip_val = "";
-        my $zip_inline_color = "";
-        if ($effective_country eq 'US') {
-            $zip_val = $zip_inline_desc if $minimal_display;
-            $zip_val = $u->{zip} if $u->{zip};
-
-            $zip_inline_color = " color: #999;" if $minimal_display && 
$zip_val eq $zip_inline_desc;
-        }
-
-        my %minimal_display_zip_attrs;
-        if ($minimal_display) {
-            $minimal_display_zip_attrs{onfocus} = "if (this.value == '" . 
$zip_inline_desc . "') { this.value = ''; this.style.color = ''; }";
-            $minimal_display_zip_attrs{onblur} = "if (this.value == '') { 
this.value = '" . $zip_inline_desc . "'; this.style.color = '#999'; }";
-        }
-
-        $ret .= "<tr><td class='field_class'>" . 
$class->ml('widget.location.fn.zip') . "</td><td>" unless $minimal_display;
-        $ret .= $class->html_text( id => 'zip',
-                                   name => 'zip',
-                                   title => $class->ml( 
'widget.location.fn.zip' ),
-                                   value => $zip_val,
-                                   size => '6', maxlength => '5',
-                                   disabled => $minimal_display || 
$effective_country eq 'US' ? '' : 'disabled',
-                                   style => "display: " . ( $minimal_display 
&& $effective_country ne 'US' ? "none" : "inline" ) . ";$zip_inline_color",
-                                   %minimal_display_zip_attrs,
-                                 );
-        $ret .= " <span class='helper'>(" . 
$class->ml('widget.location.zip.usonly') . ")</span></td></tr>\n" unless 
$minimal_display;
-    }
-
     # city
     unless ($opts{'skip_city'}) {
         my $city_val = "";
@@ -181,7 +149,7 @@ sub render_body {
                                    value => $city_val,
                                    size => '20',
                                    maxlength => '255',
-                                   style => "display: " . ($minimal_display && 
$effective_country eq 'US' ? "none" : "inline") . ";$city_inline_color",
+                                   style => "display: 
inline;$city_inline_color",
                                    %minimal_display_city_attrs,
                                    %{ $opts{'state_input_attributes'} or {} },
                                  );
@@ -215,7 +183,7 @@ sub render_body {
     $ret .= $class->html_hidden({ name => "minimal_display", value => 
$minimal_display, id => "minimal_display" });
 
     # javascript code in js/countryregions.js accepts list of countries with 
regions as a space-delimited list
-    $ret .= "<script> var countryregions = new 
CountryRegions('country_choice', 'reloadable_states', 'written_state', '" . 
LJ::ejs($state_inline_desc) . "', 'zip', '" . LJ::ejs($zip_inline_desc) . "', 
'city', '" . LJ::ejs($city_inline_desc) . "', '" . join (" ", 
$class->countries_with_regions ). "'); </script>";
+    $ret .= "<script> var countryregions = new 
CountryRegions('country_choice', 'reloadable_states', 'written_state', '" . 
LJ::ejs($state_inline_desc) . "', 'city', '" . LJ::ejs($city_inline_desc) . "', 
'" . join (" ", $class->countries_with_regions ). "'); </script>";
 
     return $ret;
 }
@@ -231,39 +199,16 @@ sub handle_post {
     LJ::load_codes({ "country" => \%countries});
 
     my $state_inline_desc = $class->ml('widget.location.fn.state.inline');
-    my $zip_inline_desc = $class->ml('widget.location.fn.zip.inline');
     my $city_inline_desc = $class->ml('widget.location.fn.city.inline');
 
     $post->{stateother} = "" if $post->{stateother} eq $state_inline_desc;
     $post->{city} = "" if $post->{city} eq $city_inline_desc;
-    $post->{zip} = "" if $post->{zip} eq $zip_inline_desc;
-
-    # state and zip
-    my ( $zipcity, $zipstate );
-    ( $zipcity, $zipstate ) = LJ::load_state_city_for_zip( $post->{'zip'} )
-        if $post->{'country'} eq "US" && length $post->{'zip'} > 0;
-
-    # country
-    if ($post->{'country'} ne "US" && $post->{'zip'}) {
-        
$class->error($class->ml('widget.location.error.locale.zip_requires_us'));
-    }
 
     my $regions_cfg = $class->country_regions_cfg($post->{'country'});
     if ($regions_cfg && $post->{'stateother'}) {
         
$class->error($class->ml('widget.location.error.locale.country_ne_state'));
     } elsif (!$regions_cfg && $post->{'statedrop'}) {
         
$class->error($class->ml('widget.location.error.locale.state_ne_country'));
-    }
-
-    # zip-code validation stuff
-    if ($post->{'country'} eq "US") {
-        if ($post->{'statedrop'} && $zipstate && $post->{'statedrop'} ne 
$zipstate) {
-            
$class->error($class->ml('widget.location.error.locale.zip_ne_state'));
-        }
-        if ($zipcity) {
-            $post->{'statedrop'} = $zipstate;
-            $post->{'city'} = $zipcity;
-        }
     }
 
     if ($post->{'country'} && !defined($countries{$post->{'country'}})) {
diff -r 75e2a7c9b3e5 -r 207c7ed022f8 cgi-bin/LJ/vCard.pm
--- a/cgi-bin/LJ/vCard.pm       Thu Sep 23 16:59:32 2010 +0800
+++ b/cgi-bin/LJ/vCard.pm       Thu Sep 23 17:50:28 2010 +0800
@@ -43,7 +43,7 @@ sub new_remote {
     $vcard->NICKNAME($u->{user});
     $vcard->URL($u->journal_base . "/");
 
-    $u->preload_props(qw(city state zip country
+    $u->preload_props(qw(city state country
                          aolim icq yahoo msn jabber google_talk skype gizmo));
 
 
@@ -94,7 +94,6 @@ sub new_remote {
 
         $node->[0]->city($u->prop('city'));
         $node->[0]->region($u->prop('state'));
-        $node->[0]->post_code($u->prop('zip'));
         $node->[0]->country($u->prop('country'));
     }
 
diff -r 75e2a7c9b3e5 -r 207c7ed022f8 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl  Thu Sep 23 16:59:32 2010 +0800
+++ b/cgi-bin/ljlib.pl  Thu Sep 23 17:50:28 2010 +0800
@@ -801,28 +801,6 @@ sub load_codes {
             }
         }
     }
-}
-
-# <LJFUNC>
-# name: LJ::load_state_city_for_zip
-# des: Fetches state and city for the given zip-code value
-# args: dbarg?, zip
-# des-zip: zip code
-# </LJFUNC>
-sub load_state_city_for_zip {
-    my $zip = shift;
-    my ($zipcity, $zipstate);
-
-    if ($zip =~ /^\d{5}$/) {
-        my $dbr = LJ::get_db_reader()
-            or die "Unable to get database handle";
-
-        my $sth = $dbr->prepare("SELECT city, state FROM zip WHERE zip=?");
-        $sth->execute($zip) or die "Failed to fetch state and city for zip: 
$DBI::errstr";
-        ($zipcity, $zipstate) = $sth->fetchrow_array;
-    }
-
-    return ($zipcity, $zipstate);
 }
 
 # <LJFUNC>
diff -r 75e2a7c9b3e5 -r 207c7ed022f8 htdocs/js/countryregions.js
--- a/htdocs/js/countryregions.js       Thu Sep 23 16:59:32 2010 +0800
+++ b/htdocs/js/countryregions.js       Thu Sep 23 17:50:28 2010 +0800
@@ -1,15 +1,13 @@ function CountryRegions (countrySelectId
-function CountryRegions (countrySelectId, regionSelectId, regionTextId, 
regionDesc, zipBoxId, zipDesc, cityBoxId, cityDesc, countriesWithRegions) {
+function CountryRegions (countrySelectId, regionSelectId, regionTextId, 
regionDesc, cityBoxId, cityDesc, countriesWithRegions) {
 
     this.countrySelect = document.getElementById(countrySelectId);
     this.regionSelect = document.getElementById(regionSelectId);
     this.regionText = document.getElementById(regionTextId);
-    this.zipBox = document.getElementById(zipBoxId);
     this.cityBox = document.getElementById(cityBoxId);
 
     this.descColor = "#999";
     this.regionDesc = regionDesc;
     this.cityDesc = cityDesc;
-    this.zipDesc = zipDesc;
 
     this.selectedCountry = '';
     this.loadedCountries = new Object;
@@ -25,10 +23,6 @@ function CountryRegions (countrySelectId
         if (this.cityBox && this.cityBox.value == "") {
             this.cityBox.style.color = this.descColor;
             this.cityBox.value = this.cityDesc;
-        }
-        if (this.zipBox && this.zipBox.value == "") {
-            this.zipBox.style.color = this.descColor;
-            this.zipBox.value = this.zipDesc;
         }
     } else {
         this.minimalDisplay = 0;
@@ -70,10 +64,6 @@ CountryRegions.prototype.countryChanged 
     var self = this;
     this.selectedCountry = this.countrySelect.value;
 
-    if (undefined != this.zipBox) {
-        this.zipSwitch();
-    }
-
     if (this.countriesWithRegions[this.selectedCountry] && undefined == 
this.loadedCountries[this.selectedCountry]) {
         HTTPReq.getJSON({
             method : "POST",
@@ -114,34 +104,8 @@ CountryRegions.prototype.createStatesOpt
         if (this.minimalDisplay == 1) {
             this.regionText.style.color = this.descColor;
             this.regionText.value = this.regionDesc;
+            this.cityBox.style.color = this.descColor;
+            this.cityBox.value = this.cityDesc;
         }
     }
 }
-
-
-CountryRegions.prototype.zipSwitch = function() {
-    if (this.minimalDisplay == 1) {
-        if (this.selectedCountry == 'US') {
-            this.zipBox.style.display = 'inline';
-            this.cityBox.style.display = 'none';
-            this.cityBox.value = '';
-
-            this.zipBox.style.color = this.descColor;
-            this.zipBox.value = this.zipDesc;
-        } else {
-            this.cityBox.style.display = 'inline';
-            this.zipBox.style.display = 'none';
-            this.zipBox.value = '';
-
-            this.cityBox.style.color = this.descColor;
-            this.cityBox.value = this.cityDesc;
-        }
-    } else {
-        if (this.selectedCountry == 'US') {
-            this.zipBox.disabled = '';
-        } else {
-            this.zipBox.value = '';
-            this.zipBox.disabled = 'disabled';
-        }
-    }
-}
diff -r 75e2a7c9b3e5 -r 207c7ed022f8 htdocs/manage/profile/index.bml
--- a/htdocs/manage/profile/index.bml   Thu Sep 23 16:59:32 2010 +0800
+++ b/htdocs/manage/profile/index.bml   Thu Sep 23 17:50:28 2010 +0800
@@ -54,7 +54,7 @@ body<=
 
     # load user props
     $u->preload_props( { use_master => 1 },
-        qw/ country state city zip timezone
+        qw/ country state city timezone
           icq aolim yahoo msn url jabber
           google_talk skype gizmo
           twitter delicious
diff -r 75e2a7c9b3e5 -r 207c7ed022f8 htdocs/manage/profile/index.bml.text
--- a/htdocs/manage/profile/index.bml.text      Thu Sep 23 16:59:32 2010 +0800
+++ b/htdocs/manage/profile/index.bml.text      Thu Sep 23 17:50:28 2010 +0800
@@ -54,10 +54,6 @@
 .error.locale.invalid_country=Somehow you selected an invalid country.
 
 .error.locale.state_ne_country=You specified a non-US country but selected a 
US state.
-
-.error.locale.zip_ne_state=Your zip code does not match the state you 
specified. Either correct the information, or erase one or both of the state 
and zip code fields.
-
-.error.locale.zip_requires_us=You entered a zip code but you did not select 
United States as your country. We only collect zip code information about 
people in the US. Please go back and remove the zip code or select United 
States as your country.
 
 .error.month.outofrange=Invalid birthday month.  Enter a month from 1-12.  
(Jan-Dec)
 
@@ -144,8 +140,6 @@
 .fn.txtnum=Full phone number
 
 .fn.userpic2=Default Icon
-
-.fn.zip=ZIP Code
 
 .friendof3=Show all accounts that have given you access or subscribed to you, 
and not just the ones you reciprocate.
 
@@ -253,5 +247,3 @@
 
 .userpic.none=no image uploaded
 
-.zip.usonly=5 digit ZIP code; US residents only
-
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to