From 0845eafe32bc01b82c353fb023337dd18c847196 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 20 Aug 2010 18:33:25 +0000 Subject: [PATCH] added support for a SIP config option that forces the server to return the no_i18n version of the patron profile group name from the 'ptype' sub (aka PC field in patron-info requests); added config options getter sub; cleaned up some string concats to prevent warnings git-svn-id: svn://svn.open-ils.org/ILS/trunk@17289 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/SIP.pm | 8 ++++++++ Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm | 29 +++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/SIP.pm b/Open-ILS/src/perlmods/OpenILS/SIP.pm index a33597336d..4d749bd2f9 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP.pm @@ -80,6 +80,14 @@ sub config { return $config; } +sub get_option_value { + my($self, $option) = @_; + my $ops = $config->{implementation_config}->{options}->{option}; + $ops = [$ops] unless ref $ops eq 'ARRAY'; + my @vals = grep { $_->{name} eq $option } @$ops; + return @vals ? $vals[0]->{value} : undef; +} + # Creates the global editor object my $cstore_init = 1; # call init on first use diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm index 137f539c7c..12ed11d2f7 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm @@ -107,8 +107,12 @@ sub id { sub name { my $self = shift; my $u = $self->{user}; - return OpenILS::SIP::clean_text($u->first_given_name . ' ' . - $u->second_given_name . ' ' . $u->family_name); + return OpenILS::SIP::clean_text( + sprintf('%s %s %s', + ($u->first_given_name || ''), + ($u->second_given_name || ''), + ($u->family_name || ''))); + } sub home_library { @@ -164,6 +168,14 @@ sub sip_birthdate { sub ptype { my $self = shift; + + my $use_code = OpenILS::SIP->get_option_value('patron_type_uses_code') || ''; + + # should we use the no_i18n version of patron profile name (as a 'code')? + return $self->{editor}->retrieve_permission_grp_tree( + [$self->{user}->profile->id, {no_i18n => 1}])->name + if $use_code =~ /true/io; + return OpenILS::SIP::clean_text($self->{user}->profile->name); } @@ -428,6 +440,8 @@ sub __patron_items_info { 0, $self->{editor}, $self->{user}->id);; } + + sub overdue_items { my ($self, $start, $end) = @_; @@ -437,13 +451,12 @@ sub overdue_items { my @o; syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circs @overdues"); - - - my @return_datatype = grep { $_->{name} eq 'msg64_summary_datatype' } OpenILS::SIP::config()->{implementation_config}->{options}->{option}; + + my $return_datatype = OpenILS::SIP->get_option_value('msg64_summary_datatype') || ''; for my $circid (@overdues) { next unless $circid; - if(@return_datatype and $return_datatype[0]->{value} eq 'barcode') { + if($return_datatype eq 'barcode') { push( @o, __circ_to_barcode($self->{editor}, $circid)); } else { push( @o, OpenILS::SIP::clean_text(__circ_to_title($self->{editor}, $circid))); @@ -486,11 +499,11 @@ sub charged_items { my @c; syslog('LOG_DEBUG', "OILS: charged_items() fleshing circs @charges"); - my @return_datatype = grep { $_->{name} eq 'msg64_summary_datatype' } OpenILS::SIP::config()->{implementation_config}->{options}->{option}; + my $return_datatype = OpenILS::SIP->get_option_value('msg64_summary_datatype') || ''; for my $circid (@charges) { next unless $circid; - if(@return_datatype and $return_datatype[0]->{value} eq 'barcode') { + if($return_datatype eq 'barcode') { push( @c, __circ_to_barcode($self->{editor}, $circid)); } else { push( @c, OpenILS::SIP::clean_text(__circ_to_title($self->{editor}, $circid))); -- 2.11.0