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 OpenSRF::Utils qw/:datetime/;
21 use DateTime::Format::ISO8601;
22 my $U = 'OpenILS::Application::AppUtils';
24 our (@ISA, @EXPORT_OK);
28 @EXPORT_OK = qw(invalid_patron);
35 my $patron_id = shift;
38 if ($key ne 'usr' and $key ne 'barcode') {
39 syslog("LOG_ERROR", "Patron (card) lookup requested by illegeal key '$key'");
43 unless(defined $patron_id) {
44 syslog("LOG_WARNING", "No patron ID provided to ILS::Patron->new");
48 my $type = ref($class) || $class;
49 my $self = bless({}, $type);
51 syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s => %s): searching...", $key, $patron_id);
53 my $e = OpenILS::SIP->editor();
54 # Pass the authtoken, if any, to the editor so that we can use it
55 # to fake a context org_unit for the csp.ignore_proximity in
56 # flesh_user_penalties, below.
57 unless ($e->authtoken()) {
58 $e->authtoken($args{authtoken}) if ($args{authtoken});
78 # in some cases, we don't need all of this data. Only fetch the user + barcode
79 $usr_flesh = {flesh => 1, flesh_fields => {au => ['card']}} if $args{slim_user};
82 if($key eq 'barcode') { # retrieve user by barcode
84 $$usr_flesh{flesh} += 1;
85 $$usr_flesh{flesh_fields}{ac} = ['usr'];
87 my $card = $e->search_actor_card([{barcode => $patron_id}, $usr_flesh])->[0];
89 if(!$card or !$U->is_true($card->active)) {
90 syslog("LOG_WARNING", "No such patron barcode: $patron_id");
97 $user = $e->retrieve_actor_user([$patron_id, $usr_flesh]);
100 if(!$user or $U->is_true($user->deleted)) {
101 syslog("LOG_WARNING", "OILS: Unable to find patron %s => %s", $key, $patron_id);
105 if(!$U->is_true($user->active)) {
106 syslog("LOG_WARNING", "OILS: Patron is inactive %s => %s", $key, $patron_id);
110 # now grab the user's penalties
112 $self->flesh_user_penalties($user, $e) unless $args{slim_user};
114 $self->{authtoken} = $args{authtoken} if $args{authtoken};
115 $self->{editor} = $e;
116 $self->{user} = $user;
117 $self->{id} = ($key eq 'barcode') ? $patron_id : $user->card->barcode; # The barcode IS the ID to SIP.
118 # We give back the passed barcode if the key was indeed a barcode, just to be safe. Otherwise pull it from the card.
120 syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s => %s): found patron : barred=%s, card:active=%s",
121 $key, $patron_id, $user->barred, $user->card->active );
123 $U->log_user_activity($user->id, $self->get_act_who, 'verify');
130 my $config = OpenILS::SIP->config();
131 my $login = OpenILS::SIP->login_account();
133 my $act_who = $config->{implementation_config}->{default_activity_who};
134 my $force_who = $config->{implementation_config}->{force_activity_who};
136 # 1. future: test sip extension for caller-provided ewho and !$force_who
138 # 2. See if the login is tagged with an ewho
139 return $login->{activity_who} if $login->{activity_who};
141 # 3. if all else fails, see if there is an institution-wide ewho
142 return $config->{activity_who} if $config->{activity_who};
147 # grab patron penalties. Only grab non-archived penalties that are for fines,
148 # excessive overdues, or otherwise block circluation activity
149 sub flesh_user_penalties {
150 my ($self, $user, $e) = @_;
152 # Use the ws_ou or home_ou of the authsession user, if any, as a
153 # context org_unit for the penalties and the csp.ignore_proximity.
155 if ($e->authtoken()) {
156 my $auth_usr = $e->checkauth();
158 $here = $auth_usr->ws_ou() || $auth_usr->home_ou();
162 # Get the "raw" list of user's penalties and flesh the
163 # standing_penalty field, so we can filter them based on
164 # csp.ignore_proximity.
166 $e->search_actor_user_standing_penalty([
171 # ignore "archived" penalties
172 {stop_date => undef},
173 {stop_date => {'>' => 'now'}}
181 transform => 'actor.org_unit_ancestors',
187 # Use "here" or user's home_ou.
188 where => {id => ($here) ? $here : $user->home_ou},
193 # in addition to fines and excessive overdue penalties,
194 # we only care about penalties that result in blocks
195 standing_penalty => {
197 select => {csp => ['id']},
201 {id => [1,2]}, # fines / overdues
202 {block_list => {'!=' => undef}}
210 flesh_fields => {ausp => ['standing_penalty']}
213 # We filter the raw penalties that apply into this array.
214 my $applied_penalties = [];
215 if (ref($raw_penalties) eq 'ARRAY' && @$raw_penalties) {
216 my $here_prox = ($here) ? $U->get_org_unit_proximity($e, $here, $user->home_ou())
218 # Filter out those that do not apply and deflesh the standing_penalty.
219 $applied_penalties = [map
220 { $_->standing_penalty($_->standing_penalty->id()) }
222 !defined($_->standing_penalty->ignore_proximity())
223 || ((defined($here_prox))
224 ? $_->standing_penalty->ignore_proximity() < $here_prox
225 : $_->standing_penalty->ignore_proximity() <
226 $U->get_org_unit_proximity($e, $_->org_unit(), $user->home_ou()))
229 $user->standing_penalties($applied_penalties);
239 return format_name($self->{user});
244 return OpenILS::SIP::clean_text(
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 = OpenILS::SIP::clean_text(
262 join( ' ', map {$_ || ''} (
273 $return =~ s/\s+/ /sg; # Compress any run of of whitespace to one space
279 return $self->{user}->id;
284 my $u = $self->{user};
285 my $str = __addr_string($u->billing_address || $u->mailing_address);
286 syslog('LOG_DEBUG', "OILS: Patron address: $str");
292 return OpenILS::SIP::clean_text($self->{user}->email);
297 return $self->{user}->day_phone;
302 my $dob = OpenILS::SIP->format_date($self->{user}->dob);
303 syslog('LOG_DEBUG', "OILS: Patron DOB = $dob");
309 my $expire = OpenILS::SIP->format_date($self->{user}->expire_date);
310 syslog('LOG_DEBUG', "OILS: Patron Expire = $expire");
317 my $use_code = OpenILS::SIP->get_option_value('patron_type_uses_code') || '';
319 # should we use the no_i18n version of patron profile name (as a 'code')?
320 return $self->{editor}->retrieve_permission_grp_tree(
321 [$self->{user}->profile->id, {no_i18n => 1}])->name
322 if $use_code =~ /true/io;
324 return OpenILS::SIP::clean_text($self->{user}->profile->name);
329 return '000'; # Unspecified
332 # How much more detail do we need to check here?
333 # sec: adding logic to return false if user is barred, has a circulation block
337 my $u = $self->{user};
339 # compute expiration date for borrowing privileges
340 my $expire = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($u->expire_date));
342 # determine whether patron should be allowed to circulate materials:
343 # not barred, doesn't owe too much wrt fines/fees, privileges haven't
345 my $circ_is_blocked =
346 (($u->barred eq 't') or
347 ($u->standing_penalties and @{$u->standing_penalties}) or
348 (CORE::time > $expire->epoch));
351 !$circ_is_blocked and
352 $u->active eq 't' and
353 $u->card->active eq 't';
358 # How much more detail do we need to check here?
361 return $self->charge_ok;
366 return $self->charge_ok if
367 OpenILS::SIP->get_option_value('patron_calculate_recal_ok');
373 return $self->charge_ok;
376 # return true if the card provided is marked as lost
379 return $self->{user}->card->active eq 'f';
382 sub recall_overdue { # not implemented
388 my ($self, $pwd) = @_;
389 syslog('LOG_DEBUG', 'OILS: Patron->check_password()');
390 return 0 unless (defined $pwd and $self->{user});
391 return md5_hex($pwd) eq $self->{user}->passwd;
394 sub currency { # not really implemented
396 syslog('LOG_DEBUG', 'OILS: Patron->currency()');
402 syslog('LOG_DEBUG', 'OILS: Patron->fee_amount()');
403 my $user_id = $self->{user}->id;
405 my $e = $self->{editor};
407 my $summary = $e->retrieve_money_open_user_summary($user_id);
408 $e->rollback; # xact_rollback + disconnect
410 my $total = ($summary) ? $summary->balance_owed : 0;
411 syslog('LOG_INFO', "User ".$self->{id} .":$user_id has a fee amount of \$$total");
417 my $u = $self->{user};
419 return 'barred' if $u->barred eq 't';
423 return $b if $u->active eq 'f';
424 return $b if $u->card->active eq 'f';
426 # if we have any penalties at this point, they are blocking penalties
427 return $b if $u->standing_penalties and @{$u->standing_penalties};
429 # has the patron account expired?
430 my $expire = DateTime::Format::ISO8601->new->parse_datetime(cleanse_ISO8601($u->expire_date));
431 return $b if CORE::time > $expire->epoch;
436 sub print_line { # not implemented
441 sub too_many_charged { # not implemented
446 sub too_many_overdue {
448 return scalar( # PATRON_EXCEEDS_OVERDUE_COUNT
449 grep { $_->standing_penalty == 2 } @{$self->{user}->standing_penalties}
453 # not completely sure what this means
454 sub too_many_renewal {
459 # not relevant, handled by fines/fees
460 sub too_many_claim_return {
465 # not relevant, handled by fines/fees
471 sub excessive_fines {
473 return scalar( # PATRON_EXCEEDS_FINES
474 grep { $_->standing_penalty == 1 } @{$self->{user}->standing_penalties}
478 # Until someone suggests otherwise, fees and fines are the same
482 return $self->excessive_fines;
485 # not relevant, handled by fines/fees
486 sub too_many_billed {
494 # List of outstanding holds placed
497 my ($self, $start, $end, $ids_only) = @_;
498 syslog('LOG_DEBUG', 'OILS: Patron->hold_items()');
501 # all of my open holds
502 my $holds = $self->{editor}->search_action_hold_request({
503 usr => $self->{user}->id,
504 fulfillment_time => undef,
508 return $holds if $ids_only;
509 return $self->__format_holds($holds, $start, $end);
513 my ($self, $start, $end, $ids_only) = @_;
514 syslog('LOG_DEBUG', 'OILS: Patron->unavail_holds()');
516 my $holds = $self->{editor}->search_action_hold_request({
517 usr => $self->{user}->id,
518 fulfillment_time => undef,
519 cancel_time => undef,
521 {current_shelf_lib => undef},
522 {current_shelf_lib => {'!=' => {'+ahr' => 'pickup_lib'}}}
526 return $holds if $ids_only;
527 return $self->__format_holds($holds, $start, $end);
533 my ($self, $holds, $start, $end) = @_;
535 return [] unless @$holds;
537 my $return_datatype =
538 OpenILS::SIP->get_option_value('msg64_hold_datatype') || '';
542 for my $hold (@$holds) {
544 if ($return_datatype eq 'barcode') {
546 if (my $copy = $self->find_copy_for_hold($hold)) {
547 push(@response, $copy->barcode);
550 syslog('LOG_WARNING',
551 'OILS: No representative copy found for hold ' . $hold->id);
556 OpenILS::SIP::clean_text($self->__hold_to_title($hold)));
560 return (defined $start and defined $end) ?
561 [ @response[($start-1)..($end-1)] ] :
565 # Finds a representative copy for the given hold.
566 # If no copy exists at all, undef is returned.
567 # The only limit placed on what constitutes a
568 # "representative" copy is that it cannot be deleted.
569 # Otherwise, any copy that allows us to find the hold
570 # later is good enough.
571 sub find_copy_for_hold {
572 my ($self, $hold) = @_;
573 my $e = $self->{editor};
575 return $e->retrieve_asset_copy($hold->current_copy)
576 if $hold->current_copy;
578 return $e->retrieve_asset_copy($hold->target)
579 if $hold->hold_type =~ /C|R|F/;
581 return $e->search_asset_copy([
582 {call_number => $hold->target, deleted => 'f'},
583 {limit => 1}])->[0] if $hold->hold_type eq 'V';
585 my $bre_ids = [$hold->target];
587 if ($hold->hold_type eq 'M') {
588 # find all of the bibs that link to the target metarecord
589 my $maps = $e->search_metabib_metarecord_source_map(
590 {metarecord => $hold->target});
591 $bre_ids = [map {$_->record} @$maps];
594 my $vol_ids = $e->search_asset_call_number(
595 {record => $bre_ids, deleted => 'f'},
599 return $e->search_asset_copy([
600 {call_number => $vol_ids, deleted => 'f'},
605 # Given a "representative" copy, finds a matching hold
606 sub find_hold_from_copy {
607 my ($self, $barcode) = @_;
608 my $e = $self->{editor};
611 my $copy = $e->search_asset_copy([
612 {barcode => $barcode, deleted => 'f'},
613 {flesh => 1, flesh_fields => {acp => ['call_number']}}
616 return undef unless $copy;
618 my $run_hold_query = sub {
620 return $e->search_action_hold_request([
621 { usr => $self->{user}->id,
622 cancel_time => undef,
623 fulfillment_time => undef,
627 order_by => {ahr => 'request_time DESC'}
632 # first see if there is a match on current_copy
633 return $hold if $hold =
634 $run_hold_query->(current_copy => $copy->id);
636 # next, assume bib-level holds are the most common
637 return $hold if $hold = $run_hold_query->(
638 target => $copy->call_number->record, hold_type => 'T');
640 # next try metarecord holds
641 my $map = $e->search_metabib_metarecord_source_map(
642 {source => $copy->call_number->record})->[0];
644 return $hold if $hold = $run_hold_query->(
645 target => $map->metarecord, hold_type => 'M');
648 return $hold if $hold = $run_hold_query->(
649 target => $copy->call_number->id, hold_type => 'V');
652 return $run_hold_query->(
653 target => $copy->id, hold_type => ['C', 'F', 'R']);
656 sub __hold_to_title {
659 my $e = $self->{editor};
661 my( $id, $mods, $title, $volume, $copy );
663 return __copy_to_title($e,
664 $e->retrieve_asset_copy($hold->target))
665 if $hold->hold_type eq 'C' or $hold->hold_type eq 'F' or $hold->hold_type eq 'R';
667 return __volume_to_title($e,
668 $e->retrieve_asset_call_number($hold->target))
669 if $hold->hold_type eq 'V';
671 return __record_to_title(
672 $e, $hold->target) if $hold->hold_type eq 'T';
674 return __metarecord_to_title(
675 $e, $hold->target) if $hold->hold_type eq 'M';
678 sub __copy_to_title {
679 my( $e, $copy ) = @_;
680 #syslog('LOG_DEBUG', "OILS: copy_to_title(%s)", $copy->id);
681 return $copy->dummy_title if $copy->call_number == -1;
683 my $vol = (ref $copy->call_number) ?
685 $e->retrieve_asset_call_number($copy->call_number);
687 return __volume_to_title($e, $vol);
691 sub __volume_to_title {
692 my( $e, $volume ) = @_;
693 #syslog('LOG_DEBUG', "OILS: volume_to_title(%s)", $volume->id);
694 return __record_to_title($e, $volume->record);
698 sub __record_to_title {
699 my( $e, $title_id ) = @_;
700 #syslog('LOG_DEBUG', "OILS: record_to_title($title_id)");
701 my $mods = $U->simplereq(
703 'open-ils.search.biblio.record.mods_slim.retrieve', $title_id );
704 return ($mods) ? $mods->title : "";
707 sub __metarecord_to_title {
708 my( $e, $m_id ) = @_;
709 #syslog('LOG_DEBUG', "OILS: metarecord_to_title($m_id)");
710 my $mods = $U->simplereq(
712 'open-ils.search.biblio.metarecord.mods_slim.retrieve', $m_id);
713 return ($U->event_code($mods)) ? "<unknown>" : $mods->title;
718 # remove the hold on item item_id from my hold queue.
719 # return true if I was holding the item, false otherwise.
722 my ($self, $item_id) = @_;
726 sub __patron_items_info {
728 return if $self->{item_info};
730 OpenILS::Application::Actor::_checked_out(
731 0, $self->{editor}, $self->{user}->id);;
737 my ($self, $start, $end, $ids_only) = @_;
739 $self->__patron_items_info();
740 my @overdues = @{$self->{item_info}->{overdue}};
741 #$overdues[$_] = __circ_to_title($self->{editor}, $overdues[$_]) for @overdues;
743 return \@overdues if $ids_only;
746 syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circs @overdues");
748 my $return_datatype = OpenILS::SIP->get_option_value('msg64_summary_datatype') || '';
750 for my $circid (@overdues) {
752 if($return_datatype eq 'barcode') {
753 push( @o, __circ_to_barcode($self->{editor}, $circid));
755 push( @o, OpenILS::SIP::clean_text(__circ_to_title($self->{editor}, $circid)));
760 return (defined $start and defined $end) ?
761 [ @overdues[($start-1)..($end-1)] ] : \@overdues;
764 sub __circ_to_barcode {
767 $circ = $e->retrieve_action_circulation($circ);
768 my $copy = $e->retrieve_asset_copy($circ->target_copy);
769 return $copy->barcode;
772 sub __circ_to_title {
773 my( $e, $circ ) = @_;
775 $circ = $e->retrieve_action_circulation($circ);
776 return __copy_to_title( $e,
777 $e->retrieve_asset_copy($circ->target_copy) );
781 my ($self, $start, $end, $ids_only) = shift;
782 return $self->charged_items_impl($start, $end, undef, $ids_only);
785 # implementation method
786 # force_bc -- return barcode data regardless of msg64_summary_datatype;
787 # this is used by the renew-all code
788 sub charged_items_impl {
789 my ($self, $start, $end, $force_bc, $ids_only) = shift;
791 $self->__patron_items_info();
794 @{$self->{item_info}->{out}},
795 @{$self->{item_info}->{overdue}}
798 #$charges[$_] = __circ_to_title($self->{editor}, $charges[$_]) for @charges;
800 return \@charges if $ids_only;
803 syslog('LOG_DEBUG', "OILS: charged_items() fleshing circs @charges");
805 my $return_datatype = OpenILS::SIP->get_option_value('msg64_summary_datatype') || '';
807 for my $circid (@charges) {
809 if($return_datatype eq 'barcode' or $force_bc) {
810 push( @c, __circ_to_barcode($self->{editor}, $circid));
812 push( @c, OpenILS::SIP::clean_text(__circ_to_title($self->{editor}, $circid)));
818 return (defined $start and defined $end) ?
819 [ @charges[($start-1)..($end-1)] ] :
824 my ($self, $start, $end, $ids_only) = @_;
827 my $xacts = $U->simplereq('open-ils.actor', 'open-ils.actor.user.transactions.history.have_balance', $self->{authtoken}, $self->{user}->id);
828 foreach my $xact (@{$xacts}) {
833 my $line = $xact->balance_owed . " " . $xact->last_billing_type . " ";
834 if ($xact->xact_type eq 'circulation') {
835 my $mods = $U->simplereq('open-ils.circ', 'open-ils.circ.circ_transaction.find_title', $self->{authtoken}, $xact->id);
836 $line .= $mods->title . ' / ' . $mods->author;
838 $line .= $xact->last_billing_note;
840 push @fines, OpenILS::SIP::clean_text($line);
843 my $log_status = $@ ? 'ERROR: ' . $@ : 'OK';
844 syslog('LOG_DEBUG', 'OILS: Patron->fine_items() ' . $log_status);
845 return (defined $start and defined $end) ?
846 [ @fines[($start-1)..($end-1)] ] : \@fines;
849 # not currently supported
851 my ($self, $start, $end, $ids_only) = @_;
856 my ($self, $card_retained, $blocked_card_msg) = @_;
857 $blocked_card_msg ||= '';
859 my $e = $self->{editor};
860 my $u = $self->{user};
862 syslog('LOG_INFO', "OILS: Blocking user %s", $u->card->barcode );
864 return $self if $u->card->active eq 'f';
866 $e->xact_begin; # connect and start a new transaction
868 $u->card->active('f');
869 if( ! $e->update_actor_card($u->card) ) {
870 syslog('LOG_ERR', "OILS: Block card update failed: %s", $e->event->{textcode});
871 $e->rollback; # rollback + disconnect
875 # retrieve the un-fleshed user object for update
876 $u = $e->retrieve_actor_user($u->id);
877 my $note = OpenILS::SIP::clean_text($u->alert_message) || "";
878 $note = "<sip> CARD BLOCKED BY SELF-CHECK MACHINE. $blocked_card_msg</sip>\n$note"; # XXX Config option
879 $note =~ s/\s*$//; # kill trailng whitespace
880 $u->alert_message($note);
882 if( ! $e->update_actor_user($u) ) {
883 syslog('LOG_ERR', "OILS: Block: patron alert update failed: %s", $e->event->{textcode});
884 $e->rollback; # rollback + disconnect
889 $self->{user}->alert_message( $note );
891 $e->commit; # commits and disconnects
895 # Testing purposes only
897 my ($self, $card_retained) = @_;
898 $self->{screen_msg} = "All privileges restored.";
900 # Un-mark card as inactive, grep out the patron alert
901 my $e = $self->{editor};
902 my $u = $self->{user};
904 syslog('LOG_INFO', "OILS: Unblocking user %s", $u->card->barcode );
906 return $self if $u->card->active eq 't';
908 $e->xact_begin; # connect and start a new transaction
910 $u->card->active('t');
911 if( ! $e->update_actor_card($u->card) ) {
912 syslog('LOG_ERR', "OILS: Unblock card update failed: %s", $e->event->{textcode});
913 $e->rollback; # rollback + disconnect
917 # retrieve the un-fleshed user object for update
918 $u = $e->retrieve_actor_user($u->id);
919 my $note = OpenILS::SIP::clean_text($u->alert_message) || "";
920 $note =~ s#<sip>.*</sip>##;
921 $note =~ s/^\s*//; # kill leading whitespace
922 $note =~ s/\s*$//; # kill trailng whitespace
923 $u->alert_message($note);
925 if( ! $e->update_actor_user($u) ) {
926 syslog('LOG_ERR', "OILS: Unblock: patron alert update failed: %s", $e->event->{textcode});
927 $e->rollback; # rollback + disconnect
932 $self->{user}->alert_message( $note );
934 $e->commit; # commits and disconnects
943 return "Please contact library staff";
947 return "Please contact library staff";
950 sub inet_privileges {
952 my $e = OpenILS::SIP->editor();
953 $INET_PRIVS = $e->retrieve_all_config_net_access_level() unless $INET_PRIVS;
954 my ($level) = grep { $_->id eq $self->{user}->net_access_level } @$INET_PRIVS;
955 my $name = OpenILS::SIP::clean_text($level->name);
956 syslog('LOG_DEBUG', "OILS: Patron inet_privs = $name");
962 my $extra_fields = {};
963 my $u = $self->{user};
964 foreach my $stat_cat_entry (@{$u->stat_cat_entries}) {
965 my $stat_cat = $stat_cat_entry->stat_cat;
966 next unless ($stat_cat->sip_field);
967 my $value = $stat_cat_entry->stat_cat_entry;
968 if(defined $stat_cat->sip_format && length($stat_cat->sip_format) > 0) { # Has a format string?
969 if($stat_cat->sip_format =~ /^\|(.*)\|$/) { # Regex match?
970 if($value =~ /($1)/) { # If we have a match
971 if(defined $2) { # Check to see if they embedded a capture group
972 $value = $2; # If so, use it
974 else { # No embedded capture group?
975 $value = $1; # Use our outer one
979 $value = ''; # Empty string. Will be checked for below.
982 else { # Not a regex match - Try sprintf match (looking for a %s, if any)
983 $value = sprintf($stat_cat->sip_format, $value);
986 next unless length($value) > 0; # No value = no export
987 $value =~ s/\|//g; # Remove all lingering pipe chars for sane output purposes
988 $extra_fields->{ $stat_cat->sip_field } = [] unless (defined $extra_fields->{$stat_cat->sip_field});
989 push(@{$extra_fields->{ $stat_cat->sip_field}}, $value);
991 return $extra_fields;