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

[dw-free] difficulty clearing phone number from DW/Setting/TxtMsgSetup

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

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

If only one of them is blank, still show an error message, because it's more
likely to be that they mistakenly left out a field)

Patch by [personal profile] yvi.

Files modified:
  • cgi-bin/DW/Setting/TxtMsgSetup.pm
--------------------------------------------------------------------------------
diff -r 81a0b4f1f303 -r c0339463c489 cgi-bin/DW/Setting/TxtMsgSetup.pm
--- a/cgi-bin/DW/Setting/TxtMsgSetup.pm	Tue Oct 12 17:59:42 2010 +0800
+++ b/cgi-bin/DW/Setting/TxtMsgSetup.pm	Tue Oct 12 18:05:10 2010 +0800
@@ -120,14 +120,18 @@ sub error_check {
     # only validate info if security is enforced
     my $number = $class->get_arg( $args, "txtmsg_number" );
     my $provider = $class->get_arg( $args, "txtmsg_provider" );
+
+    # only do further error checking if the user didn't delete both the number and the provider
     if ( $security && $security ne 'none' ) {
-        # check for something that looks like a phone number
-        $class->errors( txtmsg_number => $class->ml( 'setting.txtmsgsetup.error.number' ) )
-            unless $number && $number =~ /^[-+0-9]{9,}$/;
-        # check for valid provider
-        my %valid = map { $_ => 1 } LJ::TextMessage::providers();
-        $class->errors( txtmsg_provider => $class->ml( 'setting.txtmsgsetup.error.provider' ) )
-            unless $provider && $valid{$provider};
+        if ( $provider || $number ) {
+            # check for something that looks like a phone number
+            $class->errors( txtmsg_number => $class->ml( 'setting.txtmsgsetup.error.number' ) )
+                    unless ( $number && $number =~ /^[-+0-9]{9,}$/ );
+            # check for valid provider
+            my %valid = map { $_ => 1 } LJ::TextMessage::providers();
+            $class->errors( txtmsg_provider => $class->ml( 'setting.txtmsgsetup.error.provider' ) )
+                    unless ( $provider && $valid{$provider} );
+        }
     } else {  # warn them that new info won't be saved
         my $tminfo = LJ::TextMessage->tm_info( $u, remap_result => 1 );
         $class->errors( txtmsg_number => $class->ml( 'setting.txtmsgsetup.error.notsecured' ) )
--------------------------------------------------------------------------------

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