Add fix to Evergreen driver for missing hold notification parameters.
[working/NCIPServer.git] / lib / NCIP / ILS / Evergreen.pm
index 2e2bbd5..85aa440 100644 (file)
@@ -2355,21 +2355,29 @@ sub place_hold {
             }
             if ($hold_notify->value() =~ /phone/) {
                 my ($default_phone) = grep {$_->name() eq 'opac.default_phone'} @{$user->settings()};
+                # We need to validate the value, because it could be an empty string.
                 if ($default_phone) {
-                    $params->{phone_notify} = $default_phone->value();
-                    $params->{phone_notify} =~ s/"//g;
-                } elsif ($user->day_phone()) {
-                    $params->{phone_notify} = $user->day_phone();
+                    $default_phone = $default_phone->value();
+                    $default_phone =~ s/"//g;
                 }
+                # Use day phone as fallback if it is empty.
+                $default_phone = $user->day_phone() unless ($default_phone);
+                $params->{phone_notify} = $default_phone if ($default_phone);
             }
             if ($hold_notify->value() =~ /sms/) {
                 my ($sms_carrier) = grep {$_->name() eq 'opac.default_sms_carrier'} @{$user->settings()};
                 my ($sms_notify) = grep {$_->name() eq 'opac.default_sms_notify'} @{$user->settings()};
                 if ($sms_carrier && $sms_notify) {
-                    $params->{sms_carrier} = $sms_carrier->value();
-                    $params->{sms_notify} = $sms_notify->value();
-                    $params->{sms_carrier} =~ s/"//g;
-                    $params->{sms_notify} =~ s/"//g;
+                    # We need to validate the values as well, because
+                    # they can be empty strings.
+                    $sms_carrier = $sms_carrier->value();
+                    $sms_carrier =~ s/"//g;
+                    $sms_notify = $sms_notify->value();
+                    $sms_notify =~ s/"//g;
+                    if ($sms_carrier && $sms_notify) {
+                        $params->{sms_carrier} = $sms_carrier;
+                        $params->{sms_notify} = $sms_notify;
+                    }
                 }
             }
         } else {