View | Details | Raw Unified | Return to bug 15124
Collapse All | Expand All

(-)a/C4/SIP/Sip/MsgType.pm (-122 / +130 lines)
Lines 437-474 sub build_patron_status { Link Here
437
    my $resp = (PATRON_STATUS_RESP);
437
    my $resp = (PATRON_STATUS_RESP);
438
438
439
    if ($patron) {
439
    if ($patron) {
440
	$resp .= patron_status_string($patron);
440
        $resp .= patron_status_string($patron);
441
	$resp .= $lang . timestamp();
441
        $resp .= $lang . timestamp();
442
	$resp .= add_field(FID_PERSONAL_NAME, $patron->name);
442
        $resp .= add_field( FID_PERSONAL_NAME, $patron->name );
443
443
444
	# while the patron ID we got from the SC is valid, let's
444
        # while the patron ID we got from the SC is valid, let's
445
	# use the one returned from the ILS, just in case...
445
        # use the one returned from the ILS, just in case...
446
	$resp .= add_field(FID_PATRON_ID, $patron->id);
446
        $resp .= add_field( FID_PATRON_ID, $patron->id );
447
	if ($protocol_version >= 2) {
447
        if ( $protocol_version >= 2 ) {
448
	    $resp .= add_field(FID_VALID_PATRON, 'Y');
448
            $resp .= add_field( FID_VALID_PATRON, 'Y' );
449
	    # Patron password is a required field.
449
450
		$resp .= add_field(FID_VALID_PATRON_PWD, sipbool($patron->check_password($patron_pwd)));
450
            # Patron password is a required field.
451
	    $resp .= maybe_add(FID_CURRENCY, $patron->currency);
451
            $resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $patron->check_password($patron_pwd) ) );
452
	    $resp .= maybe_add(FID_FEE_AMT, $patron->fee_amount);
452
            $resp .= maybe_add( FID_CURRENCY, $patron->currency );
453
	}
453
            $resp .= maybe_add( FID_FEE_AMT,  $patron->fee_amount );
454
        }
454
455
455
    $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server );
456
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg,   $server );
456
    $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server )
457
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->{branchcode}, $server )
457
      if ( $server->{account}->{send_patron_home_library_in_af} );
458
          if ( $server->{account}->{send_patron_home_library_in_af} );
458
459
459
	$resp .= maybe_add(FID_PRINT_LINE, $patron->print_line);
460
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
460
    } else {
461
    }
461
	# Invalid patron id.  Report that the user has no privs.,
462
    else {
462
	# no personal name, and is invalid (if we're using 2.00)
463
        # Invalid patron id.  Report that the user has no privs.,
463
	$resp .= 'YYYY' . (' ' x 10) . $lang . timestamp();
464
        # no personal name, and is invalid (if we're using 2.00)
464
	$resp .= add_field(FID_PERSONAL_NAME, '');
465
        $resp .= 'YYYY' . ( ' ' x 10 ) . $lang . timestamp();
466
        $resp .= add_field( FID_PERSONAL_NAME, '' );
465
467
466
	# the patron ID is invalid, but it's a required field, so
468
        # the patron ID is invalid, but it's a required field, so
467
	# just echo it back
469
        # just echo it back
468
	$resp .= add_field(FID_PATRON_ID, $fields->{(FID_PATRON_ID)});
470
        $resp .= add_field( FID_PATRON_ID, $fields->{ (FID_PATRON_ID) } );
469
471
470
	($protocol_version >= 2) and 
472
        ( $protocol_version >= 2 )
471
		$resp .= add_field(FID_VALID_PATRON, 'N');
473
          and $resp .= add_field( FID_VALID_PATRON, 'N' );
472
    }
474
    }
473
475
474
    $resp .= add_field(FID_INST_ID, $fields->{(FID_INST_ID)});
476
    $resp .= add_field(FID_INST_ID, $fields->{(FID_INST_ID)});
