TPAC: Prevent unitialized variable warnings in My Account
authorDan Scott <dan@coffeecode.net>
Wed, 11 Apr 2012 03:34:24 +0000 (23:34 -0400)
committerDan Scott <dan@coffeecode.net>
Sun, 3 Jun 2012 01:28:07 +0000 (21:28 -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 7399f34..c7d9135 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"
@@ -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+';