The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit 4801ed44 authored by Alexander Purr's avatar Alexander Purr Committed by Dorian Merz
Browse files

refs #18996 [fid_bbi] show digitization-on-demand link on details page

* if logged in and correct permission &
* record older than 71 years &
* format is no ebook
* format is Atlas, Book, Manuscript, Map, Print or Thesis
parent bc6b28b7
No related merge requests found
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
namespace fid_bbi\View\Helper\Root; namespace fid_bbi\View\Helper\Root;
use Interop\Container\ContainerInterface; use Interop\Container\ContainerInterface;
use VuFind\Role\PermissionManager;
/** /**
* Factory for Root view helpers. * Factory for Root view helpers.
...@@ -56,7 +57,8 @@ class Factory ...@@ -56,7 +57,8 @@ class Factory
$container->get('ViewHelperManager')->get('url'), $container->get('ViewHelperManager')->get('url'),
$container->get('VuFind\AuthManager'), $container->get('VuFind\AuthManager'),
$container->get('finc\Rewrite\EblRewrite'), $container->get('finc\Rewrite\EblRewrite'),
$container->get('VuFind\Config')->get('Resolver') $container->get('VuFind\Config')->get('Resolver'),
$container->get(PermissionManager::class)
); );
//due to https://github.com/vufind-org/vufind/pull/718 //due to https://github.com/vufind-org/vufind/pull/718
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
*/ */
namespace fid_bbi\View\Helper\Root; namespace fid_bbi\View\Helper\Root;
use VuFind\Role\PermissionManager;
/** /**
* Record driver view helper * Record driver view helper
* *
...@@ -43,13 +45,19 @@ class Record extends \finc\View\Helper\Root\Record ...@@ -43,13 +45,19 @@ class Record extends \finc\View\Helper\Root\Record
*/ */
protected $formatIconMappings = []; protected $formatIconMappings = [];
public function __construct($config, \Zend\View\Helper\Url $helper, \VuFind\Auth\Manager $manager, $rewrite, $resolverConfig) /**
* @var PermissionManager
*/
protected $permissionManager;
public function __construct($config, \Zend\View\Helper\Url $helper, \VuFind\Auth\Manager $manager, $rewrite, $resolverConfig, PermissionManager $permissionManager)
{ {
parent::__construct($config, $helper, $manager, $rewrite, $resolverConfig); parent::__construct($config, $helper, $manager, $rewrite, $resolverConfig);
$formatIconMappingsFile = APPLICATION_PATH.$config->Record->format_icon_mappings_file_path; $formatIconMappingsFile = APPLICATION_PATH . $config->Record->format_icon_mappings_file_path;
if (file_exists($formatIconMappingsFile)) { if (file_exists($formatIconMappingsFile)) {
$this->formatIconMappings = json_decode(file_get_contents($formatIconMappingsFile), true); $this->formatIconMappings = json_decode(file_get_contents($formatIconMappingsFile), true);
} }
$this->permissionManager = $permissionManager;
} }
/** /**
...@@ -112,7 +120,7 @@ class Record extends \finc\View\Helper\Root\Record ...@@ -112,7 +120,7 @@ class Record extends \finc\View\Helper\Root\Record
$subtitle = (!empty($subTitle) ? ': ' . $subTitle : '') . $subtitle = (!empty($subTitle) ? ': ' . $subTitle : '') .
(!empty($sectionTitle) ? ', ' . $sectionTitle : ''); (!empty($sectionTitle) ? ', ' . $sectionTitle : '');
$subtitle = preg_replace('/^((\S*\s){'.$maxLengthArr.'})\S.*$/','$1 ...',$subtitle); $subtitle = preg_replace('/^((\S*\s){' . $maxLengthArr . '})\S.*$/', '$1 ...', $subtitle);
if (!empty($subtitle)) { if (!empty($subtitle)) {
$escapeHtml = $this->getView()->plugin('escapeHtml'); $escapeHtml = $this->getView()->plugin('escapeHtml');
...@@ -123,9 +131,34 @@ class Record extends \finc\View\Helper\Root\Record ...@@ -123,9 +131,34 @@ class Record extends \finc\View\Helper\Root\Record
public function getIconMapping($format = null) public function getIconMapping($format = null)
{ {
if (is_null($format)) { if (null === $format) {
$format = ($this->driver->tryMethod('getFormats') ?? ['Unknown format'])[0]; $format = ($this->driver->tryMethod('getFormats') ?? ['Unknown format'])[0];
} }
return $this->formatIconMappings[$format] ?? 'unknown'; return $this->formatIconMappings[$format] ?? 'unknown';
} }
public function allowDigitizationOnDemand()
{
if (!$this->manager->isLoggedIn()) {
return false;
}
if (!$this->permissionManager->isAuthorized('fid.Acquisitions')) {
return false;
}
$publishDate = $this->driver->tryMethod('getPublishDateSort');
$copyrightExpiredDate = date("Y") - 71;
if (!($publishDate < $copyrightExpiredDate && $publishDate > 0)) {
return false;
}
$formats = $this->driver->tryMethod('getFormat');
if (in_array("eBook", $formats)) {
return false;
}
$allowedFormats = ["Atlas","Book","Manuscript","Map","Print","Thesis"];
if (array_intersect($allowedFormats, $formats)) {
return true;
} else {
return false;
}
}
} }
...@@ -100,6 +100,20 @@ ...@@ -100,6 +100,20 @@
</a> </a>
</li> </li>
<?php if($this->record($this->driver)->allowDigitizationOnDemand()): ?>
<li>
<a
class="link-with-icon"
data-lightbox
href="<?=$this->recordLink()->getActionUrl($this->driver, 'fidDigitization')?>"
rel="nofollow"
>
<?=$this->icon('small/scan-book')?>
<?=$this->transEsc('Digitization-On-Demand Service')?>
</a>
</li>
<?php endif; ?>
<li> <li>
<a <a
class="link-with-icon" class="link-with-icon"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment