LP#1772680: Changed code to display RBdigital only when user home library is tied...
authorJaswinder Singh <Jaswinder.Singh0011@gmail.com>
Thu, 27 Sep 2018 02:28:42 +0000 (22:28 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Wed, 16 Oct 2019 18:45:00 +0000 (14:45 -0400)
Signed-off-by: Jaswinder Singh <jaswinder.singh0011@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/templates/opac/parts/vendor_tabs.tt2
Open-ILS/web/css/skin/default/ebook/rbdigital.css

index f689afa..8306efe 100644 (file)
@@ -453,22 +453,34 @@ sub load_rbdigital_common {
     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();
index ca10071..1498ca9 100644 (file)
@@ -2150,12 +2150,6 @@ sub load_myopac_main {
         })
     );
 
-    # Call sub to get the session id
-    my $session_id = _get_ebook_session_id();
-
-    # Call sub to get all the vendors to be displayed on the UI
-    $self->ctx->{vendors} = _get_authorized_vendors($self->editor->authtoken, $session_id);
-
     return $self->prepare_fines($limit, $offset) || Apache2::Const::OK;
 }
 
index f162c44..d3872da 100644 (file)
@@ -9,6 +9,10 @@
                     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; %]    
index 4a91a37..e953549 100644 (file)
@@ -19,7 +19,7 @@
     color: #FFFFFF; 
     border: 1px solid green; 
     padding: 10px;
-    font-size: 12px;
+    font-size: 11px;
     width: 600px;
 }