TPAC: Prevent unitialized variable warnings in My Account user/mrpeters-isl/tpac_uninit_stomper_signoff
authorDan Scott <dan@coffeecode.net>
Wed, 11 Apr 2012 03:34:24 +0000 (23:34 -0400)
committerMichael Peters <mrpeters@library.in.gov>
Mon, 16 Apr 2012 16:45:58 +0000 (12:45 -0400)
Viewing a user's account preferences would trigger two uninitialized
variable warnings if the corresponding org unit settings were not set.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm

index bf01bc4..0f96013 100644 (file)
@@ -108,12 +108,12 @@ sub load_myopac_prefs {
     my $user = $self->ctx->{user};
 
     my $lock_usernames = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.lock_usernames');
-    if($lock_usernames == 1) {
+    if(defined($lock_usernames) and $lock_usernames == 1) {
         # Policy says no username changes
         $self->ctx->{username_change_disallowed} = 1;
     } else {
         my $username_unlimit = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.unlimit_usernames');
-        if($username_unlimit != 1) {
+        if(defined($username_unlimit) and $username_unlimit != 1) {
             my $regex_check = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.barcode_regex');
             if(!$regex_check) {
                 # Default is "starts with a number"
@@ -1492,14 +1492,14 @@ sub load_myopac_update_username {
     my $allow_change = 1;
     my $regex_check;
     my $lock_usernames = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.lock_usernames');
-    if($lock_usernames == 1) {
+    if(defined($lock_usernames) and $lock_usernames == 1) {
         # Policy says no username changes
         $allow_change = 0;
     } else {
         # We want this further down.
         $regex_check = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.barcode_regex');
         my $username_unlimit = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'opac.unlimit_usernames');
-        if($username_unlimit != 1) {
+        if(defined($username_unlimit) and $username_unlimit != 1) {
             if(!$regex_check) {
                 # Default is "starts with a number"
                 $regex_check = '^\d+';