From: Dan Scott <dan@coffeecode.net>
Date: Wed, 11 Apr 2012 03:34:24 +0000 (-0400)
Subject: TPAC: Prevent unitialized variable warnings in My Account
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c2eb7d12fc491d15217995340b37e35565dd57d6;p=contrib%2FConifer.git

TPAC: Prevent unitialized variable warnings in My Account

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>
---

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 7399f34ba8..c7d91355d5 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -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"
@@ -1490,14 +1490,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+';