use OpenILS::Application::AppUtils;
use OpenSRF::Utils qw/:datetime/;
use DateTime::Format::ISO8601;
-use Encode;
-use Unicode::Normalize;
my $U = 'OpenILS::Application::AppUtils';
return OpenILS::Utils::CStoreEditor->new;
}
-=head2 clean_text(scalar)
-
-Evergreen uses the UTF8 encoding for everything from the database up. Perl
-doesn't know this, however, so we have to convince it to treat our UTF8 strings
-as UTF8 strings. This may enable OpenNCIP to correctly calculate the checksums
-for UTF8 text for SIP clients that support such modern options.
-
-The target encoding is set in the <encoding> element of the SIPServer.pm
-configuration file.
-
-=cut
-
-sub clean_text {
- my $text = shift || '';
-
- # Convert our incoming UTF8 data into Perl's internal string format
-
- # Also convert to Normalization Form D, as the ASCII, iso-8859-1,
- # and latin-1 encodings (at least) require this to substitute
- # characters rather than simply returning a string truncated
- # after the first non-ASCII character
- $text = NFD(decode_utf8($text));
-
- if ($target_encoding eq 'ascii') {
-
- # Try to maintain a reasonable version of the content by
- # stripping diacritics from the text, given that the SIP client
- # wants just plain ASCII. This is the base requirement according
- # to the SIP2 specification.
-
- # Stripping the combining characters converts ""béè♁ts"
- # into "bee?ts" instead of "b???ts" - better, eh?
- $text =~ s/\pM+//og;
- }
-
- # Characters that cannot be represented in the target encoding will
- # generally be replaced with a question mark (?) character.
- $text = encode($target_encoding, $text);
-
- return $text;
-}
-
my %org_sn_cache;
sub shortname_from_id {
my $id = shift or return;
sub title_id {
my $self = shift;
my $t = ($self->{mods}) ? $self->{mods}->title : $self->{copy}->dummy_title;
- return OpenILS::SIP::clean_text($t);
+ return $t;
}
sub permanent_location {
my $self = shift;
- return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname);
+ return $self->{copy}->circ_lib->shortname;
}
sub current_location {
my $self = shift;
- return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname);
+ return $self->{copy}->circ_lib->shortname;
}
sub owner {
my $self = shift;
- return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname);
+ return $self->{copy}->circ_lib->shortname;
}
sub hold_queue {
# message to display on console
sub screen_msg {
my $self = shift;
- return OpenILS::SIP::clean_text($self->{screen_msg}) || '';
+ return $self->{screen_msg} || '';
}
# reciept printer
sub print_line {
my $self = shift;
- return OpenILS::SIP::clean_text($self->{print_line}) || '';
+ return $self->{print_line} || '';
}
sub format_name {
my $u = shift;
- return OpenILS::SIP::clean_text(
- sprintf('%s %s %s',
- ($u->first_given_name || ''),
- ($u->second_given_name || ''),
- ($u->family_name || '')));
+ return sprintf('%s %s %s',
+ ($u->first_given_name || ''),
+ ($u->second_given_name || ''),
+ ($u->family_name || ''));
}
sub home_library {
sub __addr_string {
my $addr = shift;
return "" unless $addr;
- my $return = OpenILS::SIP::clean_text(
- join( ' ', map {$_ || ''} (
- $addr->street1,
- $addr->street2,
- $addr->city . ',',
- $addr->county,
- $addr->state,
- $addr->country,
- $addr->post_code
- )
- )
- );
- $return =~ s/\s+/ /sg; # Compress any run of of whitespace to one space
+ my $return = join( ' ', map {$_ || ''}
+ (
+ $addr->street1,
+ $addr->street2,
+ $addr->city . ',',
+ $addr->county,
+ $addr->state,
+ $addr->country,
+ $addr->post_code
+ )
+ );
+ $return =~ s/\s+/ /sg; # Compress any run of of whitespace to one space
return $return;
}
sub email_addr {
my $self = shift;
- return OpenILS::SIP::clean_text($self->{user}->email);
+ return $self->{user}->email;
}
sub home_phone {
[$self->{user}->profile->id, {no_i18n => 1}])->name
if $use_code =~ /true/io;
- return OpenILS::SIP::clean_text($self->{user}->profile->name);
+ return $self->{user}->profile->name;
}
sub language {
} else {
push(@response,
- OpenILS::SIP::clean_text($self->__hold_to_title($hold)));
+ $self->__hold_to_title($hold));
}
}
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)));
+ push( @o, __circ_to_title($self->{editor}, $circid));
}
}
@overdues = @o;
if($return_datatype eq 'barcode' or $force_bc) {
push( @c, __circ_to_barcode($self->{editor}, $circid));
} else {
- push( @c, OpenILS::SIP::clean_text(__circ_to_title($self->{editor}, $circid)));
+ push( @c, __circ_to_title($self->{editor}, $circid));
}
}
} else {
$line .= $xact->last_billing_note;
}
- push @fines, OpenILS::SIP::clean_text($line);
+ push @fines, $line;
}
};
my $log_status = $@ ? 'ERROR: ' . $@ : 'OK';
# retrieve the un-fleshed user object for update
$u = $e->retrieve_actor_user($u->id);
- my $note = OpenILS::SIP::clean_text($u->alert_message) || "";
+ my $note = $u->alert_message || "";
$note = "<sip> CARD BLOCKED BY SELF-CHECK MACHINE. $blocked_card_msg</sip>\n$note"; # XXX Config option
$note =~ s/\s*$//; # kill trailng whitespace
$u->alert_message($note);
# retrieve the un-fleshed user object for update
$u = $e->retrieve_actor_user($u->id);
- my $note = OpenILS::SIP::clean_text($u->alert_message) || "";
+ my $note = $u->alert_message || "";
$note =~ s#<sip>.*</sip>##;
$note =~ s/^\s*//; # kill leading whitespace
$note =~ s/\s*$//; # kill trailng whitespace
my $e = OpenILS::SIP->editor();
$INET_PRIVS = $e->retrieve_all_config_net_access_level() unless $INET_PRIVS;
my ($level) = grep { $_->id eq $self->{user}->net_access_level } @$INET_PRIVS;
- my $name = OpenILS::SIP::clean_text($level->name);
+ my $name = $level->name;
syslog('LOG_DEBUG', "OILS: Patron inet_privs = $name");
return $name;
}