From 67fb5de54d68e79994ef1014414d091abc4aba1a Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 22 Jun 2005 15:01:53 +0000 Subject: [PATCH] knows how to read the permission string script and return a friendly message. git-svn-id: svn://svn.open-ils.org/ILS/trunk@907 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Perm.pm | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Open-ILS/src/perlmods/OpenILS/Perm.pm diff --git a/Open-ILS/src/perlmods/OpenILS/Perm.pm b/Open-ILS/src/perlmods/OpenILS/Perm.pm new file mode 100644 index 0000000000..211147d3d7 --- /dev/null +++ b/Open-ILS/src/perlmods/OpenILS/Perm.pm @@ -0,0 +1,63 @@ +package OpenILS::Perm; +use strict; use warnings; +use Template qw(:template); +use OpenSRF::Utils::SettingsClient; +use OpenILS::Utils::Fieldmapper; +use OpenSRF::EX qw(:try); +use OpenSRF::AppSession; + +# ---------------------------------------------------------------------------------- +# These permission strings +# ---------------------------------------------------------------------------------- + +# returns a new fieldmapper::perm_ex + +sub new { + + my($class, $type) = @_; + $class = ref($class) || $class; + + my $self = new Fieldmapper::perm_ex; + + $self->err_msg(_find_perm_string($type)); + $self->type($type); + warn "perm type is $type\n"; + return $self; +} + + +sub _find_perm_string { + + my $type = shift; + + my $result; + my $conf = OpenSRF::Utils::SettingsClient->new; + + my $script = $conf->config_value("perm_script"); + + my $template = Template->new( + { + ABSOLUTE => 1, + OUTPUT => \$result, + } + ); + + my $status = $template->process($script, { type => $type }); + + if(!$status) { + throw OpenSRF::EX::ERROR + ("Unable to process exception script. No meaningful data to return..." . + " Error is:\n" . $template->error() . "\n"); + } + + $result =~ s/^\s*//og; + warn " -|-|-|- Perm Exception result [$result]\n"; + + return $result; +} + + + + + +1; -- 2.43.2