Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding restricted view warning for EDS #4208

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1487,6 +1487,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 Expand Up @@ -1593,6 +1594,7 @@ You do not have any saved resources = "Sie haben noch keine Daten gespeichert"
You do not have any storage retrieval requests placed = "Sie haben keine offenen Magazinbestellungen"
You must be logged in first = "Bitte loggen Sie sich zuerst ein"
Your Account = "Ihr Konto"
Your account only has guest access = "Ihr Konto hat nur Gastzugriff."
Your book bag is empty = "Ihre Zwischenablage ist leer"
Your Checked Out Items = "Ihre ausgeliehenen Exemplare"
Your Comment = "Ihr Kommentar"
Expand Down
2 changes: 2 additions & 0 deletions languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,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 Expand Up @@ -1605,6 +1606,7 @@ You do not have any saved resources = "You do not have any saved items. Perform
You do not have any storage retrieval requests placed = "You do not have any storage retrieval requests placed"
You must be logged in first = "You must be logged in first"
Your Account = "Your Account"
Your account only has guest access = "Your account only has guest access."
Your book bag is empty = "Your book bag is empty"
Your Checked Out Items = "Your Checked Out Items"
Your Comment = "Your Comment"
Expand Down
12 changes: 12 additions & 0 deletions module/VuFind/src/VuFind/Controller/AbstractRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,17 @@ protected function resultScrollerActive()
return false;
}

/**
* Should we display a warning in restricted views?
*
* @return bool
*/
public function showRestrictedViewWarning(): bool
{
// Disabled by default
return false;
}

/**
* Display a particular tab.
*
Expand Down Expand Up @@ -972,6 +983,7 @@ protected function showTab($tab, $ajax = false)
$view->scrollData = $this->resultScroller()->getScrollData($driver);
}

$view->showRestrictedViewWarning = $this->showRestrictedViewWarning();
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
$view->callnumberHandler = $config->Item_Status->callnumber_handler ?? false;

$view->setTemplate($ajax ? 'record/ajaxtab' : 'record/view');
Expand Down
11 changes: 11 additions & 0 deletions module/VuFind/src/VuFind/Controller/EdsrecordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,15 @@ protected function resultScrollerActive()
$config = $this->getService(\VuFind\Config\PluginManager::class)->get('EDS');
return $config->Record->next_prev_navigation ?? false;
}

/**
* Should we display a warning in restricted views?
*
* @return bool
*/
public function showRestrictedViewWarning(): bool
{
$config = $this->getService(\VuFind\Config\PluginManager::class)->get('EDS');
return $config->General->show_restricted_view_warning ?? false;
}
}
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 @@ -431,6 +438,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 @@ -1385,4 +1393,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;
}
}
4 changes: 4 additions & 0 deletions themes/bootstrap3/templates/RecordDriver/EDS/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<?php endif; ?>
<?=$this->record($this->driver)->getLabelList() ?>

<?php if (($this->showRestrictedViewWarning ?? false) && $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
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 @@ -123,6 +123,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('Your account only has guest access');?>
<?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 @@ -86,6 +86,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
4 changes: 4 additions & 0 deletions themes/bootstrap5/templates/RecordDriver/EDS/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<?php endif; ?>
<?=$this->record($this->driver)->getLabelList() ?>

<?php if (($this->showRestrictedViewWarning ?? false) && $restrictedView): ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've put this only in the EDS-specific core.phtml. Should we also include it in the DefaultRecord version, on the assumption that this generic mechanism might also be used in other scenarios?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the DefaultRecord version we don't have a $restrictedView variable we could use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense -- I think it's fine as it is!

<?=$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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$side = $this->config()->offcanvasSide();
$buttonAttrs = [
'class' => 'close-offcanvas btn btn-link ' . $this->_componentClass,
'data-toggle' => 'vufind-offcanvas',
'data-bs-toggle' => 'vufind-offcanvas',
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
];
?>
<button<?=$this->htmlAttributes($buttonAttrs)?>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$spanAttrs = [];
if ($side) {
$aAttrs['class'] .= ' icon-link';
$aAttrs['data-toggle'] = 'vufind-offcanvas';
$aAttrs['data-bs-toggle'] = 'vufind-offcanvas';
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
if ($side === 'left') {
$iconBefore = $this->icon($this->layout()->rtl ? 'offcanvas-show-right' : 'offcanvas-show-left', 'icon-link__icon');
} else {
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 @@ -123,6 +123,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('Your account only has guest access');?>
demiankatz marked this conversation as resolved.
Show resolved Hide resolved
<?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 @@ -86,6 +86,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
Loading