updating ILS::Patron for Koha.
authorRyan Higgins <rch@liblime.com>
Mon, 5 Nov 2007 23:13:57 +0000 (17:13 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 6 Nov 2007 12:32:55 +0000 (06:32 -0600)
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/SIP/ILS.pm
C4/SIP/ILS/Patron.pm
C4/SIP/SIPServer.pm
C4/SIP/SIPconfig.xml
C4/SIP/Sip/MsgType.pm
C4/SIP/test.txt

index 20e940f..69d6d10 100644 (file)
@@ -1,5 +1,5 @@
 #
-# ILS.pm: Test ILS interface module
+# ILS.pm: Koha ILS interface module
 #
 
 package ILS;
@@ -43,7 +43,9 @@ sub new {
     my ($class, $institution) = @_;
     my $type = ref($class) || $class;
     my $self = {};
-
+use Data::Dumper;
+warn " INSTITUTION:";
+warn Dumper($institution);
     syslog("LOG_DEBUG", "new ILS '%s'", $institution->{id});
     $self->{institution} = $institution;
 
index ce79210..19b9302 100644 (file)
@@ -14,6 +14,11 @@ use Exporter;
 use Sys::Syslog qw(syslog);
 use Data::Dumper;
 
+use C4::Context;
+use C4::Koha;
+use C4::Members;
+use Digest::MD5 qw(md5_base64);
+
 our (@ISA, @EXPORT_OK);
 
 @ISA = qw(Exporter);
@@ -50,51 +55,64 @@ our %patron_db = (
                      unavail_holds => [],
                      inet => 1,
                  },
-                 miker => {
-                     name => "Mike Rylander",
-                     id => 'miker',
-                     password => '6789',
-                     ptype => 'A', # 'A'dult.  Whatever.
-                     birthdate => '19640925',
-                     address => 'Somewhere in Atlanta',
-                     home_phone => '(404) 555 1235',
-                     email_addr => 'mrylander@gmail.com',
-                     charge_ok => 1,
-                     renew_ok => 1,
-                     recall_ok => 0,
-                     hold_ok => 1,
-                     card_lost => 0,
+                 );
+
+sub new {
+    my ($class, $patron_id) = @_;
+    my $type = ref($class) || $class;
+    my $self;
+my %ilspatron;
+       my $kp = GetMember($patron_id,'cardnumber');
+warn "THIS IS what we et from getmember...";
+use Data::Dumper;
+warn Dumper($kp);
+    if ($kp) {
+       my $pw = $kp->{password};    ## FIXME - md5hash -- deal with . 
+       my $dob= $kp->{dateofbirth};
+       $dob =~ s/\-//g;
+
+       my $debarred = $kp->{debarred}; ### 1 if ($kp->{flags}->{DBARRED}->{noissues});
+warn "i am debarred: $debarred";
+#warn Dumper(%{$kp->{flags}});
+       my $adr = $kp->{streetnumber} . " ". $kp->{address}; 
+               %ilspatron = (
+                     name => $kp->{firstname} . " " . $kp->{surname},
+                     id => $kp->{cardnumber},
+                     password => $pw,
+                     ptype => $kp->{categorycode}, # 'A'dult.  Whatever.
+                     birthdate => $dob,
+                     address => $adr,
+                     home_phone => $kp->{phone},
+                     email_addr => $kp->{email},
+                     charge_ok => (!$debarred) , ##  (C4::Context->preference('FinesMode') eq 'charge') || 0,
+                     renew_ok => 0,
+                         recall_ok => 0,
+                     hold_ok => 0,
+                     card_lost => 0,#$kp->{flags}->{LOST},
                      claims_returned => 0,
-                     fines => 0,
+                     fines => 0,#$kp->{flags}->{CHARGES},
                      fees => 0,
                      recall_overdue => 0,
                      items_billed => 0,
                      screen_msg => '',
                      print_line => '',
-                     items => [],
-                     hold_items => [],
-                     overdue_items => [],
+                     items => [] ,
+                     hold_items => [],#$kp->{flags}->{WAITING}{itemlist}->{biblionumber},
+                     overdue_items =>[], # [$kp->{flags}->{ODUES}{itemlisttext}],   ### FIXME -> this should be array, not texts string.
                      fine_items => [],
                      recall_items => [],
                      unavail_holds => [],
                      inet => 0,
-                 },
-                 );
-
-sub new {
-    my ($class, $patron_id) = @_;
-    my $type = ref($class) || $class;
-    my $self;
-
-    if (!exists($patron_db{$patron_id})) {
-       syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
-       return undef;
+                         );
+       } else {
+               syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);
+               return undef;
     }
 
-    $self = $patron_db{$patron_id};
+    $self =  \%ilspatron;
+       warn Dumper($self);
 
-    syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,
-          $self->{id});
+    syslog("LOG_DEBUG", "new ILS::Patron(%s): found patron '%s'", $patron_id,$self->{id});
 
     bless $self, $type;
     return $self;
@@ -186,10 +204,9 @@ sub recall_overdue {
 
 sub check_password {
     my ($self, $pwd) = @_;
+       my $md5pwd=$self->{password};  ### FIXME -  we're allowing access if user has no password.
 
-    # If the patron doesn't have a password,
-    # then we don't need to check
-    return (!$self->{password} || ($pwd && ($self->{password} eq $pwd)));
+return (!$self->{password} ||  md5_base64($pwd) eq $md5pwd );
 }
 
 sub currency {
index 85d5b46..987daa7 100644 (file)
@@ -125,8 +125,7 @@ sub raw_transport {
            alarm $service->{timeout};
            $input = Sip::read_SIP_packet(*STDIN);
            alarm 0;
-
-           if (!$input) {
+       if (!$input) {
                # EOF on the socket
                syslog("LOG_INFO", "raw_transport: shutting down: EOF during login");
                return;
@@ -169,7 +168,6 @@ sub telnet_transport {
        local $SIG{ALRM} = sub { die "alarm\n"; };
        local $|;
        my $timeout = 0;
-
        $| = 1;                 # Unbuffered output
        $timeout = $config->{timeout} if (exists($config->{timeout}));
 
@@ -229,7 +227,6 @@ sub sip_protocol_loop {
     my $service = $self->{service};
     my $config = $self->{config};
     my $input;
-
     # Now that the terminal has logged in, the first message
     # we recieve must be an SC_STATUS message.  But it might be
     # an SC_REQUEST_RESEND.  So, as long as we keep receiving
@@ -253,7 +250,7 @@ sub sip_protocol_loop {
 
        $status = Sip::MsgType::handle($input, $self, $expect);
        next if $status eq REQUEST_ACS_RESEND;
-
+#### stopped here rch
        if (!$status) {
            syslog("LOG_ERR", "raw_transport: failed to handle %s",
                   substr($input, 0, 2));
index 079c88d..c7f9720 100644 (file)
@@ -28,9 +28,8 @@
   </listeners>
 
   <accounts>
-      <login id="koha" password="koha" institution="kohalibrary">
-      </login>
-      <login id="koha2" password="koha2" institution="kohalibrary" />
+      <login id="koha" password="koha" delimiter="|" error-detect="enabled" institution="kohalibrary" />
+      <login id="koha2" password="koha" institution="kohalibrary2" />
       <login id="lpl-sc" password="1234" institution="LPL" />
       <login id="lpl-sc-beacock" password="xyzzy"
              delimiter="|" error-detect="enabled" institution="LPL" />
           <policy checkin="true" renewal="false"
                  status_update="false" offline="false"
                  timeout="600"
+                 retries="5" />
+    </institution>
+    <institution id="kohalibrary2" implementation="ILS" parms="">
+          <policy checkin="true" renewal="false"
+                 timeout="600"
                  retries="3" />
     </institution>
 
index ce05b93..5f62503 100644 (file)
@@ -285,6 +285,7 @@ sub new {
        # so we'll just do it.
        $protocol_version = 2;
     }
+warn "PROTOCOL: $protocol_version";    
     if (!exists($handlers{$msgtag})) {
        syslog("LOG_WARNING",
               "new Sip::MsgType: Skipping message of unknown type '%s' in '%s'",
@@ -471,9 +472,11 @@ sub build_patron_status {
     return $resp;
 }
 
+use Data::Dumper;
 sub handle_patron_status {
     my ($self, $server) = @_;
-    my $ils = $server->{ils};
+#warn Dumper($server);  
+  my $ils = $server->{ils};
     my ($lang, $date);
     my $fields;
     my $patron;
@@ -482,7 +485,9 @@ sub handle_patron_status {
 
     ($lang, $date) = @{$self->{fixed_fields}};
     $fields = $self->{fields};
-
+warn Dumper($fields);
+warn FID_INST_ID;
+warn $fields->{(FID_INST_ID)};
     $ils->check_inst_id($fields->{(FID_INST_ID)}, "handle_patron_status");
 
     $patron = $ils->find_patron($fields->{(FID_PATRON_ID)});
index 775b147..c70e7dd 100644 (file)
@@ -1,17 +1,27 @@
 97AZFEF5
-2300120060101    084235AOUWOLS|AAdjfiander|ACterminal password|ADuser password|
+2300120071003    084235AOkohalibrary|AArch|ACkoha|ADkoha|
+
 2300120060101    084236AOUWOLS|AAmjandkilde|ACterminal password|ADuser password|
 2300120060101    084237AOUWOLS|AAdjfiander|ACterminal password|ADuser password|
 9300CNLoginUserID|COLoginPassword|CPLocationCode|
 11YN20060329    203000                  AOUWOLS|AAdjfiander|AB1565921879|AC|
 09Y20060102    08423620060113    084235APUnder the bed|AOUWOLS|AB1565921879|ACterminal password|
 01N20060102    084238AOUWOLS|ALHe's a jerk|AAdjfiander|ACterminal password|
+
 2520060102    084238AOUWOLS|AAdjfiander|ACterminal password|AD6789|
 9910302.00
-3520060110    084237AOUWOLS|AAdjfiander|AD6789|
+
+3520060110    084237AOkohalibrary|AArch|ADkoha|
 1720060110    215612AOUWOLS|AB1565921879|
-6300020060329    201700Y         AOUWOLS|AAdjfiander|
+
+patron information: 
+6300020060329    201700Y         AOkohalibrary|AArch|ACkoha|ADkoha|
+
 15+20060415    110158BW20060815    110158|BSTaylor|BY2|AOUWOLS|AAdjfiander|AB1565921879|
 15-20060415    110158AOUWOLS|AAdjfiander|AB1565921879|
 29NN20060415    110158                  AOUWOLS|AAdjfiander|AD6789|AB1565921879|
 6520060415    110158AOUWOLS|AAdjfiander|AD6789|
+
+working:
+
+9300CNkoha|COkoha|CPkohalibrary|