Lines 531-604 sub handle_checkout { Link Here
531
    $item = $status->item;
533
    $item = $status->item;
532
    $patron = $status->patron;
534
    $patron = $status->patron;
533
535
534
    if ($status->ok) {
536
    if ( $status->ok ) {
535
	# Item successfully checked out
536
	# Fixed fields
537
	$resp = CHECKOUT_RESP . '1';
538
	$resp .= sipbool($status->renew_ok);
539
	if ($ils->supports('magnetic media')) {
540
	    $resp .= sipbool($item->magnetic_media);
541
	} else {
542
	    $resp .= 'U';
543
	}
544
	# We never return the obsolete 'U' value for 'desensitize'
545
	$resp .= sipbool($status->desensitize);
546
	$resp .= timestamp;
547
537
548
	# Now for the variable fields
538
        # Item successfully checked out
549
	$resp .= add_field(FID_INST_ID, $inst);
539
        # Fixed fields
550
	$resp .= add_field(FID_PATRON_ID, $patron_id);
540
        $resp = CHECKOUT_RESP . '1';
551
	$resp .= add_field(FID_ITEM_ID, $item_id);
541
        $resp .= sipbool( $status->renew_ok );
552
	$resp .= add_field(FID_TITLE_ID, $item->title_id);
542
        if ( $ils->supports('magnetic media') ) {
553
    if ($item->due_date) {
543
            $resp .= sipbool( $item->magnetic_media );
554
        $resp .= add_field(FID_DUE_DATE, timestamp($item->due_date));
544
        }
555
    } else {
545
        else {
556
        $resp .= add_field(FID_DUE_DATE, q{});
546
            $resp .= 'U';
557
    }
547
        }
558
548
559
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
549
        # We never return the obsolete 'U' value for 'desensitize'
560
	$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
550
        $resp .= sipbool( $status->desensitize );
551
        $resp .= timestamp;
552
553
        # Now for the variable fields
554
        $resp .= add_field( FID_INST_ID,   $inst );
555
        $resp .= add_field( FID_PATRON_ID, $patron_id );
556
        $resp .= add_field( FID_ITEM_ID,   $item_id );
557
        $resp .= add_field( FID_TITLE_ID,  $item->title_id );
558
        if ( $item->due_date ) {
559
            $resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ) );
560
        }
561
        else {
562
            $resp .= add_field( FID_DUE_DATE, q{} );
563
        }
561
564
562
	if ($protocol_version >= 2) {
565
        $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
563
	    if ($ils->supports('security inhibit')) {
566
        $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
564
		$resp .= add_field(FID_SECURITY_INHIBIT,
565
				   $status->security_inhibit);
566
	    }
567
	    $resp .= maybe_add(FID_MEDIA_TYPE, $item->sip_media_type);
568
	    $resp .= maybe_add(FID_ITEM_PROPS, $item->sip_item_properties);
569
567
570
	    }
568
        if ( $protocol_version >= 2 ) {
571
	}
569
            if ( $ils->supports('security inhibit') ) {
570
                $resp .= add_field( FID_SECURITY_INHIBIT, $status->security_inhibit );
571
            }
572
            $resp .= maybe_add( FID_MEDIA_TYPE, $item->sip_media_type );
573
            $resp .= maybe_add( FID_ITEM_PROPS, $item->sip_item_properties );
572
574
575
        }
576
    }
