Skip to content

Commit

Permalink
Adding restricted view warning for EDS (#4208)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThoWagen authored Jan 27, 2025
1 parent f4fa2ee commit 1b3a9fd
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 26 deletions.
18 changes: 10 additions & 8 deletions config/vufind/EDS.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ common_limiters = FC,FT,RV
;advanced_limiters = RV,FC,FT
common_expanders = fulltext
default_view = brief
; If a warning should be shown on searches and records when the user only has a restricted view.
show_restricted_view_warning = false

; These are the default recommendations modules to use when no specific setting
; are found in the [TopRecommendations], [SideRecommendations] or
Expand Down Expand Up @@ -281,10 +283,10 @@ profile = "PROFILE"
organization_id = "VuFind from MyUniversity"

; If you have been provided with an EDS API Key, please provide these below.
; API keys are used to monitor access to EDS API, isolating traffic by customer and use-case.
; This isolation allows EBSCO to manage performance for specific keys (use cases). Should a request be throttled,
; the gateway will respond with an HTTP 429. Existing implementations may start using API keys at any time.
; EBSCO will require API keys for all customers at one point, but deadlines have not been established.
; API keys are used to monitor access to EDS API, isolating traffic by customer and use-case.
; This isolation allows EBSCO to manage performance for specific keys (use cases). Should a request be throttled,
; the gateway will respond with an HTTP 429. Existing implementations may start using API keys at any time.
; EBSCO will require API keys for all customers at one point, but deadlines have not been established.
; Customers may have more than one API key for separate client applications or use-cases accessing EDS API.
; Note: API keys do not replace EDS API’s authentication or session tokens.

Expand Down Expand Up @@ -445,11 +447,11 @@ DetailPageFormat = 'Long'
;ShortAuthorLimit = 3

[AdditionalHeaders]
; Due to the nature of EDS API integrations EBSCO's web application firewall (WAF) does not have sufficient
; data to distinguish bots from users. By sending some end-user data to EDS API, EBSCO's WAF can make more
; informed decisions regarding bots.
; Due to the nature of EDS API integrations EBSCO's web application firewall (WAF) does not have sufficient
; data to distinguish bots from users. By sending some end-user data to EDS API, EBSCO's WAF can make more
; informed decisions regarding bots.
; This is important to guarantee accurate COUNTER 5 usage reports. The Counter Code of Practice 5.1 stipulates:
; "Activity generated by internet robots and crawlers MUST be excluded from all COUNTER usage reports."
; "Activity generated by internet robots and crawlers MUST be excluded from all COUNTER usage reports."
; See https://cop5.countermetrics.org/en/5.1/07-processing/08-internet-robots-and-crawlers.html

; If you are already protecting your site from bots, e.g. through your own WAF, you might not wish to enable this
Expand Down
2 changes: 2 additions & 0 deletions languages/de.ini
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ Located = "Standort"
Location = "Standort"
Log Out = "Log out"
logged_in = "Sie haben sich eingeloggt."
logged_in_access_restricted = "Ihr Konto hat nicht vollen Zugriff."
Login = "Login"
Login for full access = "Für Vollzugriff bitte einloggen."
login_disabled = "Login steht momentan nicht zur Verfügung."
Expand Down Expand Up @@ -1487,6 +1488,7 @@ Theme = "Layout"
Thesis = "Abschlussarbeit"
This email was sent from = "Diese Mail wurde verschickt von"
This field is required = "Pflichtfeld"
This is only a restricted view = "Dies ist nur eine eingeschränkte Ansicht."
This item is already part of the following list/lists = "Dieser Datensatz ist bereits in der/den folgenden Liste/Listen enthalten"
This result is not displayed to guests = "Dieser Treffer wird im Gastzugang nicht angezeigt."
Title = "Titel"
Expand Down
2 changes: 2 additions & 0 deletions languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ Located = "Located"
Location = "Location"
Log Out = "Log Out"
logged_in = "You have logged in."
logged_in_access_restricted = "Your account has not been granted full access."
Login = "Login"
Login for full access = "Login for full access."
login_disabled = "Login is not available at this time."
Expand Down Expand Up @@ -1499,6 +1500,7 @@ Theme = "Theme"
Thesis = "Thesis"
This email was sent from = "This email was sent from"
This field is required = "This field is required"
This is only a restricted view = "This is only a restricted view."
This item is already part of the following list/lists = "This item is already part of the following list/lists"
This result is not displayed to guests = "This result is not displayed to guests."
Title = "Title"
Expand Down
18 changes: 18 additions & 0 deletions module/VuFind/src/VuFind/Search/Base/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,13 @@ abstract class Options implements TranslatorAwareInterface
*/
protected $displayCitationLinksInResults;

/**
* Should we display a warning in restricted views?
*
* @var bool
*/
protected bool $showRestrictedViewWarning;

/**
* Constructor
*
Expand Down Expand Up @@ -430,6 +437,7 @@ public function __construct(\VuFind\Config\PluginManager $configLoader)
$this->hiddenSortOptions = $searchSettings?->HiddenSorting?->pattern?->toArray() ?? [];
$this->displayCitationLinksInResults
= (bool)($searchSettings->Results_Settings->display_citation_links ?? true);
$this->showRestrictedViewWarning = (bool)($searchSettings->General->show_restricted_view_warning ?? false);
}

/**
Expand Down Expand Up @@ -1387,4 +1395,14 @@ public function getHierarchicalFacetFilters(?string $field = null): array
}
return $this->hierarchicalFacetFilters;
}

/**
* Should we display a warning in restricted views?
*
* @return bool
*/
public function showRestrictedViewWarning(): bool
{
return $this->showRestrictedViewWarning ?? false;
}
}
17 changes: 17 additions & 0 deletions module/VuFind/src/VuFind/Search/Base/Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ abstract class Results
*/
protected $hierarchicalFacetHelper = null;

