Skip to content
Snippets Groups Projects
Commit 32fbf69e authored by Dorian Merz's avatar Dorian Merz
Browse files

refs #16522 [master] adds hasRecordPermissions

* allows for specific test for presence of a single RecordPermission
parent 236b58d8
No related merge requests found
...@@ -34,6 +34,7 @@ namespace finc\RecordDriver; ...@@ -34,6 +34,7 @@ namespace finc\RecordDriver;
use VuFindSearch\ParamBag; use VuFindSearch\ParamBag;
use VuFindSearch\Query\Query as Query; use VuFindSearch\Query\Query as Query;
use Zend\Config\Config;
/** /**
* finc specific model for Solr records based on the stock * finc specific model for Solr records based on the stock
...@@ -155,6 +156,26 @@ trait SolrDefaultFincTrait ...@@ -155,6 +156,26 @@ trait SolrDefaultFincTrait
return null; return null;
} }
public function hasRecordPermission(String $permission) : bool
{
// do we have a RecordPermissions section in config.ini?
if (isset($this->mainConfig->RecordPermissions)) {
$settings = $this->mainConfig->RecordPermissions->{$permission} ?? null;
if (is_null($settings)) return false;
if ($settings instanceof Config) $settings = $settings->toArray();
foreach ((array) $settings as $value) {
list($methodName, $methodReturn) = explode(':', $value);
if (in_array($methodReturn, (array) $this->tryMethod($methodName))) {
// as the current permission matches the current record,
// return it
return true;
}
}
}
// either no settings for the permission were present or none matched, so return false
return false;
}
/** /**
* Controller to decide when local format field of a library should be * Controller to decide when local format field of a library should be
* retrieved from marc. Pass through method for PrimoCentral * retrieved from marc. Pass through method for PrimoCentral
......
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