573
    else {
577
    else {
574
	# Checkout failed
578
        # Checkout failed
575
	# Checkout Response: not ok, no renewal, don't know mag. media,
579
        # Checkout Response: not ok, no renewal, don't know mag. media,
576
	# no desensitize
580
        # no desensitize
577
	$resp = sprintf("120NUN%s", timestamp);
581
        $resp = sprintf( "120NUN%s", timestamp );
578
	$resp .= add_field(FID_INST_ID, $inst);
582
        $resp .= add_field( FID_INST_ID,   $inst );
579
	$resp .= add_field(FID_PATRON_ID, $patron_id);
583
        $resp .= add_field( FID_PATRON_ID, $patron_id );
580
	$resp .= add_field(FID_ITEM_ID, $item_id);
584
        $resp .= add_field( FID_ITEM_ID,   $item_id );
581
585
582
	# If the item is valid, provide the title, otherwise
586
        # If the item is valid, provide the title, otherwise
583
	# leave it blank
587
        # leave it blank
584
	$resp .= add_field(FID_TITLE_ID, $item ? $item->title_id : '');
588
        $resp .= add_field( FID_TITLE_ID, $item ? $item->title_id : '' );
585
	# Due date is required.  Since it didn't get checked out,
586
	# it's not due, so leave the date blank
587
	$resp .= add_field(FID_DUE_DATE, '');
588
589
589
    $resp .= maybe_add(FID_SCREEN_MSG, $status->screen_msg, $server);
590
        # Due date is required.  Since it didn't get checked out,
590
	$resp .= maybe_add(FID_PRINT_LINE, $status->print_line);
591
        # it's not due, so leave the date blank
592
        $resp .= add_field( FID_DUE_DATE, '' );
591
593
592
	if ($protocol_version >= 2) {
594
        $resp .= maybe_add( FID_SCREEN_MSG, $status->screen_msg, $server );
593
	    # Is the patron ID valid?
595
        $resp .= maybe_add( FID_PRINT_LINE, $status->print_line );
594
	    $resp .= add_field(FID_VALID_PATRON, sipbool($patron));
595
596
596
	    if ($patron && exists($fields->{FID_PATRON_PWD})) {
597
        if ( $protocol_version >= 2 ) {
597
		# Password provided, so we can tell if it was valid or not
598
598
		$resp .= add_field(FID_VALID_PATRON_PWD,
599
            # Is the patron ID valid?
599
				   sipbool($patron->check_password($fields->{(FID_PATRON_PWD)})));
600
            $resp .= add_field( FID_VALID_PATRON, sipbool($patron) );
600
	    }
601
601
	}
602
            if ( $patron && exists( $fields->{FID_PATRON_PWD} ) ) {
603
604
                # Password provided, so we can tell if it was valid or not
605
                $resp .=
606
                  add_field( FID_VALID_PATRON_PWD,
607
                    sipbool( $patron->check_password( $fields->{ (FID_PATRON_PWD) } ) ) );
608
            }
609
        }
602
    }
610
    }