/**
* If the results provide only a restricted view.
*
* @var bool
*/
protected bool $restrictedView = false;

/**
* Extra search details.
*
Expand Down Expand Up @@ -843,6 +850,16 @@ public function getFullFieldFacets(
return $facets;
}

/**
* Check if the results provide only a restricted view.
*
* @return bool
*/
public function isRestrictedView()
{
return $this->restrictedView;
}

/**
* Get the extra search details
*
Expand Down
1 change: 1 addition & 0 deletions module/VuFind/src/VuFind/Search/EDS/Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected function performSearch()

// Construct record drivers for all the items in the response:
$this->results = $collection->getRecords();
$this->restrictedView = $collection->isRestrictedView();
}
}

Expand Down
4 changes: 4 additions & 0 deletions module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use VuFind\Config\Config;
use VuFind\Config\Feature\SecretTrait;
use VuFindSearch\Backend\AbstractBackend;
use VuFindSearch\Backend\EDS\Response\RecordCollection;
use VuFindSearch\Backend\Exception\BackendException;
use VuFindSearch\ParamBag;
use VuFindSearch\Query\AbstractQuery;
Expand Down Expand Up @@ -286,6 +287,9 @@ public function search(
}
$collection = $this->createRecordCollection($response);
$this->injectSourceIdentifier($collection);
if ($this->isGuest && $collection instanceof RecordCollection) {
$collection->setRestrictedView(true);
}
return $collection;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class RecordCollection extends AbstractRecordCollection
*/
protected $facetFields = null;

/**
* If the results only provide a restricted view.
*
* @var bool
*/
protected bool $restrictedView = false;

/**
* Constructor.
*
Expand Down Expand Up @@ -148,4 +155,26 @@ public function getOffset()
}
return 0;
}

/**
* Set if the results only provide a restricted view.
*
* @param bool $restrictedView If restricted view
*
* @return void
*/
public function setRestrictedView(bool $restrictedView): void
{
$this->restrictedView = $restrictedView;
}

