Skip to content
Snippets Groups Projects
Commit 58b90591 authored by André Lahmann's avatar André Lahmann Committed by Robert Lange
Browse files

refs #22489 [finc] included code from VuFind 6 class to HoldTrait

* minor fixes in comments and formatting of ILS Connection, Holds and EnhancedRenderArray
parent 18da59f1
Branches
Tags
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* Holds trait (for subclasses of AbstractRecord) * Holds trait (for subclasses of AbstractRecord)
* *
* PHP version 5 * PHP version 7
* *
* Copyright (C) Villanova University 2010. * Copyright (C) Villanova University 2010.
* *
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category VuFind * @category VuFind
* @package Controller * @package Controller
...@@ -38,17 +38,6 @@ namespace finc\Controller; ...@@ -38,17 +38,6 @@ namespace finc\Controller;
*/ */
trait HoldsTrait trait HoldsTrait
{ {
/**
* Action for dealing with blocked holds.
*
* @return mixed
*/
public function blockedholdAction()
{
$this->flashMessenger()->addMessage('hold_error_blocked', 'error');
return $this->redirectToRecord('#top');
}
/** /**
* Action for dealing with holds. * Action for dealing with holds.
* *
...@@ -84,23 +73,31 @@ trait HoldsTrait ...@@ -84,23 +73,31 @@ trait HoldsTrait
} }
// Block invalid requests: // Block invalid requests:
if (!$catalog->checkRequestIsValid( $validRequest = $catalog->checkRequestIsValid(
$driver->getUniqueID(), $gatheredDetails, $patron $driver->getUniqueID(), $gatheredDetails, $patron
)) { );
return $this->blockedholdAction(); if ((is_array($validRequest) && !$validRequest['valid']) || !$validRequest) {
$this->flashMessenger()->addErrorMessage(
is_array($validRequest)
? $validRequest['status'] : 'hold_error_blocked'
);
return $this->redirectToRecord('#top');
} }
// Send various values to the view so we can build the form: // Send various values to the view so we can build the form:
$requestGroups = $catalog->checkCapability( $requestGroups = $catalog->checkCapability(
'getRequestGroups', [$driver->getUniqueID(), $patron] 'getRequestGroups', [$driver->getUniqueID(), $patron, $gatheredDetails]
) ? $catalog->getRequestGroups($driver->getUniqueID(), $patron) : []; ) ? $catalog->getRequestGroups(
$driver->getUniqueID(), $patron, $gatheredDetails
) : [];
$extraHoldFields = isset($checkHolds['extraHoldFields']) $extraHoldFields = isset($checkHolds['extraHoldFields'])
? explode(":", $checkHolds['extraHoldFields']) : []; ? explode(":", $checkHolds['extraHoldFields']) : [];
$requestGroupNeeded = in_array('requestGroup', $extraHoldFields) $requestGroupNeeded = in_array('requestGroup', $extraHoldFields)
&& !empty($requestGroups) && !empty($requestGroups)
&& (empty($gatheredDetails['level']) && (empty($gatheredDetails['level'])
|| $gatheredDetails['level'] != 'copy'); || ($gatheredDetails['level'] != 'copy'
|| count($requestGroups) > 1));
$pickupDetails = $gatheredDetails; $pickupDetails = $gatheredDetails;
if (!$requestGroupNeeded && !empty($requestGroups) if (!$requestGroupNeeded && !empty($requestGroups)
...@@ -113,18 +110,20 @@ trait HoldsTrait ...@@ -113,18 +110,20 @@ trait HoldsTrait
$pickup = $catalog->getPickUpLocations($patron, $pickupDetails); $pickup = $catalog->getPickUpLocations($patron, $pickupDetails);
// Process form submissions if necessary: // Process form submissions if necessary:
if (!is_null($this->params()->fromPost('placeHold'))) { if (null !== $this->params()->fromPost('placeHold')) {
// If the form contained a pickup location or request group, make sure // If the form contained a pickup location or request group, make sure
// they are valid: // they are valid:
$valid = $this->holds()->validateRequestGroupInput( $validGroup = $this->holds()->validateRequestGroupInput(
$gatheredDetails, $extraHoldFields, $requestGroups $gatheredDetails, $extraHoldFields, $requestGroups
); );
if (!$valid) { $validPickup = $validGroup && $this->holds()->validatePickUpInput(
$gatheredDetails['pickUpLocation'] ?? null,
$extraHoldFields, $pickup
);
if (!$validGroup) {
$this->flashMessenger() $this->flashMessenger()
->addMessage('hold_invalid_request_group', 'error'); ->addMessage('hold_invalid_request_group', 'error');
} elseif (!$this->holds()->validatePickUpInput( } elseif (!$validPickup) {
$gatheredDetails['pickUpLocation'], $extraHoldFields, $pickup
)) {
$this->flashMessenger()->addMessage('hold_invalid_pickup', 'error'); $this->flashMessenger()->addMessage('hold_invalid_pickup', 'error');
} else { } else {
// If we made it this far, we're ready to place the hold; // If we made it this far, we're ready to place the hold;
...@@ -146,7 +145,7 @@ trait HoldsTrait ...@@ -146,7 +145,7 @@ trait HoldsTrait
'%%url%%' => $this->url()->fromRoute('myresearch-holds') '%%url%%' => $this->url()->fromRoute('myresearch-holds')
], ],
]; ];
$this->flashMessenger()->addMessage(isset($results['sysMessage']) ? $results['sysMessage'] : $msg, 'success'); $this->flashMessenger()->addMessage($results['sysMessage'] ?? $msg, 'success');
return $this->redirectToRecord('#top'); return $this->redirectToRecord('#top');
} else { } else {
// Failure: use flash messenger to display messages, stay on // Failure: use flash messenger to display messages, stay on
...@@ -167,7 +166,7 @@ trait HoldsTrait ...@@ -167,7 +166,7 @@ trait HoldsTrait
$defaultRequired = $this->holds()->getDefaultRequiredDate( $defaultRequired = $this->holds()->getDefaultRequiredDate(
$checkHolds, $catalog, $patron, $gatheredDetails $checkHolds, $catalog, $patron, $gatheredDetails
); );
$defaultRequired = $this->serviceLocator->get('VuFind\DateConverter') $defaultRequired = $this->serviceLocator->get(\VuFind\Date\Converter::class)
->convertToDisplayDate("U", $defaultRequired); ->convertToDisplayDate("U", $defaultRequired);
try { try {
$defaultPickup $defaultPickup
...@@ -183,19 +182,21 @@ trait HoldsTrait ...@@ -183,19 +182,21 @@ trait HoldsTrait
$defaultRequestGroup = false; $defaultRequestGroup = false;
} }
$config = $this->getConfig();
$allowHomeLibrary = $config->Account->set_home_library ?? true;
$view = $this->createViewModel( $view = $this->createViewModel(
[ [
'gatheredDetails' => $gatheredDetails, 'gatheredDetails' => $gatheredDetails,
'pickup' => $pickup, 'pickup' => $pickup,
'defaultPickup' => $defaultPickup, 'defaultPickup' => $defaultPickup,
'homeLibrary' => $this->getUser()->home_library, 'homeLibrary' => $allowHomeLibrary
? $this->getUser()->home_library : '',
'extraHoldFields' => $extraHoldFields, 'extraHoldFields' => $extraHoldFields,
'defaultRequiredDate' => $defaultRequired, 'defaultRequiredDate' => $defaultRequired,
'requestGroups' => $requestGroups, 'requestGroups' => $requestGroups,
'defaultRequestGroup' => $defaultRequestGroup, 'defaultRequestGroup' => $defaultRequestGroup,
'requestGroupNeeded' => $requestGroupNeeded, 'requestGroupNeeded' => $requestGroupNeeded,
'helpText' => isset($checkHolds['helpText']) 'helpText' => $checkHolds['helpText'] ?? null
? $checkHolds['helpText'] : null
] ]
); );
$view->setTemplate('record/hold'); $view->setTemplate('record/hold');
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
*/ */
namespace finc\ILS; namespace finc\ILS;
use VuFind\Exception\ILS as ILSException;
use VuFind\ILS\Driver\DriverInterface;
use VuFind\I18n\Translator\TranslatorAwareInterface; use VuFind\I18n\Translator\TranslatorAwareInterface;
/** /**
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki * @link https://vufind.org/wiki/development Wiki
*/ */
namespace finc\ILS\Logic; namespace finc\ILS\Logic;
use VuFind\Exception\ILS as ILSException; use VuFind\Exception\ILS as ILSException;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* @link https://vufind.org/wiki/development Wiki * @link https://vufind.org/wiki/development Wiki
*/ */
namespace finc\View\Helper\Root; namespace finc\View\Helper\Root;
use Zend\View\Helper\AbstractHelper; use Zend\View\Helper\AbstractHelper;
/** /**
......
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