3 # A Class for hiding the ILS's concept of the patron from the OpenSIP
7 package OpenILS::SIP::Patron;
13 use Sys::Syslog qw(syslog);
15 use Digest::MD5 qw(md5_hex);
18 use OpenILS::Application::AppUtils;
19 use OpenILS::Application::Actor;
20 use OpenILS::Const qw/:const/;
21 use OpenILS::Utils::DateTime qw/:datetime/;
22 use DateTime::Format::ISO8601;
23 my $U = 'OpenILS::Application::AppUtils';
25 our (@ISA, @EXPORT_OK);
29 @EXPORT_OK = qw(invalid_patron);
36 my $patron_id = shift;
39 if ($key ne 'usr' and $key ne 'barcode') {
40 syslog("LOG_ERROR", "Patron (card) lookup requested by illegeal key '$key'");
44 unless(defined $patron_id) {
45 syslog("LOG_WARNING", "No patron ID provided to ILS::Patron->new");
49 my $type = ref($class) || $class;
50 my $self = bless({}, $type);
52 syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s => %s): searching...", $key, $patron_id);
54 my $e = OpenILS::SIP->editor();
55 # Pass the authtoken, if any, to the editor so that we can use it
56 # to fake a context org_unit for the csp.ignore_proximity in
57 # flesh_user_penalties, below.
58 unless ($e->authtoken()) {
59 $e->authtoken($args{authtoken}) if ($args{authtoken});
79 # in some cases, we don't need all of this data. Only fetch the user + barcode
80 $usr_flesh = {flesh => 1, flesh_fields => {au => ['card']}} if $args{slim_user};
83 if($key eq 'barcode') { # retrieve user by barcode
85 $$usr_flesh{flesh} += 1;
86 $$usr_flesh{flesh_fields}{ac} = ['usr'];
88 my $card = $e->search_actor_card([{barcode => $patron_id}, $usr_flesh])->[0];
90 if(!$card or !$U->is_true($card->active)) {
91 syslog("LOG_WARNING", "No such patron barcode: $patron_id");
98 $user = $e->retrieve_actor_user([$patron_id, $usr_flesh]);
101 if(!$user or $U->is_true($user->deleted)) {
102 syslog("LOG_WARNING", "OILS: Unable to find patron %s => %s", $key, $patron_id);
106 if(!$U->is_true($user->active)) {
107 syslog("LOG_WARNING", "OILS: Patron is inactive %s => %s", $key, $patron_id);
111 # now grab the user's penalties
113 $self->flesh_user_penalties($user, $e) unless $args{slim_user};
115 $self->{authtoken} = $args{authtoken} if $args{authtoken};
116 $self->{editor} = $e;
117 $self->{user} = $user;
118 $self->{id} = ($key eq 'barcode') ? $patron_id : $user->card->barcode; # The barcode IS the ID to SIP.
119 # We give back the passed barcode if the key was indeed a barcode, just to be safe. Otherwise pull it from the card.
121 syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s => %s): found patron : barred=%s, card:active=%s",
122 $key, $patron_id, $user->barred, $user->card->active );
124 $U->log_user_activity($user->id, $self->get_act_who, 'verify');
131 my $config = OpenILS::SIP->config();
132 my $login = OpenILS::SIP->login_account();
134 my $act_who = $config->{implementation_config}->{default_activity_who};
135 my $force_who = $config->{implementation_config}->{force_activity_who};
137 # 1. future: test sip extension for caller-provided ewho and !$force_who
139 # 2. See if the login is tagged with an ewho
140 return $login->{activity_who} if $login->{activity_who};
142 # 3. if all else fails, see if there is an institution-wide ewho
143 return $config->{activity_who} if $config->{activity_who};
148 # grab patron penalties. Only grab non-archived penalties that are for fines,
149 # excessive overdues, or otherwise block circluation activity
150 sub flesh_user_penalties {
151 my ($self, $user, $e) = @_;
153 # Use the ws_ou or home_ou of the authsession user, if any, as a
154 # context org_unit for the penalties and the csp.ignore_proximity.
156 if ($e->authtoken()) {
157 my $auth_usr = $e->checkauth();
159 $here = $auth_usr->ws_ou() || $auth_usr->home_ou();
163 # Get the "raw" list of user's penalties and flesh the
164 # standing_penalty field, so we can filter them based on
165 # csp.ignore_proximity.
167 $e->search_actor_user_standing_penalty([
172 # ignore "archived" penalties
173 {stop_date => undef},
174 {stop_date => {'>' => 'now'}}
182 transform => 'actor.org_unit_ancestors',
188 # Use "here" or user's home_ou.
189 where => {id => ($here) ? $here : $user->home_ou},
194 # in addition to fines and excessive overdue penalties,
195 # we only care about penalties that result in blocks
196 standing_penalty => {
198 select => {csp => ['id']},
202 {id => [1,2]}, # fines / overdues
203 {block_list => {'!=' => undef}}
211 flesh_fields => {ausp => ['standing_penalty']}
214 # We filter the raw penalties that apply into this array.
215 my $applied_penalties = [];
216 if (ref($raw_penalties) eq 'ARRAY' && @$raw_penalties) {
217 my $here_prox = ($here) ? $U->get_org_unit_proximity($e, $here, $user->home_ou())
219 # Filter out those that do not apply
220 $applied_penalties = [map
221 { $_->standing_penalty }
223 !defined($_->standing_penalty->ignore_proximity())
224 || ((defined($here_prox))
225 ? $_->standing_penalty->ignore_proximity() < $here_prox
226 : $_->standing_penalty->ignore_proximity() <
227 $U->get_org_unit_proximity($e, $_->org_unit(), $user->home_ou()))
230 $user->standing_penalties($applied_penalties);
240 return format_name($self->{user});
245 return sprintf('%s %s %s',
246 ($u->first_given_name || ''),
247 ($u->second_given_name || ''),
248 ($u->family_name || ''));
253 my $lib = OpenILS::SIP::shortname_from_id($self->{user}->home_ou);
254 syslog('LOG_DEBUG', "OILS: Patron->home_library() = $lib");
260 return "" unless $addr;
261 my $return = join( ' ', map {$_ || ''}
272 $return =~ s/\s+/ /sg; # Compress any run of of whitespace to one space
278 return $self->{user}->id;
283 my $u = $self->{user};
284 my $str = __addr_string($u->billing_address || $u->mailing_address);
285 syslog('LOG_DEBUG', "OILS: Patron address: $str");
291 return $self->{user}->email;
296 return $self->{user}->day_phone;
301 my $dob = OpenILS::SIP->format_date($self->{user}->dob, 'dob');
302 syslog('LOG_DEBUG', "OILS: Patron DOB = $dob");
308 my $expire = OpenILS::SIP->format_date($self->{user}->expire_date);
309 syslog('LOG_DEBUG', "OILS: Patron Expire = $expire");
316 my $use_code = OpenILS::SIP->get_option_value('patron_type_uses_code') || '';
318 # should we use the no_i18n version of patron profile name (as a 'code')?
319 return $self->{editor}->retrieve_permission_grp_tree(
320 [$self->{user}->profile->id, {no_i18n => 1}])->name
321 if $use_code =~ /true/io;
323 return $self->{user}->profile->name;
328 return '000'; # Unspecified
331 # How much more detail do we need to check here?
332 # sec: adding logic to return false if user is barred, has a circulation block
336 my $u = $self->{user};
337 my $circ_is_blocked = 0;
339 # compute expiration date for borrowing privileges
340 my $expire = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($u->expire_date));
343 (($u->barred eq 't') or
344 (@{$u->standing_penalties} and grep { ( $_->block_list // '') =~ /CIRC/ } @{$u->standing_penalties}) or
345 (CORE::time > $expire->epoch));
350 $u->card->active eq 't';
355 my $u = $self->{user};
356 my $renew_is_blocked = 0;
358 # compute expiration date for borrowing privileges
359 my $expire = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($u->expire_date));
362 (($u->barred eq 't') or
363 (@{$u->standing_penalties} and grep { ( $_->block_list // '') =~ /RENEW/ } @{$u->standing_penalties}) or
364 (CORE::time > $expire->epoch));
367 !$renew_is_blocked &&
369 $u->card->active eq 't';
374 return $self->charge_ok if
375 OpenILS::SIP->get_option_value('patron_calculate_recal_ok');
381 my $u = $self->{user};
382 my $hold_is_blocked = 0;
384 # compute expiration date for borrowing privileges
385 my $expire = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($u->expire_date));
388 (($u->barred eq 't') or
389 (@{$u->standing_penalties} and grep { ( $_->block_list // '') =~ /HOLD/ } @{$u->standing_penalties}) or
390 (CORE::time > $expire->epoch));
395 $u->card->active eq 't';
398 # return true if the card provided is marked as lost
401 return $self->{user}->card->active eq 'f';
404 sub recall_overdue { # not implemented
410 my ($self, $pwd) = @_;
411 syslog('LOG_DEBUG', 'OILS: Patron->check_password()');
412 return 0 unless (defined $pwd and $self->{user});
413 return $U->verify_migrated_user_password(
414 $self->{editor},$self->{user}->id, $pwd);
419 syslog('LOG_DEBUG', 'OILS: Patron->currency()');
420 return OpenILS::SIP->config()->{implementation_config}->{currency} || 'USD';
425 syslog('LOG_DEBUG', 'OILS: Patron->fee_amount()');
426 my $user_id = $self->{user}->id;
428 my $e = $self->{editor};
430 my $summary = $e->retrieve_money_open_user_summary($user_id);
431 $e->rollback; # xact_rollback + disconnect
433 my $total = ($summary) ? $summary->balance_owed : 0;
434 syslog('LOG_INFO', "User ".$self->{id} .":$user_id has a fee amount of \$$total");
440 my $u = $self->{user};
442 return 'barred' if $u->barred eq 't';
446 return $b if $u->active eq 'f';
447 return $b if $u->card->active eq 'f';
449 # if we have any penalties at this point, they are blocking penalties
450 return $b if $u->standing_penalties and @{$u->standing_penalties};
452 # has the patron account expired?
453 my $expire = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($u->expire_date));
454 return $b if CORE::time > $expire->epoch;
459 sub print_line { # not implemented
464 sub too_many_charged { # not implemented
469 sub too_many_overdue {
471 return scalar( # PATRON_EXCEEDS_OVERDUE_COUNT
472 grep { $_->id == OILS_PENALTY_PATRON_EXCEEDS_OVERDUE_COUNT } @{$self->{user}->standing_penalties}
476 # not completely sure what this means
477 sub too_many_renewal {
482 # not relevant, handled by fines/fees
483 sub too_many_claim_return {
488 # not relevant, handled by fines/fees
494 sub excessive_fines {
496 return scalar( # PATRON_EXCEEDS_FINES
497 grep { $_->id == OILS_PENALTY_PATRON_EXCEEDS_FINES } @{$self->{user}->standing_penalties}
501 # Until someone suggests otherwise, fees and fines are the same
505 return $self->excessive_fines;
508 # not relevant, handled by fines/fees
509 sub too_many_billed {
517 # List of outstanding holds placed
520 my ($self, $start, $end, $ids_only) = @_;
521 syslog('LOG_DEBUG', 'OILS: Patron->hold_items()');
524 # all of my open holds
525 my $holds = $self->{editor}->search_action_hold_request({
526 usr => $self->{user}->id,
527 fulfillment_time => undef,
531 return $holds if $ids_only;
532 return $self->__format_holds($holds, $start, $end);
536 my ($self, $start, $end, $ids_only) = @_;
537 syslog('LOG_DEBUG', 'OILS: Patron->unavail_holds()');
539 my $holds = $self->{editor}->search_action_hold_request({
540 usr => $self->{user}->id,
541 fulfillment_time => undef,
542 cancel_time => undef,
544 {current_shelf_lib => undef},
545 {current_shelf_lib => {'!=' => {'+ahr' => 'pickup_lib'}}}
549 return $holds if $ids_only;
550 return $self->__format_holds($holds, $start, $end);
556 my ($self, $holds, $start, $end) = @_;
558 return [] unless @$holds;
560 my $return_datatype =
561 OpenILS::SIP->get_option_value('msg64_hold_datatype') || '';
565 for my $hold (@$holds) {
567 if ($return_datatype eq 'barcode') {
569 if (my $copy = $self->find_copy_for_hold($hold)) {
570 push(@response, $copy->barcode);
573 syslog('LOG_WARNING',
574 'OILS: No representative copy found for hold ' . $hold->id);
579 $self->__hold_to_title($hold));
583 return (defined $start and defined $end) ?
584 [ @response[($start-1)..($end-1)] ] :
588 # Finds a representative copy for the given hold.
589 # If no copy exists at all, undef is returned.
590 # The only limit placed on what constitutes a
591 # "representative" copy is that it cannot be deleted.
592 # Otherwise, any copy that allows us to find the hold
593 # later is good enough.
594 sub find_copy_for_hold {
595 my ($self, $hold) = @_;
596 my $e = $self->{editor};
598 return $e->retrieve_asset_copy($hold->current_copy)
599 if $hold->current_copy;
601 return $e->retrieve_asset_copy($hold->target)
602 if $hold->hold_type =~ /C|R|F/;
604 return $e->search_asset_copy([
605 {call_number => $hold->target, deleted => 'f'},
606 {limit => 1}])->[0] if $hold->hold_type eq 'V';
608 my $bre_ids = [$hold->target];
610 if ($hold->hold_type eq 'M') {
611 # find all of the bibs that link to the target metarecord
612 my $maps = $e->search_metabib_metarecord_source_map(
613 {metarecord => $hold->target});
614 $bre_ids = [map {$_->record} @$maps];
617 my $vol_ids = $e->search_asset_call_number(
618 {record => $bre_ids, deleted => 'f'},
622 return $e->search_asset_copy([
623 {call_number => $vol_ids, deleted => 'f'},
628 # Given a "representative" copy, finds a matching hold
629 sub find_hold_from_copy {
630 my ($self, $barcode) = @_;
631 my $e = $self->{editor};
634 my $copy = $e->search_asset_copy([
635 {barcode => $barcode, deleted => 'f'},
636 {flesh => 1, flesh_fields => {acp => ['call_number']}}
639 return undef unless $copy;
641 my $run_hold_query = sub {
643 return $e->search_action_hold_request([
644 { usr => $self->{user}->id,
645 cancel_time => undef,
646 fulfillment_time => undef,
650 order_by => {ahr => 'request_time DESC'}
655 # first see if there is a match on current_copy
656 return $hold if $hold =
657 $run_hold_query->(current_copy => $copy->id);
659 # next, assume bib-level holds are the most common
660 return $hold if $hold = $run_hold_query->(
661 target => $copy->call_number->record, hold_type => 'T');
663 # next try metarecord holds
664 my $map = $e->search_metabib_metarecord_source_map(
665 {source => $copy->call_number->record})->[0];
667 return $hold if $hold = $run_hold_query->(
668 target => $map->metarecord, hold_type => 'M');
671 return $hold if $hold = $run_hold_query->(
672 target => $copy->call_number->id, hold_type => 'V');
675 return $run_hold_query->(
676 target => $copy->id, hold_type => ['C', 'F', 'R']);
679 sub __hold_to_title {
682 my $e = $self->{editor};
684 my( $id, $mods, $title, $volume, $copy );
686 return __copy_to_title($e,
687 $e->retrieve_asset_copy($hold->target))
688 if $hold->hold_type eq 'C' or $hold->hold_type eq 'F' or $hold->hold_type eq 'R';
690 return __volume_to_title($e,
691 $e->retrieve_asset_call_number($hold->target))
692 if $hold->hold_type eq 'V';
694 return __record_to_title(
695 $e, $hold->target) if $hold->hold_type eq 'T';
697 return __metarecord_to_title(
698 $e, $hold->target) if $hold->hold_type eq 'M';
701 sub __copy_to_title {
702 my( $e, $copy ) = @_;
703 #syslog('LOG_DEBUG', "OILS: copy_to_title(%s)", $copy->id);
704 return $copy->dummy_title if $copy->call_number == -1;
706 my $vol = (ref $copy->call_number) ?
708 $e->retrieve_asset_call_number($copy->call_number);
710 return __volume_to_title($e, $vol);
714 sub __volume_to_title {
715 my( $e, $volume ) = @_;
716 #syslog('LOG_DEBUG', "OILS: volume_to_title(%s)", $volume->id);
717 return __record_to_title($e, $volume->record);
721 sub __record_to_title {
722 my( $e, $title_id ) = @_;
723 #syslog('LOG_DEBUG', "OILS: record_to_title($title_id)");
724 my $mods = $U->simplereq(
726 'open-ils.search.biblio.record.mods_slim.retrieve', $title_id );
727 return ($mods) ? $mods->title : "";
730 sub __metarecord_to_title {
731 my( $e, $m_id ) = @_;
732 #syslog('LOG_DEBUG', "OILS: metarecord_to_title($m_id)");
733 my $mods = $U->simplereq(
735 'open-ils.search.biblio.metarecord.mods_slim.retrieve', $m_id);
736 return ($U->event_code($mods)) ? "<unknown>" : $mods->title;
741 # remove the hold on item item_id from my hold queue.
742 # return true if I was holding the item, false otherwise.
745 my ($self, $item_id) = @_;
749 sub __patron_items_info {
751 return if $self->{item_info};
753 OpenILS::Application::Actor::_checked_out(
754 0, $self->{editor}, $self->{user}->id);;
760 my ($self, $start, $end, $ids_only) = @_;
762 $self->__patron_items_info();
763 my @overdues = @{$self->{item_info}->{overdue}};
764 #$overdues[$_] = __circ_to_title($self->{editor}, $overdues[$_]) for @overdues;
766 return \@overdues if $ids_only;
769 syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circs @overdues");
771 my $return_datatype = OpenILS::SIP->get_option_value('msg64_summary_datatype') || '';
773 for my $circid (@overdues) {
775 if($return_datatype eq 'barcode') {
776 push( @o, __circ_to_barcode($self->{editor}, $circid));
778 push( @o, __circ_to_title($self->{editor}, $circid));
783 return (defined $start and defined $end) ?
784 [ @overdues[($start-1)..($end-1)] ] : \@overdues;
787 sub __circ_to_barcode {
790 $circ = $e->retrieve_action_circulation($circ);
791 my $copy = $e->retrieve_asset_copy($circ->target_copy);
792 return $copy->barcode;
795 sub __circ_to_title {
796 my( $e, $circ ) = @_;
798 $circ = $e->retrieve_action_circulation($circ);
799 return __copy_to_title( $e,
800 $e->retrieve_asset_copy($circ->target_copy) );
804 my ($self, $start, $end, $ids_only) = shift;
805 return $self->charged_items_impl($start, $end, undef, $ids_only);
808 # implementation method
809 # force_bc -- return barcode data regardless of msg64_summary_datatype;
810 # this is used by the renew-all code
811 sub charged_items_impl {
812 my ($self, $start, $end, $force_bc, $ids_only) = shift;
814 $self->__patron_items_info();
817 @{$self->{item_info}->{out}},
818 @{$self->{item_info}->{overdue}}
821 #$charges[$_] = __circ_to_title($self->{editor}, $charges[$_]) for @charges;
823 return \@charges if $ids_only;
826 syslog('LOG_DEBUG', "OILS: charged_items() fleshing circs @charges");
828 my $return_datatype = OpenILS::SIP->get_option_value('msg64_summary_datatype') || '';
830 for my $circid (@charges) {
832 if($return_datatype eq 'barcode' or $force_bc) {
833 push( @c, __circ_to_barcode($self->{editor}, $circid));
835 push( @c, __circ_to_title($self->{editor}, $circid));
841 return (defined $start and defined $end) ?
842 [ @charges[($start-1)..($end-1)] ] :
847 my ($self, $start, $end, $ids_only) = @_;
850 my $xacts = $U->simplereq('open-ils.actor', 'open-ils.actor.user.transactions.history.have_balance', $self->{authtoken}, $self->{user}->id);
851 foreach my $xact (@{$xacts}) {
856 my $line = $xact->balance_owed . " " . $xact->last_billing_type . " ";
857 if ($xact->xact_type eq 'circulation') {
858 my $mods = $U->simplereq('open-ils.circ', 'open-ils.circ.circ_transaction.find_title', $self->{authtoken}, $xact->id);
859 $line .= $mods->title . ' / ' . $mods->author;
861 $line .= $xact->last_billing_note;
866 my $log_status = $@ ? 'ERROR: ' . $@ : 'OK';
867 syslog('LOG_DEBUG', 'OILS: Patron->fine_items() ' . $log_status);
868 return (defined $start and defined $end) ?
869 [ @fines[($start-1)..($end-1)] ] : \@fines;
872 # not currently supported
874 my ($self, $start, $end, $ids_only) = @_;
879 my ($self, $card_retained, $blocked_card_msg) = @_;
880 $blocked_card_msg ||= '';
882 my $e = $self->{editor};
883 my $u = $self->{user};
885 syslog('LOG_INFO', "OILS: Blocking user %s", $u->card->barcode );
887 return $self if $u->card->active eq 'f';
889 $e->xact_begin; # connect and start a new transaction
891 $u->card->active('f');
892 if( ! $e->update_actor_card($u->card) ) {
893 syslog('LOG_ERR', "OILS: Block card update failed: %s", $e->event->{textcode});
894 $e->rollback; # rollback + disconnect
898 # retrieve the un-fleshed user object for update
899 $u = $e->retrieve_actor_user($u->id);
900 my $note = $u->alert_message || "";
901 $note = "<sip> CARD BLOCKED BY SELF-CHECK MACHINE. $blocked_card_msg</sip>\n$note"; # XXX Config option
902 $note =~ s/\s*$//; # kill trailng whitespace
903 $u->alert_message($note);
905 if( ! $e->update_actor_user($u) ) {
906 syslog('LOG_ERR', "OILS: Block: patron alert update failed: %s", $e->event->{textcode});
907 $e->rollback; # rollback + disconnect
912 $self->{user}->alert_message( $note );
914 $e->commit; # commits and disconnects
918 # Testing purposes only
920 my ($self, $card_retained) = @_;
921 $self->{screen_msg} = "All privileges restored.";
923 # Un-mark card as inactive, grep out the patron alert
924 my $e = $self->{editor};
925 my $u = $self->{user};
927 syslog('LOG_INFO', "OILS: Unblocking user %s", $u->card->barcode );
929 return $self if $u->card->active eq 't';
931 $e->xact_begin; # connect and start a new transaction
933 $u->card->active('t');
934 if( ! $e->update_actor_card($u->card) ) {
935 syslog('LOG_ERR', "OILS: Unblock card update failed: %s", $e->event->{textcode});
936 $e->rollback; # rollback + disconnect
940 # retrieve the un-fleshed user object for update
941 $u = $e->retrieve_actor_user($u->id);
942 my $note = $u->alert_message || "";
943 $note =~ s#<sip>.*</sip>##;
944 $note =~ s/^\s*//; # kill leading whitespace
945 $note =~ s/\s*$//; # kill trailng whitespace
946 $u->alert_message($note);
948 if( ! $e->update_actor_user($u) ) {
949 syslog('LOG_ERR', "OILS: Unblock: patron alert update failed: %s", $e->event->{textcode});
950 $e->rollback; # rollback + disconnect
955 $self->{user}->alert_message( $note );
957 $e->commit; # commits and disconnects
966 return "Please contact library staff";
970 return "Please contact library staff";
973 sub inet_privileges {
975 my $e = OpenILS::SIP->editor();
976 $INET_PRIVS = $e->retrieve_all_config_net_access_level() unless $INET_PRIVS;
977 my ($level) = grep { $_->id eq $self->{user}->net_access_level } @$INET_PRIVS;
978 my $name = $level->name;
979 syslog('LOG_DEBUG', "OILS: Patron inet_privs = $name");
985 my $extra_fields = {};
986 my $u = $self->{user};
987 foreach my $stat_cat_entry (@{$u->stat_cat_entries}) {
988 my $stat_cat = $stat_cat_entry->stat_cat;
989 next unless ($stat_cat->sip_field);
990 my $value = $stat_cat_entry->stat_cat_entry;
991 if(defined $stat_cat->sip_format && length($stat_cat->sip_format) > 0) { # Has a format string?
992 if($stat_cat->sip_format =~ /^\|(.*)\|$/) { # Regex match?
993 if($value =~ /($1)/) { # If we have a match
994 if(defined $2) { # Check to see if they embedded a capture group
995 $value = $2; # If so, use it
997 else { # No embedded capture group?
998 $value = $1; # Use our outer one
1002 $value = ''; # Empty string. Will be checked for below.
1005 else { # Not a regex match - Try sprintf match (looking for a %s, if any)
1006 $value = sprintf($stat_cat->sip_format, $value);
1009 next unless length($value) > 0; # No value = no export
1010 $value =~ s/\|//g; # Remove all lingering pipe chars for sane output purposes
1011 $extra_fields->{ $stat_cat->sip_field } = [] unless (defined $extra_fields->{$stat_cat->sip_field});
1012 push(@{$extra_fields->{ $stat_cat->sip_field}}, $value);
1014 return $extra_fields;