/**
* Check if the results only provide a restricted view.
*
* @return bool
*/
public function isRestrictedView()
{
return $this->restrictedView;
}
}
9 changes: 6 additions & 3 deletions themes/bootstrap3/templates/RecordDriver/EDS/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$cover = $coverDetails['html'];
$edsConfig = $this->config()->get('EDS');
$authorDisplay = strtolower($edsConfig->AuthorDisplay->DetailPageFormat ?? 'Long');
$searchOptions = $this->searchOptions($this->driver->getSourceIdentifier());
?>
<div class="media"<?=$this->schemaOrg()->getAttributes(['vocab' => 'http://schema.org/', 'resource' => '#record', 'typeof' => $this->schemaOrg()->getRecordTypes($this->driver)])?>>
<div class="media-left medium img-col">
Expand Down Expand Up @@ -76,6 +77,10 @@
<?php endif; ?>
<?=$this->record($this->driver)->getLabelList() ?>

<?php if ($searchOptions->showRestrictedViewWarning() && $restrictedView): ?>
<?=$this->render('error/restrictedViewWarning.phtml')?>
<?php endif; ?>

<table class="table table-striped">
<caption class="sr-only"><?=$this->transEsc('Bibliographic Details')?></caption>
<?php foreach ($items as $key => $item): ?>
Expand Down Expand Up @@ -134,9 +139,7 @@
<td colspan="2">
<div class="alert alert-info">
<?=$this->transEsc('Full text is not displayed to guests')?>
<a class="login" href="<?=$this->url('myresearch-userlogin')?>" rel="nofollow">
<strong><?=$this->transEsc('Login for full access')?></strong>
</a>
<?=$this->render('error/loginForAccess.phtml')?>
</div>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
<p>
<?=$this->transEsc('This result is not displayed to guests')?>
<br>
<a class="login" href="<?=$this->url('myresearch-userlogin')?>">
<strong><?=$this->transEsc('Login for full access')?></strong>
</a>
<?=$this->render('error/loginForAccess.phtml')?>
</p>
</div>
<?php endif; ?>
Expand Down
4 changes: 4 additions & 0 deletions themes/bootstrap3/templates/combined/results-list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
</div>
<?php /* End Listing Options */ ?>

<?php if ($results->getOptions()->showRestrictedViewWarning() && $results->isRestrictedView()): ?>
<?=$this->render('error/restrictedViewWarning.phtml')?>
<?php endif; ?>

<?php foreach($this->extraErrors ?? [] as $error): ?>
<div class="alert alert-danger"><?=$this->transEsc($error)?></div>
<?php endforeach; ?>
Expand Down
11 changes: 8 additions & 3 deletions themes/bootstrap3/templates/error/loginForAccess.phtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php // This can be used as a permission denied behavior; see example in permissionBehavior.ini... ?>
<a class="login" href="<?=$this->url('myresearch-home')?>" rel="nofollow">
<strong><?=$this->transEsc('Login for full access')?></strong>
</a>
<?php $isLoggedin = $this->auth()->getUserObject() !== null; ?>
<?php if (!$isLoggedin): ?>
<a class="login" href="<?=$this->url('myresearch-userlogin')?>">
<strong><?=$this->transEsc('Login for full access')?></strong>
</a>
<?php else: ?>
<?=$this->transEsc('logged_in_access_restricted');?>
<?php endif; ?>
4 changes: 4 additions & 0 deletions themes/bootstrap3/templates/error/restrictedViewWarning.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="alert alert-info">
<?=$this->transEsc('This is only a restricted view')?>
<?=$this->render('error/loginForAccess.phtml')?>
</div>
4 changes: 4 additions & 0 deletions themes/bootstrap3/templates/search/results.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
</div>
<?php /* End Listing Options */ ?>

<?php if ($options->showRestrictedViewWarning() && $this->results->isRestrictedView()): ?>
<?=$this->render('error/restrictedViewWarning.phtml')?>
<?php endif; ?>

