if (defined($self->editor->requestor)) {
# Call sub to get the session id
my $session_id = _get_ebook_session_id();
+ $self->ctx->{vendors} = [];
+ $self->ctx->{wishlist} = [];
+ $self->ctx->{vendor_library_url} = "";
+ $self->ctx->{is_patron_authorized_to_register_with_rbdigital} = 0;
# Send back rbdigital_patron_id
$self->ctx->{rbdigital_patron_id} = _get_patron_id($self->editor->authtoken, $session_id);
$logger->info('EbookAPI: Got patron id: '. $self->ctx->{rbdigital_patron_id});
+
+ # Call method to know if the user's home library is tied to RBdigital portal
+ my $is_patron_authorized_to_register_with_rbdigital = _is_authorized($self->editor->authtoken, $session_id);
+ $self->ctx->{is_patron_authorized_to_register_with_rbdigital} = $is_patron_authorized_to_register_with_rbdigital;
+ $logger->info('EbookAPI: is_patron_authorized_to_register_with_rbdigital: '.$is_patron_authorized_to_register_with_rbdigital);
+
# Call sub to get all the vendors to be displayed on the UI
$self->ctx->{vendors} = _get_authorized_vendors($self->editor->authtoken, $session_id);
+ $self->ctx->{wishlist} = _get_patron_wishlist($self->editor->authtoken, $session_id);
- # Loop through vendors array and get the RBdigital library URL tied to logged in User
- foreach my $value (@ {$self->ctx->{vendors}}) {
- if ($value->vendor_key eq 'rbdigital') {
- $self->ctx->{vendor_library_url} = $value->[0]->digital_services_library_url;
- last;
+ if ($is_patron_authorized_to_register_with_rbdigital eq 1) {
+ # Loop through vendors array and get the RBdigital library URL tied to logged in User
+ foreach my $value (@ {$self->ctx->{vendors}}) {
+ if ($value->vendor_key eq 'rbdigital') {
+ $self->ctx->{vendor_library_url} = $value->[0]->digital_services_library_url;
+ last;
+ }
}
}
-
- $self->ctx->{wishlist} = _get_patron_wishlist($self->editor->authtoken, $session_id);
+
} else {
$self->ctx->{rbdigital_patron_id} = 0;
$self->ctx->{vendors} = _get_default_vendor();
vendor_key = 'default';
END;
FOR vendor IN ctx.vendors;
+
+ IF vendor.vendor_key == 'rbdigital';
+ NEXT IF ctx.is_patron_authorized_to_register_with_rbdigital == 0;
+ END;
IF vendor.vendor_key == vendor_key;
vendor_tab_class = "acct-tab-on";
vendor_search_uri = vendor.search_uri;
IF vendor.vendor_key == 'default';
vendor_search_url = ctx.opac_root _ vendor.search_uri;
END;
- IF vendor.vendor_key == 'rbdigital';
- # vendor_library_url = vendor.digital_services_library_url;
- END;
- %]
+ %]
<a id="lnkSearchResults_[% vendor.vendor_key %]"
href="[% vendor_search_url; %]" class="[% vendor_tab_class %]">[% vendor.name %]</a>
[% END; %]