diff --git a/module/fid/src/View/Helper/Root/GetIt.php b/module/fid/src/View/Helper/Root/GetIt.php index 263687c840f6ad6b780d7a619739296e5746ba82..df73259aa95f6583d473181a31137eb7f4eb1e8c 100644 --- a/module/fid/src/View/Helper/Root/GetIt.php +++ b/module/fid/src/View/Helper/Root/GetIt.php @@ -152,7 +152,7 @@ class GetIt extends AbstractHelper private function _getNonSourceIds($value) { $sids = $this->config->NonSourceIds; - return isset($sids->$value) ? $sids->$value : ''; + return $sids->$value ?? ''; } /** @@ -168,6 +168,7 @@ class GetIt extends AbstractHelper $accordeonHeadline = $this->accordeonHeadlineDefault; $boxHeadline = $this->translate('Get it'); $notice = $this->translate('getit_text_default'); + $noticeWithLink = null; $showLinks = true; $showOrderButton = false; $showPartCopyButton = false; @@ -179,9 +180,8 @@ class GetIt extends AbstractHelper // let specific functions override defaults where necessary foreach ($this->sids as $sid_config) { - if (in_array($this->sid, $sid = $this->_getSourceIds($sid_config))) - { - $foo = 'get_config_'.$sid_config; + if (in_array($this->sid, $sid = $this->_getSourceIds($sid_config))) { + $foo = 'get_config_' . $sid_config; $this->$foo( $accordeonColor, $accordeonHeadline, @@ -194,10 +194,10 @@ class GetIt extends AbstractHelper $bossData, $isEBCEBooks, $hideNotice, - $isAiSidRecord + $isAiSidRecord, + $noticeLinkType ); - if ($this->sid !== '0') - { + if ($this->sid !== '0') { //special case for source ID 0 // this is th only SID that is contained in multiple configs (V8 + V9) break; @@ -216,7 +216,8 @@ class GetIt extends AbstractHelper 'bossData', 'isEBCEBooks', 'hideNotice', - 'isAiSidRecord' + 'isAiSidRecord', + 'noticeLinkType' ); } @@ -235,6 +236,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV1( &$accordeonColor, @@ -248,9 +250,9 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { $accordeonColor = $this->accordeonColorAlternative; $accordeonHeadline = $this->accordeonHeadlineAlternative; $notice = $this->translate('getit_text_1'); @@ -271,6 +273,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV3( &$accordeonColor, @@ -284,9 +287,9 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { $accordeonColor = $this->accordeonColorAlternative; $accordeonHeadline = $this->accordeonHeadlineAlternative; $boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); @@ -311,6 +314,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV4( &$accordeonColor, @@ -324,11 +328,16 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { $boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); - $notice = $this->fidClient->isLoggedOn() ? $this->translate('getit_text_12') : $this->translate('getit_text_2'); + if ($this->fidClient->isLoggedOn()) { + $notice = $this->translate('getit_text_12'); + } else { + $notice = $this->translate('getit_text_2'); + $noticeLinkType = "register"; + } $showOrderButton = isset($this->config->Permission->allowPDA) ? $this->config->Permission->allowPDA : true; } @@ -348,6 +357,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV5( &$accordeonColor, @@ -361,14 +371,29 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { + $limited_access = false; + if ($this->fidClient->isLoggedOn()) { + $limited_access = $this->fidClient->requestUserDetails()->hasPermission('limited_access'); + } + $accordeonColor = $this->accordeonColorAlternative; $accordeonHeadline = $this->accordeonHeadlineAlternative; - $notice = !$this->fidClient->isLoggedOn() ? $this->translate('getit_text_3_1') : $this->translate('getit_text_13'); + if ($this->fidClient->isLoggedOn()) { + if ($limited_access) { + $notice = $this->translate('getit_text_13'); + } else { + $notice = $this->translate('getit_text_13b_1'); + $noticeLinkType = "contact"; + } + } else { + $notice = $this->translate('getit_text_3_1'); + $noticeLinkType = "register"; + } $boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); - $showLinks = $this->fidClient->isLoggedOn(); + $showLinks = $this->fidClient->isLoggedOn() && $limited_access; } /** @@ -386,6 +411,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV6( &$accordeonColor, @@ -399,9 +425,9 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { $notice = $this->translate('getit_text_4'); } @@ -420,6 +446,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV7( &$accordeonColor, @@ -433,9 +460,9 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { $accordeonColor = $this->accordeonColorAlternative; $accordeonHeadline = $this->accordeonHeadlineAlternative; $notice = $this->translate('getit_text_5'); @@ -456,6 +483,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV8( &$accordeonColor, @@ -469,9 +497,9 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { //accordeon if (in_array('Free', $this->facetAvail)) { $accordeonHeadline = $this->accordeonHeadlineAlternative; @@ -491,8 +519,7 @@ class GetIt extends AbstractHelper && preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->format) ) { $isLogin = true; - } - elseif (in_array('Local', $this->facetAvail) + } elseif (in_array('Local', $this->facetAvail) && ((preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) && !in_array($this->_getNonSourceIds('source_idsV8_9'), $this->institution)) || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format) @@ -517,35 +544,30 @@ class GetIt extends AbstractHelper } else { $notice = $this->translate('getit_text_13'); } - } - elseif ($this->isCollection) { - $notice = $this->translate('getit_text_11',['%%hierarchy_tree%%' => $this->translate('hierarchy_tree')]); - } - elseif (preg_grep($this->_getNonSourceIds('source_idsV8_7'), $this->megacollection) + } elseif ($this->isCollection) { + $notice = $this->translate('getit_text_11', ['%%hierarchy_tree%%' => $this->translate('hierarchy_tree')]); + } elseif (preg_grep($this->_getNonSourceIds('source_idsV8_7'), $this->megacollection) ) { $notice = $this->translate('getit_text_1'); - } - elseif (in_array('Local', $this->facetAvail) + } elseif (in_array('Local', $this->facetAvail) && (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) ) { if (!$this->fidClient->isLoggedOn()) { $notice = $this->translate('getit_text_10'); + $noticeLinkType = "register"; } elseif (preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) { $notice = $this->translate('getit_text_14'); } else { $notice = ''; } - } - elseif (in_array('Local', $this->facetAvail) + } elseif (in_array('Local', $this->facetAvail) && preg_grep($this->_getNonSourceIds('source_idsV8_2'), $this->format) ) { $notice = $this->translate('getit_text_8'); - } - elseif (in_array('Free', $this->facetAvail)) { + } elseif (in_array('Free', $this->facetAvail)) { $notice = $this->translate('getit_text_1'); - } - elseif (in_array('Online', $this->facetAvail) + } elseif (in_array('Online', $this->facetAvail) && (preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format)) ) { @@ -555,12 +577,13 @@ class GetIt extends AbstractHelper ) { if (!$this->fidClient->isLoggedOn()) { $notice = $this->translate('getit_text_10'); + $noticeLinkType = "register"; } else { $notice = $this->translate('getit_text_15'); } } } elseif ($this->isCollection) { - $notice = $this->translate('getit_text_11',['%%hierarchy_tree%%' => $this->translate('hierarchy_tree')]); + $notice = $this->translate('getit_text_11', ['%%hierarchy_tree%%' => $this->translate('hierarchy_tree')]); } elseif (in_array('Local', $this->facetAvail) && preg_grep($this->_getNonSourceIds('source_idsV8_2'), $this->format) ) { @@ -568,6 +591,7 @@ class GetIt extends AbstractHelper } elseif (in_array('Local', $this->facetAvail)) { if (!$this->fidClient->isLoggedOn()) { $notice = $this->translate('getit_text_10'); + $noticeLinkType = "register"; } elseif (preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) { $notice = $this->translate('getit_text_14'); } elseif (!preg_grep($this->_getNonSourceIds('source_idsV8_10'), $this->format)) { @@ -585,6 +609,7 @@ class GetIt extends AbstractHelper ) { if (!$this->fidClient->isLoggedOn()) { $notice = $this->translate('getit_text_10'); + $noticeLinkType = "register"; } else { $notice = $this->translate('getit_text_15'); } @@ -611,8 +636,7 @@ class GetIt extends AbstractHelper //END bossData //hideNotice if ($this->fidClient->isLoggedOn()) { - if (in_array('Local', $this->facetAvail)) - { + if (in_array('Local', $this->facetAvail)) { if (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) && empty($this->isbn) && !preg_grep($this->_getNonSourceIds('source_idsV8_9'), $this->institution) @@ -643,6 +667,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV9( &$accordeonColor, @@ -656,9 +681,9 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { //accordeon if (preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) || preg_grep($this->_getNonSourceIds('source_idsV8_7'), $this->megacollection) @@ -710,6 +735,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV10( &$accordeonColor, @@ -723,9 +749,9 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { $accordeonColor = $this->accordeonColorAlternative; $accordeonHeadline = $this->accordeonHeadlineAlternative; $notice = $this->translate('getit_text_6'); @@ -746,6 +772,7 @@ class GetIt extends AbstractHelper * @param $isEBCEBooks boolean is given record UBL-FID-EBC * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV11( &$accordeonColor, @@ -759,9 +786,9 @@ class GetIt extends AbstractHelper &$bossData, &$isEBCEBooks, &$hideNotice, - &$isAiSidRecord - ) - { + &$isAiSidRecord, + &$noticeLinkType + ) { $notice = $this->translate('getit_text_7'); }