diff --git a/devops/i18n-merge.sh b/devops/i18n-merge.sh new file mode 100755 index 0000000000000000000000000000000000000000..2dafe51188842c1a773d98377d6ae3500002850c --- /dev/null +++ b/devops/i18n-merge.sh @@ -0,0 +1,153 @@ +#!/usr/bin/env bash +# Copyright (C) 2021 Leipzig University Library +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# @author Robert Lange <lange@ub.uni-leipzig.de> +# @license https://opensource.org/licenses/GPL-3.0 GNU GPLv3 + +# this script merges token files and removes unused / duplicate tokens with parent and target translation file *.ini +# assumes You are in projects base dir + +CACHE_FILE=$1; INSTANCE_FILE=$2; PARENT_FILE=$3; + +HAS_ERROR=0; +if [ -z "$CACHE_FILE" ] || [ -z "$INSTANCE_FILE" ]; then + SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + HAS_ERROR=1 + echo "Usage: $0 path/to/language/with/new/tokens path/to/language/file/of/instance [path/to/parent/file/of/instance]" + echo "example command 1: \"devops/i18n-merge.sh data/i18n/languages/de.ini de_zi4/languages/de.ini local/languages/de.ini\""; +else + if [ ! -f "$CACHE_FILE" ] + then + echo "Language File "$CACHE_FILE" does not exist on your filesystem."; HAS_ERROR=1; + fi + + if [ ! -f "$INSTANCE_FILE" ] + then + echo "Language File "$INSTANCE_FILE" does not exist on your filesystem."; HAS_ERROR=1; + fi +fi + +if [ -z "$CACHE_FILE" ]; then + if [ ! -f "$PARENT_FILE" ]; then + echo "Parent Language File "$PARENT_FILE" does not exist on your filesystem."; + HAS_ERROR=1; + fi +fi + +if [ $HAS_ERROR = 1 ] +then + #echo "exit 1: aborting" + exit 1; +fi + +echo "Read new tokens from $CACHE_FILE." +declare -A newTokens +declare -a newTokensOrder +while IFS= read -r line || [ -n "$line" ] # handle possible missing newline in last line +do + key=$(echo "$line" | awk -F: '{ st = index($0,"=");print substr($0,0,st-1)}') + value=$(echo "$line" | awk -F: '{ st = index($0,"=");print substr($0,st+1)}') + newTokens["$key"]="$value" + newTokensOrder+=("$key"); +done < $CACHE_FILE + +echo "Reading and minify existing tokens from $INSTANCE_FILE" +declare -A instanceTokens +declare -A instanceComments +declare -a instanceTokensOrder +i=0 +while IFS= read -r line || [ -n "$line" ]; # handle possible missing newline in last line +do + if [ -z "$line" ]; then + #echo "empty" + instanceTokensOrder+=("X_empty_X"); + elif [[ ${line:0:1} == "#" ]] || [[ ${line:0:1} == ";" ]]; then + #echo "comment" + instanceTokensOrder+=("X_comment_$i") + instanceComments["X_comment_$i"]="$line" + elif [[ ${line:0:11} == "@parent_ini" ]]; then + #echo "relative path to parent ini" + instanceTokensOrder+=("X_comment_$i") + instanceComments["X_comment_$i"]="$line" + #PARENT_FILE=$(echo "$line" | awk -F: '{ st = index($0,"=");print substr($0,st+3)} ' | sed 's/.$//') + #PARENT_FILE=$(echo "${PARENT_FILE#@(.)}") + #PARENT_FILE="${INSTANCE_FILE}/${PARENT_FILE}" + #echo "$PARENT_FILE" + else + key=$(echo "$line" | awk -F: '{ st = index($0,"=");print substr($0,0,st-1)}') + value=$(echo "$line" | awk -F: '{ st = index($0,"=");print substr($0,st+1)}') + #echo "$line" + # only add to instanceTokensOrder when key entry is NOT already existing -> remove duplicates / ignored by letting latest entry win + if [[ -n "${instanceTokens["$key"]}" ]]; then + echo "* remove duplicate token \"${key}\" with obsolete value ${instanceTokens["$key"]} by $value." + else + instanceTokensOrder+=("$key"); + fi + instanceTokens["$key"]="$value"; + fi + ((i=i+1)) +done < $INSTANCE_FILE + +if [ -f "$PARENT_FILE" ]; then + echo "Reading and minifying existing tokens from $PARENT_FILE..." + declare -A parentTokens + declare -a parentTokensOrder + while IFS= read -r line || [ -n "$line" ] + do + if [ -z "$line" ] || [[ ${line:0:1} == "#" ]] || [[ ${line:0:1} == ";" ]] || [[ ${line:0:11} == "@parent_ini" ]]; then + continue + else + key=$(echo "$line" | awk -F: '{ st = index($0,"=");print substr($0,0,st-1)}') + value=$(echo "$line" | awk -F: '{ st = index($0,"=");print substr($0,st+1)}') + #echo "$line" + # only add to instanceTokensOrder when key entry is NOT already existing -> remove duplicates / ignored by letting latest entry win + if [[ ${instanceTokens["$key"]} == "$value" ]] ; then + #instanceTokens["$key"]="$value"; + echo "* remove duplicate token \"${key}\" and $value with parent file." + instanceTokens["$key"]="X_duplicate_X"; + fi + fi + done < $PARENT_FILE +fi + +echo "Adding new token translations..." +for i in "${!newTokensOrder[@]}" +do + if [[ -n "${instanceTokens[${newTokensOrder[$i]}]}" ]]; then + echo "* replace token \"${newTokensOrder[$i]}\" with old value ${instanceTokens[${newTokensOrder[$i]}]} by new value $value" + else + instanceTokensOrder+=("${newTokensOrder[$i]}"); + echo "* add new token \"${newTokensOrder[$i]}\" with value ${newTokens[${newTokensOrder[$i]}]}" + fi + instanceTokens["${newTokensOrder[$i]}"]="${newTokens[${newTokensOrder[$i]}]}"; +done + +echo "4) Writing merged translations to instance file..." +true > "${INSTANCE_FILE}" +for i in "${!instanceTokensOrder[@]}" +do + key="${instanceTokensOrder[$i]}" + if [[ "$key" == "X_empty_X" ]]; then + #echo "empty" + echo -en '\n' >> "${INSTANCE_FILE}" + elif [[ ${key:0:10} == "X_comment_" ]]; then + #echo "comment" + echo "${instanceComments[${key}]}" >> "${INSTANCE_FILE}" + elif [[ "${instanceTokens[${key}]}" != "X_duplicate_X" ]]; then + #echo "$key" + echo "${key}=${instanceTokens[${key}]}" >> "${INSTANCE_FILE}" + fi +done diff --git a/local/config/vufind/config.ini b/local/config/vufind/config.ini index 1fac69a4f0fc852f51fc26ce03bcf4e657e0330a..c4f84f2d911ca450e130da97c843e02fba6688f0 100644 --- a/local/config/vufind/config.ini +++ b/local/config/vufind/config.ini @@ -1565,17 +1565,6 @@ nbn[pattern] = "^urn:nbn:" nbn[search] = "urn:nbn:" nbn[replace] = "http://nbn-resolving.de/urn:nbn:" -; This section defines urls to match with record entries of external ILS. -; - The url pattern is defined as value with %s replacement placeholder. -; - The variable name indicates which identifier should be taken as replacement. -; Currently possibles values are _id_ for unique solr id (finc.id) and _ppn_ as -; record id of data other provider. -; - The variable key indicates the institution for those replacement should be take -; place. -[ExternalAccess] -; ppn[DE-D13] = "http://webopac.skd.museum/libero/WebopacOpenURL.cls?ACTION=DISPLAY&RID=%s" -; id[DE-14] = "http://katalogbeta.slub-dresden.de/id/%s/" - ; ***************** ; * EOF finc ; ***************** diff --git a/local/languages/de.ini b/local/languages/de.ini index 07a4c46a933050a3841d0c3e45c47ee3d257cf2b..9966a9252f8fa4037da669a2f6e18a43f682b66a 100644 --- a/local/languages/de.ini +++ b/local/languages/de.ini @@ -87,7 +87,7 @@ TactileText = "taktiler Text" Collage = Collage Drawing = Zeichnung Painting = Gemälde -Print = Druck +Print = "Drucken" Photonegative = Photonegativ FlashCard = "Flash Card" Chart = "Tabelle / Grafik" @@ -270,7 +270,7 @@ Electronic Resource (Remote Access) = "Elektronische Ressource im Fernzugriff" Electronic Resources = Online-Ressourcen Electronic Serial = "Elektronische Zeitschrift" Electronic Thesis = "Elektronische Hochschulschrift" -Email = "E-Mail" +Email = "Mailen" Email Address = "E-Mail-Adresse" Email Record = "E-Mail-Eintrag" Email address is invalid = "Die E-Mail-Adresse ist ungültig" @@ -646,7 +646,7 @@ banner_link = "kommentieren Sie im Blog!" bookbag_confirm_empty = "Wollen Sie ihre Zwischenablage wirklich leeren?" bookbag_delete_selected = "Löschen" bookbag_delete = "Markiertes aus Zwischenablage löschen" -bookbag_email_selected = "E-Mail" +bookbag_email_selected = "Links zu ausgewählten Medien per E-Mail versenden" bookbag_email = "Markiertes per E-Mail versenden" bookbag_export_selected = "Export" bookbag_export = "Markiertes exportieren" @@ -715,7 +715,7 @@ errorcode_opac_error = "Es ist ein Fehler im Lokalsystem aufgetreten" errorcode_login_error = "Die Anmeldung des Benutzers am Lokalsystem ist gescheitert" errorcode_empty_member_code = "Es wurde keine Benutzernummer übergeben" errorcode_empty_password = "Es wurde kein Passwort übergeben" -errorcode_member_not_found = "Die Benutzernummer exisitiert nicht" +errorcode_member_not_found = "Die Benutzernummer existiert nicht" errorcode_password_validation_error = "Das übergebene Password ist nicht korrekt" errorcode_old_password_validation_error = "Die Kombination aus Benutzernummer und Kennwort ist nicht gültig. Bitte überprüfen Sie Ihre Eingabe." errorcode_empty_req_param_error = "Um das Formular erfolgreich zu senden, müssen alle erforderlichen Felder ausgefüllt sein" @@ -1989,7 +1989,7 @@ ReliefPrint = Druckgraphik ; Accessibility Modal_description = "Sie befinden sich in einem Dialogfenster, das über dem Hauptinhalt der Seiten liegt. Drücken Sie die Escape-Taste oder die Schaltfläche 'Dialogfenster schließen', um das Fenster zu schließen und auf der Hauptseite weiterzuarbeiten." -Skip_navigation_links = "Sprunglinks zum Inhalt" +Skip_navigation_links = "Sprunglinks zur Suche und zum Inhalt" Skip to search = "Zum Suchbereich" Skip to content = "Zum Inhalt" Skip to facet = "Zu ihrem ausgewählten Suchfilter "%%filter_name%%" springen" @@ -2056,15 +2056,6 @@ form-button-submit = "Ausgefülltes Formular abschicken" ; #17601 offcanvas-toggler-search-tips = "Suchtipps einblenden" -; #17993 -; only for German translation -Email = "Mailen" -Print = "Drucken" -bookbag_email_selected = "Links zu ausgewählten Medien per E-Mail versenden" - -; #18441 -Skip_navigation_links = "Sprunglinks zur Suche und zum Inhalt" - ; #18019 & #18754 select_item = "Titel wählen" select_item_search_result = "Titel zum Mailen, Exportieren, Drucken, Speichern oder Merken auswählen" diff --git a/local/languages/en.ini b/local/languages/en.ini index 01d63c1841d80d2e596bef345c59e56b4e175509..41cfa27c921739f7f16f908576d7cda3348d5101 100644 --- a/local/languages/en.ini +++ b/local/languages/en.ini @@ -151,7 +151,6 @@ Article, E-Article = Article, E-Article Audio = Audio Book, E-Book = Book, E-Book Card = Card -DBIS = DBIS Journal, E-Journal = Journal, E-Journal Map = Map Notated Music = Notated Music @@ -2138,7 +2137,6 @@ form-button-submit = "Submit the completed form" offcanvas-toggler-search-tips = "Show search help" ; #18441 -Skip_navigation_links = "Skip navigation links" ; #18019 & #18754 select_item = "Select item" diff --git a/module/fid/config/module.config.php b/module/fid/config/module.config.php index 0df34ef2b76ed282ea867cdb2151495bb59c5feb..74b728b9c8cd91cf378cf6c3b389dc022150af7a 100644 --- a/module/fid/config/module.config.php +++ b/module/fid/config/module.config.php @@ -30,6 +30,7 @@ use fid\Filter\PermissionsFilterFactory; use fid\FormModel\PasswordChangeModel; use fid\FormModel\PasswordResetModel; use fid\FormModel\UsernameChangeModel; +use fid\FormModel\UserDeleteModel; use fid\Helper\FormLabel; use fid\Helper\TranslatorDelegator; use fid\Hydrator\OrderHydrator; @@ -75,6 +76,7 @@ $config = [ PasswordResetModel::class => require 'password-reset-form.php', PasswordChangeModel::class => require 'password-change-form.php', UsernameChangeModel::class => require 'username-change-form.php', + UserDeleteModel::class => require 'user-delete-form.php', ], 'filters' => [ 'factories' => [ @@ -340,6 +342,16 @@ $config = [ ], ], ], + 'delete' => [ + 'type' => 'literal', + 'options' => [ + 'route' => '/delete', + 'defaults' => [ + 'controller' => UserController::class, + 'action' => 'delete', + ], + ], + ], ], ], 'admin' => [ diff --git a/module/fid/config/user-delete-form.php b/module/fid/config/user-delete-form.php new file mode 100644 index 0000000000000000000000000000000000000000..c21ba9cd1cac4ac0a0d41a3a80a21568d8db7567 --- /dev/null +++ b/module/fid/config/user-delete-form.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright (C) 2021 Leipzig University Library + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + */ + use Zend\Filter\StringTrim; + use Zend\Form\Element\Password; + use Zend\Form\Element\Submit; + use Zend\Hydrator\ClassMethods; + use Zend\Validator\NotEmpty; + + return [ + 'hydrator' => ClassMethods::class, + 'elements' => [ + 'password' => [ + 'spec' => [ + 'name' => 'passwordConfirmation', + 'type' => Password::class, + 'options' => [ + 'label' => 'label_password', + ], + 'attributes' => [ + 'autocomplete' => 'current-password', + 'autofocus' => true, + 'title' => 'Password', + ], + ], + ], + 'submit' => [ + 'spec' => [ + 'name' => 'submit', + 'type' => Submit::class, + 'attributes' => [ + 'value' => 'label_submit', + ], + ], + ], + ], + 'input_filter' => [ + 'passwordConfirmation' => [ + 'name' => 'passwordConfirmation', + 'required' => true, + 'filters' => [ + StringTrim::class => [ + 'name' => StringTrim::class, + ], + ], + ], + 'submit' => [ + 'name' => 'submit', + 'required' => true, + ], + ], +]; diff --git a/module/fid/src/Controller/UserController.php b/module/fid/src/Controller/UserController.php index 99dc2db56ec1b7e2cd29da700314eeb03c9b7082..096fa3fa6ea61b32d68ff215eda737b90c8e0ed4 100644 --- a/module/fid/src/Controller/UserController.php +++ b/module/fid/src/Controller/UserController.php @@ -22,6 +22,7 @@ namespace fid\Controller; +use fid\FormModel\UserDeleteModel; use fid\FormModel\PasswordChangeModel; use fid\FormModel\PasswordResetModel; use fid\FormModel\UsernameChangeModel; @@ -426,6 +427,86 @@ class UserController extends AbstractBase return $this->redirect()->toRoute('myresearch-home'); } + /** + * @noinspection PhpUnused + * @return Response + */ + public function deleteAction() + { + if (!$this->getUser()) { + return $this->forceLogin(); + } + + /** @var User $user */ + $user = $this->client->requestUserDetails(null, true); + if ($user->getData()['deleted'] ?? false) { + $view = $this->createViewModel(); + $messages['html'] = true; + $messages['msg'] = $this->translate("fid::user_delete_error_account_blocked", [ + '%%fidname%%' => $this->translate("fid::acquisition_fid_name") + ]); + $this->flashMessenger()->addMessage($messages, 'error'); + $view->setTemplate('default/flash-message'); + return $view; + } + + /** @var Request $request */ + $request = $this->getRequest(); + /** @var Form $form */ + $form = $this->serviceLocator->get(UserDeleteModel::class); + $forwarded = $this->params()->fromRoute('forwarded', false); + + if ($submitted = $this->formWasSubmitted()) { + $form->setData($request->getPost()); + if (!$forwarded && $form->isValid()) { + return $this->deleteUser($form); + } + } + + $view = $this->createViewModel(); + $view->setVariables(compact('form')); + $view->setTemplate('fid/user/user-delete'); + + return $view; + } + + protected function deleteUser(Form $form) + { + $messenger = $this->getMessenger(); + /** @var UserDeleteModel $model */ + $model = $form->getHydrator()->hydrate($form->getData(), new UserDeleteModel()); + $error = []; + + try { + /** @var User $user */ + $user = $this->client->requestUserDetails(); + if ($this->client->checkCredentials($user->getUsername(), $model->getPasswordConfirmation())) { + $user->setDeleted(true); + $user->setDeletedAt(date('Y-m-d H:i:s', time())); + $user = $this->client->requestUserUpdate($user); + if (!$user->isDeleted()) { + $error['msg'] = $this->translate('fid::user_delete_error_unknown'); + } + } else { + $error['msg'] = $this->translate('fid::user_delete_error_wrong_password'); + } + } catch (ClientException $exception) { + $error['msg'] = $this->translate('fid::user_delete_error_unknown'); + } + + if(!empty($error)) { + $error['html'] = true; + $messenger->addErrorMessage($error); + return $this->redirect()->toRoute('fid/user/delete'); + } + + $this->client->logoff(); + $this->getAuthManager()->logout(""); + $view = $this->createViewModel(); + $view->setTemplate('myresearch/delete-success'); + return $view; + } + public function policyAction() { $viewModel = $this->createViewModel(); diff --git a/module/fid/src/FormModel/UserDeleteModel.php b/module/fid/src/FormModel/UserDeleteModel.php new file mode 100644 index 0000000000000000000000000000000000000000..8974fd938588674259152e5f9e1b1ad2b6df8261 --- /dev/null +++ b/module/fid/src/FormModel/UserDeleteModel.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright (C) 2020 Leipzig University Library + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + */ + +namespace fid\FormModel; + +class UserDeleteModel +{ + /** + * @var string + */ + protected $id; + + /** + * @var string + */ + protected $passwordConfirmation; + + /** + * @var string + */ + protected $submit; + + /** + * @return string + */ + public function getPasswordConfirmation(): string + { + return $this->passwordConfirmation; + } + + /** + * @param string $password + */ + public function setPasswordConfirmation(string $password): void + { + $this->passwordConfirmation = $password; + } + + /** + * @return string + */ + public function getSubmit(): string + { + return $this->submit; + } + + /** + * @param string $submit + */ + public function setSubmit(string $submit): void + { + $this->submit = $submit; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } +} diff --git a/module/fid/src/Service/Client.php b/module/fid/src/Service/Client.php index 8d54127c89b38ad3be2eeb1e9ebd3956582317eb..531e760e3f96869f00cb708d3f68e14b0c67fdee 100644 --- a/module/fid/src/Service/Client.php +++ b/module/fid/src/Service/Client.php @@ -174,6 +174,27 @@ class Client } } + /** + * @param string $username + * @param string $password + * + * @return bool + */ + public function checkCredentials(string $username, string $password): bool + { + $body = json_encode(compact('username', 'password')); + $request = $this->buildRequest('post', 'logons', $body); + $response = $this->sendRequest($request); + + if ($response->getStatusCode() !== 201) { + return false; + } + + $logon = $this->parseLogon((string)$response->getBody()); + $this->storeLogon($logon); + return true; + } + /** * @throws ClientException */ diff --git a/module/fid/src/Service/DataTransferObject/User.php b/module/fid/src/Service/DataTransferObject/User.php index b2704cf9b31db72768096ea79f52f68098fee08d..7da55a719956b78bf8ff78e35c634d1d18a7c3c1 100644 --- a/module/fid/src/Service/DataTransferObject/User.php +++ b/module/fid/src/Service/DataTransferObject/User.php @@ -395,6 +395,34 @@ class User return $addresses[$addressIndex]; } + /** + * @return bool + */ + public function isDeleted(): bool + { + return ($this->data['deleted'] ?? false) === true; + } + + /** + * @return void + */ + public function setDeleted(bool $delete): void + { + if (empty($this->data)) { + $this->data = []; + } + $this->data['deleted'] = $delete; + } + + /** + * @param string $deletedAt + * @return void + */ + public function setDeletedAt(string $deletedAt): void + { + $this->data["deletedAt"] = $deletedAt; + } + /** * @return boolean */ diff --git a/module/fid/src/VuFind/Auth/Authenticator.php b/module/fid/src/VuFind/Auth/Authenticator.php index 5a2cd6130fe2f4dc329d9f1276fb76691a8e6756..bda67c1efad3cbebbd17eae04d4a2b431bc8134c 100644 --- a/module/fid/src/VuFind/Auth/Authenticator.php +++ b/module/fid/src/VuFind/Auth/Authenticator.php @@ -23,6 +23,7 @@ namespace fid\VuFind\Auth; use fid\Service\Client; use fid\Service\ClientException; +use fid\Service\DataTransferObject\User; use fid\VuFind\Db\Row\User as VuFindUser; use VuFind\Auth\AbstractBase; use VuFind\Db\Row\User as UserRow; @@ -40,6 +41,9 @@ class Authenticator extends AbstractBase protected const AUTH_ERROR_ACCOUNT_BLOCKED = 'fid::auth_error_account_blocked'; + protected const AUTH_ERROR_ACCOUNT_DELETED + = 'fid::auth_error_account_deleted'; + /** * @var Client */ @@ -92,6 +96,13 @@ class Authenticator extends AbstractBase throw new AuthException(self::AUTH_ERROR_ACCOUNT_BLOCKED); } + /** @var User $user */ + $user = $this->client->requestUserDetails(); + if ($user->isDeleted()) { + $this->client->logoff(); + throw new AuthException(self::AUTH_ERROR_ACCOUNT_DELETED); + } + if ($ownerId = $logon->getOwnerId()) { /** @var VuFindUser $userRow */ $userRow = $this->getUserTable()->getByUsername($ownerId); diff --git a/module/finc/src/finc/RecordTab/HierarchyTree.php b/module/finc/src/finc/RecordTab/HierarchyTree.php index cfc6a02c43cc86cde7eb86e3cc1a79e0bcab68a3..315b773894fe50aa0da87b36fdf6c63318eb1ae9 100644 --- a/module/finc/src/finc/RecordTab/HierarchyTree.php +++ b/module/finc/src/finc/RecordTab/HierarchyTree.php @@ -51,17 +51,20 @@ class HierarchyTree extends \VuFind\RecordTab\HierarchyTree else return 'hierarchy_tree'; } - /** - * {@inheritdoc} - * Returns different descriptions according to record type - * @return string - */ -/* public function isActive() + public function isActive() { - return ( - $this->getRecordDriver()->tryMethod('isSingleElementHierarchyRecord') - ? false : parent::isActive() - ); + $trees = $this->getTreeList(); + if (empty($trees)) { + return false; + } + foreach ($trees as $key => $value) { + if ($key !== $this->driver->getUniqueID()) { + return true; + } + } + if ($this->driver->getChildRecordCount() > 0) { + return true; + } + return false; } -*/ } diff --git a/module/finc/src/finc/View/Helper/Root/Record.php b/module/finc/src/finc/View/Helper/Root/Record.php index 63545be5c92d7a5ea7cad1748e9a83bc48de1760..340f8980884318fa5765bd0b95292d4f85259f3e 100644 --- a/module/finc/src/finc/View/Helper/Root/Record.php +++ b/module/finc/src/finc/View/Helper/Root/Record.php @@ -183,74 +183,6 @@ class Record extends \VuFind\View\Helper\Root\Record $this->config->Content->showStyleBasedIcons : false; } - /** - * Get external access links to other ILS defined by config setting. - * - * @return array Associative array. - * @throws Exception Value of source ids has to be numeric. - * @deprecated Deprecated due to View Helper ExternalCatalogueLink->getLinks() - * @see https://projekte.ub.uni-leipzig.de/issues/10543 - */ - public function getExternalAccessLinks() - { - $i = -1; // iterator of extUrls - $extUrls = []; - - // if configuration empty return unprocessed - if (!isset($this->config->ExternalAccess) - || count($this->config->ExternalAccess) == 0 - ) { - return []; - } - // if institutions empty return unprocessed - $institutions = $this->driver->tryMethod('getInstitutions'); - if (!isset($institutions) || count($institutions) == 0) { - return []; - } - foreach ($this->config->ExternalAccess as $recordType => $accessUrl) { - $replaceId = null; - // get identifier of record id type - switch ($recordType) { - case "id": - $replaceId = $this->driver->getUniqueID(); - break; - case "ppn": - $replaceId = $this->driver->tryMethod('getRID'); - break; - default: - $replaceId = null; - } - foreach ($accessUrl as $institution => $urlPattern) { - // source_id filter - if (is_array($urlPattern)) { - foreach ($urlPattern as $source_id => $pattern) { - $urlPattern = $pattern; - $sids = explode(',', $source_id); - if (!array_product(array_map('is_numeric', $sids))) { - throw new Exception( - 'Value of source ids has to be numeric.' - ); - } - $sourceID = $this->driver->tryMethod('getSourceID'); - $replaceId = (isset($sourceID) - && true === in_array($sourceID, $sids)) - ? $replaceId : null; - break; - } - } - - // institution filter - if (true === in_array($institution, $institutions) - && !empty($replaceId) - ) { - $extUrls[++$i]['desc'] = $institution; - $extUrls[$i]['url'] = sprintf($urlPattern, $replaceId); - } - } - } - return $extUrls; - } - /** * Render the link of the specified type. * diff --git a/module/finc/tests/fixtures/externallink/testexternallink1.json b/module/finc/tests/fixtures/externallink/testexternallink1.json index a003aa3234013507e659fe5dd78f4acec55064df..d54c4d9d20cb2076bf46475c9af1f6bc1aab536d 100644 --- a/module/finc/tests/fixtures/externallink/testexternallink1.json +++ b/module/finc/tests/fixtures/externallink/testexternallink1.json @@ -1,5 +1,5 @@ { - "ppn": { + "record_id": { "DE-540": [{ "pattern": "http://194.94.197.6/libero/WebopacOpenURL.cls?ACTION=DISPLAY&LANG=DE&RID=%s" }], diff --git a/module/finc/tests/unit-tests/src/fincTest/View/Helper/Root/ExternalCatalogueLinkTest.php b/module/finc/tests/unit-tests/src/fincTest/View/Helper/Root/ExternalCatalogueLinkTest.php index 5a2559ae84f3c67558be3a6617ed01f400535d02..1d9030923767a914ddd9554a458e9b21deb7f484 100644 --- a/module/finc/tests/unit-tests/src/fincTest/View/Helper/Root/ExternalCatalogueLinkTest.php +++ b/module/finc/tests/unit-tests/src/fincTest/View/Helper/Root/ExternalCatalogueLinkTest.php @@ -57,9 +57,13 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase = $this->getExternalCatalogueLink( [], $this->getFixture('testexternallink1.json', 'externallink') - )->__invoke($this->getMockDriver()); + )->__invoke($this->getMockDriver( + 'VuFind\RecordDriver\SolrDefault', + '0008964455', + '265768233', + '22', + ['DE-14', 'DE-D13'])); - $links = $externalCatalogue->getLinks(); $expectedArray = [ [ "desc" => "DE-D13", @@ -70,7 +74,8 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase "url" => "http://katalogbeta.slub-dresden.de/id/0008964455/" ] ]; - $this->assertEquals(json_encode($expectedArray), json_encode($links)); + $this->assertEquals(json_encode($expectedArray), json_encode($externalCatalogue->getLinks())); + $externalCatalogue = $this->getExternalCatalogueLink( [], @@ -84,14 +89,13 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase ['DE-D13', 'DE-540'] ) ); - $links = $externalCatalogue->getLinks(); $expectedArray = [ [ "desc" => "DE-540", "url" => "http://194.94.197.6/libero/WebopacOpenURL.cls?ACTION=DISPLAY&LANG=DE&RID=265768233" ] ]; - $this->assertEquals(json_encode($expectedArray), json_encode($links)); + $this->assertEquals(json_encode($expectedArray), json_encode($externalCatalogue->getLinks())); // @codingStandardsIgnoreEnd } @@ -108,10 +112,10 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase */ protected function getMockDriver( $class = 'VuFind\RecordDriver\SolrDefault', - $id = '0008964455', - $record_id = '265768233', - $source_id = "0", - $institutions = ["DE-14", "DE-D13"] + $id, + $record_id, + $source_id, + $institutions ) { $driver = $this->getMockBuilder($class) ->setMethods(['getUniqueID', 'getSourceID', 'tryMethod']) @@ -124,14 +128,15 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase ->method('tryMethod') ->withConsecutive( [$this->equalTo('getInstitutions')], - [$this->equalTo('getRID')], - [$this->equalTo('getPpn')], - [$this->equalTo('getSourceID')] + [$this->equalTo('getField'), $this->equalTo(['record_id'])], + [$this->equalTo('getSourceID')], + [$this->equalTo('getField'), $this->equalTo(['id'])] ) ->willReturnOnConsecutiveCalls( $this->returnValue($institutions), $this->returnValue($record_id), - $this->returnValue($source_id) + $this->returnValue($source_id), + $this->returnValue($id) ); return $driver; } diff --git a/themes/fid/languages/fid/de.ini b/themes/fid/languages/fid/de.ini index 161362d76ef583c199adb437b10852609b9e9fcd..0a3fee6dac272d902870c7d7531427e88eedd530 100644 --- a/themes/fid/languages/fid/de.ini +++ b/themes/fid/languages/fid/de.ini @@ -1,6 +1,8 @@ auth_error_bad_credentials = Nutzername oder Passwort falsch. +auth_error_bad_password = Passwort falsch. auth_error_unknown_reason = Anmeldung derzeit nicht möglich. auth_error_account_blocked = Ihr Konto wurde aus Sicherheitsgründen gesperrt. Bitte kontaktieren Sie uns unter info@adlr.link, um eine Entsperrung vorzunehmen. +auth_error_account_deleted = Ihr Konto ist zur Löschung vorgemerkt und Ihre Daten werden beim nächsten Wartungslauf endgültig entfernt. user_init_form_title = "Registrierung" user_create_form_title = "Registrierung abschließen" @@ -105,6 +107,15 @@ username_update_error = "Es ist ein unerwarteter Fehler beim Aktualisieren Ihrer username_update_error_expired = "Ihr Verifikationslink ist bereits abgelaufen. Bitte starten Sie den Vorgang erneut." username_update_success = "Ihre E-Mail-Addresse wurde erfolgreich aktualisiert." +user_delete_link = "Konto löschen" +user_delete_info = "Sie können hier Ihr Konto zur Löschung anmelden. Wenn Sie fortfahren, wird der Zugang zu Ihrem Konto sofort gesperrt und das Konto beim nächsten Wartungslauf entfernt. +user_delete_hint = "Achtung! Sämtliche Daten in Ihrem Konto werden endgültig gelöscht und können nach der Löschung nicht wiedergestellt werden.<br /><br />Bitte geben Sie zur Bestätigung Ihr Passwort ein:" +user_delete_error_account_blocked = "Ihr Konto ist bereits gesperrt. Ihre Daten werden beim nächsten Wartungslauf endgültig entfernt. Vielen Dank für die Nutzung von %%fidname%%.<br /><br />Falls Sie zu einem späteren Zeitpunkt %%fidname%% wieder nutzen möchten, können Sie sich nach erfolgter Löschung jederzeit für ein neues Konto mit Ihrer E-Mail-Adresse registrieren." +user_delete_error_unknown = "Ein unerwarteter Fehler ist aufgetreten. Das Konto konnte nicht gesperrt werden." +user_delete_error_wrong_password = "Das angegebene Passwort ist falsch." +user_delete_success = "Ihr Konto ist nun gesperrt und Ihre Daten werden beim nächsten Wartungslauf endgültig entfernt. Vielen Dank für die Nutzung von %%fidname%%.<br /><br />Falls Sie zu einem späteren Zeitpunkt %%fidname%% wieder nutzen möchten, können Sie sich nach erfolgter Löschung jederzeit für ein neues Konto mit Ihrer E-Mail-Adresse registrieren." +user_delete_success_title = "Konto gesperrt und zur Löschung vorgemerkt." + Edit Account = "Profildaten ändern" @@ -166,7 +177,7 @@ acquisition_error_page_selection = "Der von Ihnen angegebene Seitenbereich über acquisition_subito_article_confirmation = "Möchten Sie den Artikel bestellen?" acquisition_subito_partial_copy_confirmation = "Möchten Sie die Teilkopie bestellen?" acquisition_pda_confirmation = "Möchten Sie das Buch bestellen?" -acquisition_pda_ordered = "Dieser Titel wurde bereits auf Nutzerwunsch durch adlr.link erworben und wird in Kürze verfügbar sein." +acquisition_pda_ordered = "Dieser Titel wurde bereits auf Nutzerwunsch durch %%fidname%% erworben und wird in Kürze verfügbar sein." acquisition_success = "Ihre Bestellung wurde entgegengenommen und wird nun von uns bearbeitet." acquisition_permission_denied = "Ihr Konto ist für Bestellungen zurzeit gesperrt." diff --git a/themes/fid/languages/fid/en.ini b/themes/fid/languages/fid/en.ini index 102479fd08c99cc5d3b9136992d44b17aeecbcdb..01cd367904a8b26b3886d97ca5cca59e5ed3696b 100644 --- a/themes/fid/languages/fid/en.ini +++ b/themes/fid/languages/fid/en.ini @@ -1,6 +1,8 @@ auth_error_bad_credentials = Invalid username or password. +auth_error_bad_password = Invalid password. auth_error_unknown_reason = Login currently impossible. auth_error_account_blocked = Your account has been disabled due to security reasons. Please contact us at info@adlr.link for more details. +auth_error_account_deleted = Your account is marked for deletion and your data will be permanently removed during the next maintenance run. user_init_form_title = "Registration" user_create_form_title = "Complete registration" @@ -104,6 +106,15 @@ username_update_error = "An unexpected error has occurred when updating your ema username_update_error_expired = "Your configmration link has already expired." username_update_success = "Your email address has successfully been updated." +user_delete_link = "Delete Account" +user_delete_info = "You can mark your account for deletion here. If you proceed, access to your account will be immediately blocked and the account will be removed during the next maintenance run." +user_delete_hint = " Attention. All data in your account will be permanently deleted and cannot be restored after deletion.<br /><br />Please enter your password to confirm:" +user_delete_error_account_blocked = "Your account is already disabled. Your data will be permanently removed during the next maintenance run. Thank you for using %%fidname%%.<br /><br />If you want to use %%fidname%% again at a later date, you can register for a new account with your email address at any time after it has been deleted." +user_delete_error_unknown = "An unexpected error occurred. Your account could not be disabled." +user_delete_error_wrong_password = "The password you typed is incorrect." +user_delete_success = "Your account is now disabled and your data will be permanently removed during the next maintenance run. Thank you for using %%fidname%%.<br /><br />If you would like to use %%fidname%% again at a later date, you can register for a new account with your email address at any time after deletion." +user_delete_success_title = "Account disabled and marked for deletion." + Edit Account = "Edit Account" requested_groups = "Membership requested" @@ -162,7 +173,7 @@ acquisition_error_page_selection = "The page range you specify exceeds the 10 pe acquisition_subito_article_confirmation = "Do you like to order the article?" acquisition_subito_partial_copy_confirmation = "Do you like to order the partial copy?" acquisition_pda_confirmation = "Do you like to order the book?" -acquisition_pda_ordered = "This item has been acquired by adlr.link by request of a patron and will be available in a short time." +acquisition_pda_ordered = "This item has been acquired by %%fidname%% by request of a patron and will be available in a short time." acquisition_success = "Your order is received and will be processed now." acquisition_permission_denied = "Your account is currently blocked for orders." diff --git a/themes/fid/templates/fid/user/user-delete.phtml b/themes/fid/templates/fid/user/user-delete.phtml new file mode 100644 index 0000000000000000000000000000000000000000..cc7e27eecbbbf6d49c12dc4158b0fab613616d98 --- /dev/null +++ b/themes/fid/templates/fid/user/user-delete.phtml @@ -0,0 +1,86 @@ +<?php + /** + * Copyright (C) 2021 Leipzig University Library + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + */ + use Zend\Form\Element; + use Zend\Form\Form; + use Zend\Form\View\Helper\FormElementErrors; + use Zend\Form\View\Helper\FormLabel; + use Zend\Form\View\Helper\FormSubmit; + use Zend\I18n\Translator\TranslatorInterface; + + /** @var FormLabel $formLabel */ + $formLabel = $this->formLabel(); + /**@var FormSubmit $formSubmit */ + $formSubmit = $this->formSubmit(); + /** @var FormElementErrors $formElementErrors */ + $formElementErrors = $this->formElementErrors(); + + $formLabel->setTranslatorTextDomain('fid'); + $formSubmit->setTranslatorTextDomain('fid'); + $formElementErrors->setTranslatorTextDomain('fid'); + /** @var TranslatorInterface $translator */ + $translator = $this->getHelperPluginManager()->get('translate') + ->getTranslator(); + $formLabel->setTranslator($translator); + $formElementErrors->setTranslator($translator); + + /** @var Form $form */ + $form = $this->form; + $form->setAttribute('method', 'post'); + $form->setAttribute('action', $this->url('fid/user/delete')); + $form->prepare(); + + $this->headTitle($this->translate("fid::delete_account_title")); +?> + +<h1><?= $this->translate("fid::user_delete_link") ?></h1> +<?= $this->flashmessages() ?> +<?= $this->translate("fid::user_delete_info") ?> +<br /><br /> +<?= $this->translate("fid::user_delete_hint") ?> +<?= $this->form()->openTag($form) ?> +<br/> +<?php /* username */ ?> +<?php + /** @var Element\Password $elemPassword */ + $elemPassword = $form->get('passwordConfirmation'); + $elemPassword->setLabelAttributes(['class' => 'control-label']); + $elemPassword->setAttributes(['class' => 'form-control']); +?> +<div> + <?= $this->formLabel($elemPassword) ?> + <?= $this->formElement($elemPassword) ?> + <?= $this->formElementErrors($elemPassword) ?> +</div> + +<?php /* submit button */ ?> +<?php + /** @var Element\Submit $elemSubmit */ + $elemSubmit = $form->get('submit'); + $elemSubmit->setAttributes(['class' => 'btn btn-primary']); +?> +<div class="form-group"> + <a class="back-to-login btn btn-link" href="<?=$this->url('myresearch-userlogin') ?>"> + <i class="fa fa-chevron-left" aria-hidden="true"></i> + <span class="decorate"><?=$this->transEsc('Back')?></span> + </a> + <?= $this->formElement($elemSubmit) ?> +</div> +<?= $this->form()->closeTag($form) ?> diff --git a/themes/fid/templates/myresearch/delete-success.phtml b/themes/fid/templates/myresearch/delete-success.phtml new file mode 100644 index 0000000000000000000000000000000000000000..de775c02dda8082ccbe6ae2dd0e991a5ffcd599b --- /dev/null +++ b/themes/fid/templates/myresearch/delete-success.phtml @@ -0,0 +1,16 @@ +<?php + $title = $this->translate('fid::user_delete_success_title'); + $this->headTitle($title); +?> +<br /> +<h1><?= $title ?></h1> +<br /> +<p><?= $this->translate("fid::user_delete_success", ['%%fidname%%' => $this->translate("fid::acquisition_fid_name")]); ?></p> +<br /> +<?php /* leave profile page after closing of modal; go to home page instead of login page */ ?> +<script> + //VuFind.lightbox.refreshOnClose = true + document.addEventListener('VuFind.lightbox.closed', function lightboxClosed(e) { + document.location.href = "<?=$this->url('search-home')?>"; + }, false); +</script> diff --git a/themes/finc/js/covers.js b/themes/finc/js/covers.js index f54f93b677c941e87ad4fc3a0406e43f54d20aba..3eb309ef70b9765951f99e163e3185e1084aca2d 100644 --- a/themes/finc/js/covers.js +++ b/themes/finc/js/covers.js @@ -50,7 +50,8 @@ function loadCoverByElement(data, element) { method: 'GET', data: data, element: element, - success: coverCallback + success: coverCallback, + error: spinner.hide() }); } diff --git a/themes/finc/js/lightbox.js b/themes/finc/js/lightbox.js index 108712feda24df15a4e3a6fe1a104992589d21da..4d183e226b88d770ccea6bb32f1779abf431f7cd 100644 --- a/themes/finc/js/lightbox.js +++ b/themes/finc/js/lightbox.js @@ -1,4 +1,6 @@ -/*global grecaptcha, recaptchaOnLoad, resetCaptcha, VuFind, TEMPORARY BARF CK */ +/*global recaptchaOnLoad, resetCaptcha, VuFind, userIsLoggedIn:true */ +// TEMPORARY BARF CK +/*jshint strict: false */ VuFind.register('lightbox', function Lightbox() { // State var _originalUrl = false; @@ -15,7 +17,7 @@ VuFind.register('lightbox', function Lightbox() { function _html(content) { _modalBody.html(content); // Set or update title if we have one - var $h2 = _modalBody.find("h2:first-of-type"); + var $h2 = _modalBody.find('h2:first-of-type'); if (_lightboxTitle && $h2) { $h2.text(_lightboxTitle); } @@ -42,8 +44,8 @@ VuFind.register('lightbox', function Lightbox() { // Public: Present an alert function showAlert(message, _type) { var type = _type || 'info'; - _html('<div class="flash-message alert alert-' + type + '" role="alert">' + message + '</div>' - + '<button class="btn btn-default" data-dismiss="modal">' + VuFind.translate('close') + '</button>'); + _html('<div class="flash-message alert alert-' + type + '" role="alert">' + message + '</div>' + + '<button class="btn btn-default" data-dismiss="modal">' + VuFind.translate('close') + '</button>'); _modal.modal('show'); } function flashMessage(message, _type) { @@ -67,7 +69,7 @@ VuFind.register('lightbox', function Lightbox() { var _constrainLink; var _formSubmit; function render(content) { - if (typeof content !== "string") { + if (typeof content !== 'string') { return; } // Isolate successes @@ -128,9 +130,7 @@ VuFind.register('lightbox', function Lightbox() { // Add lightbox GET parameter if (!obj.url.match(/layout=lightbox/)) { var parts = obj.url.split('#'); - obj.url = parts[0].indexOf('?') < 0 - ? parts[0] + '?' - : parts[0] + '&'; + obj.url = parts[0].indexOf('?') < 0 ? parts[0] + '?' : parts[0] + '&'; obj.url += 'layout=lightbox'; if (_currentUrl) { obj.url += '&lbreferer=' + encodeURIComponent(_currentUrl); @@ -168,8 +168,7 @@ VuFind.register('lightbox', function Lightbox() { // - not a failed login if ( obj.method && ( - obj.url.match(/catalogLogin/) - || obj.url.match(/MyResearch\/(?!Bulk|Delete|Recover)/) + obj.url.match(/catalogLogin/) || obj.url.match(/MyResearch\/(?!Bulk|Delete|Recover)/) ) && flashMessages.length === 0 ) { @@ -182,7 +181,8 @@ VuFind.register('lightbox', function Lightbox() { VuFind.refreshPage(); } return false; - } else { + /* FINC-specific: avoid page reload after login if param is given - show account links by javascript */ + } else if (new URL(_originalUrl).searchParams.get('refreshOnClose') !== 'false' || !displayLogin()) { VuFind.lightbox.refreshOnClose = true; } _currentUrl = _originalUrl; // Now that we're logged in, where were we? @@ -202,6 +202,22 @@ VuFind.register('lightbox', function Lightbox() { ajax({ url: _currentUrl || _originalUrl }); } + /** + * Finc specific: Login without Page Reload + */ + function displayLogin() { + try { + if ($('#loginOptions').length && $('.logoutOptions').length) { + userIsLoggedIn = true; + $('#loginOptions').hide(); + $('.logoutOptions').removeClass('hidden'); + return true; + } + } catch (e) { /* Empty */ } + + return false; + } + /** * Evaluate a callback */ @@ -243,22 +259,23 @@ VuFind.register('lightbox', function Lightbox() { VuFind.lightbox.reset(); } var $link = $(this); - if (typeof $link.data("lightboxIgnore") != "undefined" - || typeof $link.attr("href") === "undefined" - || $link.attr("href").charAt(0) === "#" - || $link.attr("href").match(/^[a-zA-Z]+:[^/]/) // ignore resource identifiers (mailto:, tel:, etc.) - || (typeof $link.attr("target") !== "undefined" - && ( - $link.attr("target").toLowerCase() === "_new" - || $link.attr("target").toLowerCase() === "new" - )) + if (typeof $link.data('lightboxIgnore') !== 'undefined' || + typeof $link.attr('href') === 'undefined' || + $link.attr('href').charAt(0) === '#' || + $link.attr('href').match(/^[a-zA-Z]+:[^/]/) || // ignore resource identifiers (mailto:, tel:, etc.) + (typeof $link.attr('target') !== 'undefined' && + ( + $link.attr('target').toLowerCase() === '_new' || + $link.attr('target').toLowerCase() === 'new' + ) + ) ) { return true; } if (this.href.length > 1) { event.preventDefault(); var obj = {url: $(this).data('lightboxHref') || this.href}; - if ("string" === typeof $(this).data('lightboxPost')) { + if ('string' === typeof $(this).data('lightboxPost')) { obj.type = 'POST'; obj.data = $(this).data('lightboxPost'); } @@ -490,8 +507,9 @@ VuFind.register('lightbox', function Lightbox() { VuFind.lightbox.reset(); _emit('VuFind.lightbox.closed'); // set focus back on launching element - if (_origin != "undefined") + if (_origin !== null && _origin !== 'undefined') { _origin.focus(); + } }); _modal.on("shown.bs.modal", function lightboxShown() { bindFocus(); diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/core.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/core.phtml index e7b39706ee3f3f2fdd8e46c481d40ecc9c8a5d25..2836a86ebbc501adcc00269c6bb04edd71b2765a 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/core.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/core.phtml @@ -46,7 +46,7 @@ */ ?> <?php /* finc: add schema tags for title #13850 - VE */ ?> - <h1 property="name" lang=""><?= $this->escapeHtml(preg_replace('/(\s[\/\.:]\s*)*$/', '', $this->truncate($this->driver->getShortTitle() . ' ' . $this->driver->getSubtitle() . ' ' . $this->driver->getTitleSection(), 100))) ?></h1> + <h1 property="name" lang=""><?=$this->record($this->driver)->getTitleHtml()?></h1> <?php /* #18307 remove summary from core */ ?> diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml index 878760060d4bcac2728a7ac5cf914eb170648406..2d1425fa86e9d4d2a6bb2662c27d0722ce36cc4d 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml @@ -209,7 +209,7 @@ $i = 0; <?php if ($this->userlist()->getMode() !== 'disabled'): ?> <?php if ($this->permission()->allowDisplay('feature.Favorites')): ?> <?php /* Add to favorites; finc: keep Icon inside link - CK */ ?> - <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" data-lightbox class="save-record result-link-label" data-id="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>" aria-label="<?=$this->transEsc('Add to favorites')?>"> + <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>?refreshOnClose=false" data-lightbox class="save-record result-link-label" data-id="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>" aria-label="<?=$this->transEsc('Add to favorites')?>"> <i class="fa fa-fw fa-star" aria-hidden="true"></i> <span><?=$this->transEsc('Add to favorites')?></span> </a><br/> <?php elseif ($block = $this->permission()->getAlternateContent('feature.Favorites')): ?> diff --git a/themes/finc/templates/RecordDriver/SolrAI/core.phtml b/themes/finc/templates/RecordDriver/SolrAI/core.phtml index 504fe19d7dc63a99975874b717c6c1db529101af..e6f20eacbfafa42e4e86a6979fed34b52fe56dcb 100644 --- a/themes/finc/templates/RecordDriver/SolrAI/core.phtml +++ b/themes/finc/templates/RecordDriver/SolrAI/core.phtml @@ -46,7 +46,7 @@ */ ?> <?php /* finc: add schema tags for title #13850 - VE */ ?> - <h1 property="name" lang=""><?= $this->escapeHtml(preg_replace('/(\s[\/\.:]\s*)*$/', '', $this->truncate($this->driver->getShortTitle() . ' ' . $this->driver->getSubtitle() . ' ' . $this->driver->getTitleSection(), 100))) ?></h1> + <h1 property="name" lang=""><?=$this->record($this->driver)->getTitleHtml()?></h1> <?php /* #18307 remove summary from core */ ?> diff --git a/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml b/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml index 0b8dc222334495369c4a119078df6840174a8a3f..e21b80019c88987fa4b300e1455720c988b77584 100644 --- a/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml +++ b/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml @@ -219,7 +219,7 @@ if ($cover): <?php if ($this->userlist()->getMode() !== 'disabled'): ?> <?php /* if ($this->permission()->allowDisplay('feature.Favorites')): */ ?> <?php /* Add to favorites; finc: keep Icon inside link - CK */ ?> - <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" data-lightbox class="save-record result-link-label" data-id="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>"> + <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>?refreshOnClose=false" data-lightbox class="save-record result-link-label" data-id="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>"> <i class="result-link-icon fa fa-fw fa-star" aria-hidden="true"></i> <?=$this->transEsc('Add to favorites')?> </a><br/> <?php elseif ($block = $this->permission()->getAlternateContent('feature.Favorites')): ?> diff --git a/themes/finc/templates/RecordDriver/SolrLido/core.phtml b/themes/finc/templates/RecordDriver/SolrLido/core.phtml index 5436e6000a8e689cb50c49edddc31049421d87b6..9a8cdb17928ba940f656a029fbdddbe1faf5c779 100644 --- a/themes/finc/templates/RecordDriver/SolrLido/core.phtml +++ b/themes/finc/templates/RecordDriver/SolrLido/core.phtml @@ -63,7 +63,7 @@ <?php /* finc: We want to get rid of trailing special chars in the title and limit its length to 100 chars; in finc: keep schema name tag here!! #13861 CK */ ?> - <h1 property="name" lang=""><?=$this->escapeHtml(preg_replace('/(\s[\/\.:]\s*)*$/', '', $this->truncate($this->driver->getShortTitle() . ' ' . $this->driver->getSubtitle() . ' ' . $this->driver->getTitleSection(), 100)))?></h1> + <h1 property="name" lang=""><?=$this->record($this->driver)->getTitleHtml()?></h1> <?php $summary = $this->driver->getSummary(); $summary = isset($summary[0]) ? $this->escapeHtml($summary[0]) : false; ?> diff --git a/themes/finc/templates/RecordDriver/SolrMarc/core.phtml b/themes/finc/templates/RecordDriver/SolrMarc/core.phtml index 89f4018e26abf6c4bccd8961fed1c7a92762290e..37fd560fc0623732c1132bc1770acf6d5f7118d9 100644 --- a/themes/finc/templates/RecordDriver/SolrMarc/core.phtml +++ b/themes/finc/templates/RecordDriver/SolrMarc/core.phtml @@ -46,7 +46,7 @@ */ ?> <?php /* finc: add schema tags for title #13850 - VE */ ?> - <h1 property="name" lang=""><?= $this->escapeHtml(preg_replace('/(\s[\/\.:]\s*)*$/', '', $this->truncate($this->driver->getShortTitle() . ' ' . $this->driver->getSubtitle() . ' ' . $this->driver->getTitleSection(), 100))) ?></h1> + <h1 property="name" lang=""><?=$this->record($this->driver)->getTitleHtml()?></h1> <?php /* #18307 remove summary from core */ ?>