# Most fields are handled by the Transaction superclass
my %fields = (
- security_inhibit => 0,
- due => undef,
- renew_ok => 0,
- );
+ security_inhibit => 0,
+ due => undef,
+ renew_ok => 0,
+ );
sub new {
my $class = shift;;
my $self = $class->SUPER::new();
foreach my $element (keys %fields) {
- $self->{_permitted}->{$element} = $fields{$element};
+ $self->{_permitted}->{$element} = $fields{$element};
}
@{$self}{keys %fields} = values %fields;
# $self->{'due'} = time() + (60*60*24*14); # two weeks hence
- $debug and warn "new ILS::Transaction::Checkout : " . Dumper $self;
+ $debug and warn "new ILS::Transaction::Checkout : " . Dumper $self;
return bless $self, $class;
}
sub do_checkout {
- my $self = shift;
- siplog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
- my $shelf = $self->{item}->hold_shelf;
- my $barcode = $self->{item}->id;
- my $patron_barcode = $self->{patron}->id;
+ my $self = shift;
+ siplog('LOG_DEBUG', "ILS::Transaction::Checkout performing checkout...");
+ my $shelf = $self->{item}->hold_shelf;
+ my $barcode = $self->{item}->id;
+ my $patron_barcode = $self->{patron}->id;
my $overridden_duedate; # usually passed as undef to AddIssue
- $debug and warn "do_checkout: patron (" . $patron_barcode . ")";
+ $debug and warn "do_checkout: patron (" . $patron_barcode . ")";
my $patron = Koha::Patrons->find( { cardnumber => $patron_barcode } );
my $borrower = $patron->unblessed;
- $debug and warn "do_checkout borrower: . " . Dumper $borrower;
+ $debug and warn "do_checkout borrower: . " . Dumper $borrower;
my ($issuingimpossible, $needsconfirmation) = _can_we_issue($patron, $barcode,
C4::Context->preference("AllowItemsOnHoldCheckoutSIP")
);
$noerror = 0;
}
}
- unless ($noerror) {
- $debug and warn "cannot issue: " . Dumper($issuingimpossible) . "\n" . Dumper($needsconfirmation);
- $self->ok(0);
- return $self;
- }
- # can issue
- $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n"
- # . "w/ \$borrower: " . Dumper($borrower)
- . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
+ unless ($noerror) {
+ $debug and warn "cannot issue: " . Dumper($issuingimpossible) . "\n" . Dumper($needsconfirmation);
+ $self->ok(0);
+ return $self;
+ }
+ # can issue
+ $debug and warn "do_checkout: calling AddIssue(\$borrower,$barcode, $overridden_duedate, 0)\n"
+ # . "w/ \$borrower: " . Dumper($borrower)
+ . "w/ C4::Context->userenv: " . Dumper(C4::Context->userenv);
my $issue = AddIssue( $borrower, $barcode, $overridden_duedate, 0 );
$self->{due} = $self->duedatefromissue($issue, $itemnumber);
- $self->ok(1);
- return $self;
+ $self->ok(1);
+ return $self;
}
sub _can_we_issue {
use constant LOG_SIP => "local6"; # Local alias for the logging facility
#
-# Main # not really, since package SIPServer
+# Main # not really, since package SIPServer
#
# FIXME: Is this a module or a script?
# A script with no MAIN namespace?
#
if (defined($config->{'server-params'})) {
while (my ($key, $val) = each %{$config->{'server-params'}}) {
- push @parms, $key . '=' . $val;
+ push @parms, $key . '=' . $val;
}
}
$self->{service} = $config->find_service($sockaddr, $port, $proto);
if (!defined($self->{service})) {
- siplog("LOG_ERR", "process_request: Unknown recognized server connection: %s:%s/%s", $sockaddr, $port, $proto);
- die "process_request: Bad server connection";
+ siplog("LOG_ERR", "process_request: Unknown recognized server connection: %s:%s/%s", $sockaddr, $port, $proto);
+ die "process_request: Bad server connection";
}
$transport = $transports{$self->{service}->{transport}};
if (!defined($transport)) {
- siplog("LOG_WARNING", "Unknown transport '%s', dropping", $service->{transport});
- return;
+ siplog("LOG_WARNING", "Unknown transport '%s', dropping", $service->{transport});
+ return;
} else {
- &$transport($self);
+ &$transport($self);
}
return;
}
}
sub get_clean_string {
- my $string = shift;
- if (defined $string) {
- siplog("LOG_DEBUG", "get_clean_string pre-clean(length %s): %s", length($string), $string);
- chomp($string);
- $string =~ s/^[^A-z0-9]+//;
- $string =~ s/[^A-z0-9]+$//;
- siplog("LOG_DEBUG", "get_clean_string post-clean(length %s): %s", length($string), $string);
- } else {
- siplog("LOG_INFO", "get_clean_string called on undefined");
- }
- return $string;
+ my $string = shift;
+ if (defined $string) {
+ siplog("LOG_DEBUG", "get_clean_string pre-clean(length %s): %s", length($string), $string);
+ chomp($string);
+ $string =~ s/^[^A-z0-9]+//;
+ $string =~ s/[^A-z0-9]+$//;
+ siplog("LOG_DEBUG", "get_clean_string post-clean(length %s): %s", length($string), $string);
+ } else {
+ siplog("LOG_INFO", "get_clean_string called on undefined");
+ }
+ return $string;
}
sub get_clean_input {
- local $/ = "\012";
- my $in = <STDIN>;
- $in = get_clean_string($in);
- while (my $extra = <STDIN>){
- siplog("LOG_ERR", "get_clean_input got extra lines: %s", $extra);
- }
- return $in;
+ local $/ = "\012";
+ my $in = <STDIN>;
+ $in = get_clean_string($in);
+ while (my $extra = <STDIN>){
+ siplog("LOG_ERR", "get_clean_input got extra lines: %s", $extra);
+ }
+ return $in;
}
sub telnet_transport {
siplog("LOG_DEBUG", "telnet_transport: timeout is $timeout");
eval {
- local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; };
- local $| = 1; # Unbuffered output
- $/ = "\015"; # Internet Record Separator (lax version)
+ local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; };
+ local $| = 1; # Unbuffered output
+ $/ = "\015"; # Internet Record Separator (lax version)
# Until the terminal has logged in, we don't trust it
# so use a timeout to protect ourselves from hanging.
- while ($strikes--) {
- print "login: ";
- alarm $timeout;
- # $uid = &get_clean_input;
- $uid = <STDIN>;
- print "password: ";
- # $pwd = &get_clean_input || '';
- $pwd = <STDIN>;
- alarm 0;
-
- siplog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd));
- $uid = get_clean_string ($uid);
- $pwd = get_clean_string ($pwd);
- siplog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd));
-
- if (exists ($config->{accounts}->{$uid})
- && ($pwd eq $config->{accounts}->{$uid}->{password})) {
- $account = $config->{accounts}->{$uid};
- if ( C4::SIP::Sip::MsgType::login_core($self,$uid,$pwd) ) {
+ while ($strikes--) {
+ print "login: ";
+ alarm $timeout;
+ # $uid = &get_clean_input;
+ $uid = <STDIN>;
+ print "password: ";
+ # $pwd = &get_clean_input || '';
+ $pwd = <STDIN>;
+ alarm 0;
+
+ siplog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd));
+ $uid = get_clean_string ($uid);
+ $pwd = get_clean_string ($pwd);
+ siplog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd));
+
+ if (exists ($config->{accounts}->{$uid})
+ && ($pwd eq $config->{accounts}->{$uid}->{password})) {
+ $account = $config->{accounts}->{$uid};
+ if ( C4::SIP::Sip::MsgType::login_core($self,$uid,$pwd) ) {
last;
}
- }
- siplog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||''));
- print("Invalid login$CRLF");
- }
+ }
+ siplog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||''));
+ print("Invalid login$CRLF");
+ }
}; # End of eval
if ($@) {
- siplog("LOG_ERR", "telnet_transport: Login timed out");
- die "Telnet Login Timed out";
+ siplog("LOG_ERR", "telnet_transport: Login timed out");
+ die "Telnet Login Timed out";
} elsif (!defined($account)) {
- siplog("LOG_ERR", "telnet_transport: Login Failed");
- die "Login Failure";
+ siplog("LOG_ERR", "telnet_transport: Login Failed");
+ die "Login Failure";
} else {
- print "Login OK. Initiating SIP$CRLF";
+ print "Login OK. Initiating SIP$CRLF";
}
$self->{account} = $account;
my ($i, $ent);
if (!defined($value)) {
- siplog("LOG_DEBUG", "add_field: Undefined value being added to '%s'",
- $field_id);
- $value = '';
+ siplog("LOG_DEBUG", "add_field: Undefined value being added to '%s'",
+ $field_id);
+ $value = '';
}
$value=~s/\r/ /g; # CR terminates a sip message
# Protect against them in sip text fields
$ent = sprintf("&#%d;", ord($field_delimiter));
while (($i = index($value, $field_delimiter)) != ($[-1)) {
- substr($value, $i, 1) = $ent;
+ substr($value, $i, 1) = $ent;
}
return $field_id . $value . $field_delimiter;
# If the field is unsupported, it will be undef, return blanks
# as per the spec.
if (!defined($count)) {
- return ' ' x 4;
+ return ' ' x 4;
}
$count = sprintf("%04d", $count);
if (length($count) != 4) {
- siplog("LOG_WARNING", "handle_patron_info: %s wrong size: '%s'",
- $label, $count);
- $count = ' ' x 4;
+ siplog("LOG_WARNING", "handle_patron_info: %s wrong size: '%s'",
+ $label, $count);
+ $count = ' ' x 4;
}
return $count;
}