<?php if ($recordTotal < 1): ?>
<p>
<?php
Expand Down
9 changes: 6 additions & 3 deletions themes/bootstrap5/templates/RecordDriver/EDS/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
$cover = $coverDetails['html'];
$edsConfig = $this->config()->get('EDS');
$authorDisplay = strtolower($edsConfig->AuthorDisplay->DetailPageFormat ?? 'Long');
$searchOptions = $this->searchOptions($this->driver->getSourceIdentifier());
?>
<div class="media"<?=$this->schemaOrg()->getAttributes(['vocab' => 'http://schema.org/', 'resource' => '#record', 'typeof' => $this->schemaOrg()->getRecordTypes($this->driver)])?>>
<div class="media-left medium img-col">
Expand Down Expand Up @@ -76,6 +77,10 @@
<?php endif; ?>
<?=$this->record($this->driver)->getLabelList() ?>

<?php if ($searchOptions->showRestrictedViewWarning() && $restrictedView): ?>
<?=$this->render('error/restrictedViewWarning.phtml')?>
<?php endif; ?>

<table class="table table-striped">
<caption class="sr-only"><?=$this->transEsc('Bibliographic Details')?></caption>
<?php foreach ($items as $key => $item): ?>
Expand Down Expand Up @@ -134,9 +139,7 @@
<td colspan="2">
<div class="alert alert-info">
<?=$this->transEsc('Full text is not displayed to guests')?>
<a class="login" href="<?=$this->url('myresearch-userlogin')?>" rel="nofollow">
<strong><?=$this->transEsc('Login for full access')?></strong>
</a>
<?=$this->render('error/loginForAccess.phtml')?>
</div>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
<p>
<?=$this->transEsc('This result is not displayed to guests')?>
<br>
<a class="login" href="<?=$this->url('myresearch-userlogin')?>">
<strong><?=$this->transEsc('Login for full access')?></strong>
</a>
<?=$this->render('error/loginForAccess.phtml')?>
</p>
</div>
<?php endif; ?>
Expand Down
4 changes: 4 additions & 0 deletions themes/bootstrap5/templates/combined/results-list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
</div>
<?php /* End Listing Options */ ?>

<?php if ($results->getOptions()->showRestrictedViewWarning() && $results->isRestrictedView()): ?>
<?=$this->render('error/restrictedViewWarning.phtml')?>
<?php endif; ?>

<?php foreach($this->extraErrors ?? [] as $error): ?>
<div class="alert alert-danger"><?=$this->transEsc($error)?></div>
<?php endforeach; ?>
Expand Down
11 changes: 8 additions & 3 deletions themes/bootstrap5/templates/error/loginForAccess.phtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php // This can be used as a permission denied behavior; see example in permissionBehavior.ini... ?>
<a class="login" href="<?=$this->url('myresearch-home')?>" rel="nofollow">
<strong><?=$this->transEsc('Login for full access')?></strong>
</a>
<?php $isLoggedin = $this->auth()->getUserObject() !== null; ?>
<?php if (!$isLoggedin): ?>
<a class="login" href="<?=$this->url('myresearch-userlogin')?>">
<strong><?=$this->transEsc('Login for full access')?></strong>
</a>
<?php else: ?>
<?=$this->transEsc('logged_in_access_restricted');?>
<?php endif; ?>
4 changes: 4 additions & 0 deletions themes/bootstrap5/templates/error/restrictedViewWarning.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="alert alert-info">
<?=$this->transEsc('This is only a restricted view')?>
<?=$this->render('error/loginForAccess.phtml')?>
</div>
4 changes: 4 additions & 0 deletions themes/bootstrap5/templates/search/results.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
</div>
<?php /* End Listing Options */ ?>

<?php if ($options->showRestrictedViewWarning() && $this->results->isRestrictedView()): ?>
<?=$this->render('error/restrictedViewWarning.phtml')?>
<?php endif; ?>

<?php if ($recordTotal < 1): ?>
<p>
<?php
Expand Down

0 comments on commit 1b3a9fd

Please sign in to comment.