[open-ils-commits] r17289 - in trunk/Open-ILS/src/perlmods/OpenILS: . SIP (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Aug 20 14:33:29 EDT 2010


Author: erickson
Date: 2010-08-20 14:33:25 -0400 (Fri, 20 Aug 2010)
New Revision: 17289

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm
   trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
Log:
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

Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm	2010-08-20 17:18:28 UTC (rev 17288)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm	2010-08-20 18:33:25 UTC (rev 17289)
@@ -107,8 +107,12 @@
 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 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 @@
 			0, $self->{editor}, $self->{user}->id);;
 }
 
+
+
 sub overdue_items {
 	my ($self, $start, $end) = @_;
 
@@ -437,13 +451,12 @@
 
 	my @o;
 	syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circs @overdues");
+
+	my $return_datatype = OpenILS::SIP->get_option_value('msg64_summary_datatype') || '';
 	
-	
-	my @return_datatype = grep { $_->{name} eq 'msg64_summary_datatype' } OpenILS::SIP::config()->{implementation_config}->{options}->{option};
-	
 	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 @@
 	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)));

Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm	2010-08-20 17:18:28 UTC (rev 17288)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP.pm	2010-08-20 18:33:25 UTC (rev 17289)
@@ -80,7 +80,15 @@
 	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
 sub make_editor {



More information about the open-ils-commits mailing list