603
611
604
    if ( $protocol_version >= 2 ) {
612
    if ( $protocol_version >= 2 ) {
Lines 1210-1263 sub handle_item_status_update { Link Here
1210
}
1218
}
1211
1219
1212
sub handle_patron_enable {
1220
sub handle_patron_enable {
1213
    my ($self, $server) = @_;
1221
    my ( $self, $server ) = @_;
1214
    my $ils = $server->{ils};
1222
    my $ils    = $server->{ils};
1215
    my $fields = $self->{fields};
1223
    my $fields = $self->{fields};
1216
    my ($trans_date, $patron_id, $terminal_pwd, $patron_pwd);
1224
    my ( $trans_date, $patron_id, $terminal_pwd, $patron_pwd );
1217
    my ($status, $patron);
1225
    my ( $status, $patron );
1218
    my $resp = PATRON_ENABLE_RESP;
1226
    my $resp = PATRON_ENABLE_RESP;
1219
1227
1220
    ($trans_date) = @{$self->{fixed_fields}};
1228
    ($trans_date) = @{ $self->{fixed_fields} };
1221
    $patron_id = $fields->{(FID_PATRON_ID)};
1229
    $patron_id  = $fields->{ (FID_PATRON_ID) };
1222
    $patron_pwd = $fields->{(FID_PATRON_PWD)};
1230
    $patron_pwd = $fields->{ (FID_PATRON_PWD) };
1223
1231
1224
    syslog("LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'",
1232
    syslog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd );
1225
	   $patron_id, $patron_pwd);
1226
1233
1227
    $patron = $ils->find_patron($patron_id);
1234
    $patron = $ils->find_patron($patron_id);
1228
1235
1229
    if (!defined($patron)) {
1236
    if ( !defined($patron) ) {
1230
	# Invalid patron ID
1231
	$resp .= 'YYYY' . (' ' x 10) . '000' . timestamp();
1232
	$resp .= add_field(FID_PATRON_ID, $patron_id);
1233
	$resp .= add_field(FID_PERSONAL_NAME, '');
1234
	$resp .= add_field(FID_VALID_PATRON, 'N');
1235
	$resp .= add_field(FID_VALID_PATRON_PWD, 'N');
1236
    } else {
1237
	# valid patron
1238
	if (!defined($patron_pwd) || $patron->check_password($patron_pwd)) {
1239
	    # Don't enable the patron if there was an invalid password
1240
	    $status = $patron->enable;
1241
	}
1242
	$resp .= patron_status_string($patron);
1243
	$resp .= $patron->language . timestamp();
1244
1237
1245
	$resp .= add_field(FID_PATRON_ID, $patron->id);
1238
        # Invalid patron ID
1246
	$resp .= add_field(FID_PERSONAL_NAME, $patron->name);
1239
        $resp .= 'YYYY' . ( ' ' x 10 ) . '000' . timestamp();
1247
	if (defined($patron_pwd)) {
1240
        $resp .= add_field( FID_PATRON_ID,        $patron_id );
1248
	    $resp .= add_field(FID_VALID_PATRON_PWD,
1241
        $resp .= add_field( FID_PERSONAL_NAME,    '' );
1249
			       sipbool($patron->check_password($patron_pwd)));
1242
        $resp .= add_field( FID_VALID_PATRON,     'N' );
1250
	}
1243
        $resp .= add_field( FID_VALID_PATRON_PWD, 'N' );
1251
	$resp .= add_field(FID_VALID_PATRON, 'Y');
1252
    $resp .= maybe_add(FID_SCREEN_MSG, $patron->screen_msg, $server);
1253
	$resp .= maybe_add(FID_PRINT_LINE, $patron->print_line);
1254
    }
1244
    }
1245
    else {
1246
        # valid patron
1247
        if ( !defined($patron_pwd) || $patron->check_password($patron_pwd) ) {
1255
1248
1256
    $resp .= add_field(FID_INST_ID, $ils->institution);
1249
            # Don't enable the patron if there was an invalid password
1250
            $status = $patron->enable;
1251
        }
1252
        $resp .= patron_status_string($patron);
1253
        $resp .= $patron->language . timestamp();
1257
1254
1258
    $self->write_msg($resp,undef,$server->{account}->{terminator},$server->{account}->{encoding});
1255
        $resp .= add_field( FID_PATRON_ID,     $patron->id );
1256
        $resp .= add_field( FID_PERSONAL_NAME, $patron->name );
1257
        if ( defined($patron_pwd) ) {
1258
            $resp .= add_field( FID_VALID_PATRON_PWD, sipbool( $patron->check_password($patron_pwd) ) );
1259
        }
1260
        $resp .= add_field( FID_VALID_PATRON, 'Y' );
1261
        $resp .= maybe_add( FID_SCREEN_MSG, $patron->screen_msg, $server );
1262
        $resp .= maybe_add( FID_PRINT_LINE, $patron->print_line );
1263
    }
1264
1265
    $resp .= add_field( FID_INST_ID, $ils->institution );
1266
1267
    $self->write_msg( $resp, undef, $server->{account}->{terminator}, $server->{account}->{encoding} );
1259
1268
1260
    return(PATRON_ENABLE);
1269
    return (PATRON_ENABLE);
1261
}
1270
}
1262
1271
1263
sub handle_hold {
1272
sub handle_hold {
1264
- 

Return to bug 15124