Skip to content
Snippets Groups Projects
Commit 4fce746d authored by Robert Lange's avatar Robert Lange
Browse files

Merge branch 'instance/fid' into instance/fid_adlr

parents 9e9d047b 6babbbb8
No related merge requests found
Showing with 145 additions and 1 deletion
...@@ -202,6 +202,9 @@ order_list = "Liste aller Bestellungen" ...@@ -202,6 +202,9 @@ order_list = "Liste aller Bestellungen"
edit_order_error = "Bestellung kann nicht bearbeitet werden" edit_order_error = "Bestellung kann nicht bearbeitet werden"
order_update_success = "Bestellung aktualisiert" order_update_success = "Bestellung aktualisiert"
order_update_error = "Fehler beim Aktualisieren der Bestellung" order_update_error = "Fehler beim Aktualisieren der Bestellung"
order_delete_success = "Bestellung gelöscht"
order_delete_error = "Fehler bei Löschung der Bestellung"
order_delete_modal = "Bitte Bestätigen Sie das Sie diese Bestellung wirklich löschen wollen."
order_type = "Typ" order_type = "Typ"
label_deleted = Zur Löschung vorgemerkt label_deleted = Zur Löschung vorgemerkt
......
...@@ -198,6 +198,9 @@ order_list = "List of all orders" ...@@ -198,6 +198,9 @@ order_list = "List of all orders"
edit_order_error = "Order cannot be processed" edit_order_error = "Order cannot be processed"
order_update_success = "Order updated" order_update_success = "Order updated"
order_update_error = "Error on updating order" order_update_error = "Error on updating order"
order_delete_success = "Order deleted"
order_delete_error = "Error on deleting order"
order_delete_modal = "Please confirm that you really want to delete this order."
order_type = "Type" order_type = "Type"
label_deleted = Flagged for deletion label_deleted = Flagged for deletion
......
...@@ -738,4 +738,14 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface ...@@ -738,4 +738,14 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface
$user->last_login = date('Y-m-d H:i:s'); $user->last_login = date('Y-m-d H:i:s');
$user->save(); $user->save();
} }
/**
* Is the user allowed to log directly into the ILS?
*
* @return bool
*/
public function allowsUserIlsLogin(): bool
{
return $this->config->Catalog->allowUserLogin ?? true;
}
} }
...@@ -364,6 +364,12 @@ class AbstractBase extends AbstractActionController ...@@ -364,6 +364,12 @@ class AbstractBase extends AbstractActionController
if (($username = $this->params()->fromPost('cat_username', false)) if (($username = $this->params()->fromPost('cat_username', false))
&& ($password = $this->params()->fromPost('cat_password', false)) && ($password = $this->params()->fromPost('cat_password', false))
) { ) {
// If somebody is POSTing credentials but that logic is disabled, we
// should throw an exception!
if (!$account->allowsUserIlsLogin()) {
$account->logout("login");
throw new \Exception('Unexpected ILS credential submission.');
}
// Check for multiple ILS target selection // Check for multiple ILS target selection
$target = $this->params()->fromPost('target', false); $target = $this->params()->fromPost('target', false);
if ($target) { if ($target) {
......
...@@ -432,6 +432,17 @@ ...@@ -432,6 +432,17 @@
], ],
], ],
], ],
'deleteOrder' => [
'type' => 'Zend\Router\Http\Segment',
'options' => [
'route' => '/deleteOrder/[:orderid]',
'defaults' => [
'controller' => OrderController::class,
'action' => 'deleteOrder',
'orderid' => null
],
],
],
], ],
], ],
], ],
......
...@@ -251,6 +251,34 @@ class OrderController extends AbstractBase ...@@ -251,6 +251,34 @@ class OrderController extends AbstractBase
} }
} }
/**
* Deletes given Order
*
* @return mixed|void|ViewModel
*
* @throws UserNotAuthorizedException
* @throws ClientException
*/
public function deleteOrderAction()
{
if (!$this->getUser()) {
return $this->forceLogin();
}
$messenger = $this->getMessenger();
try {
$orderId = $this->params()->fromRoute('orderid');
$this->client->requestOrderDelete($orderId);
$message = $this->translate('fid::order_delete_success');
$messenger->addSuccessMessage($message);
} catch (UserNotAuthorizedException $exception) {
$messenger->addErrorMessage('fid::read_order_list_not_allowed');
} catch (ClientException $exception) {
$messenger->addErrorMessage('fid::order_delete_error');
}
return $this->redirect()->toRoute('fid/admin/orders');
}
/** /**
* Display admins order list route action * Display admins order list route action
* *
......
...@@ -369,6 +369,26 @@ class Client ...@@ -369,6 +369,26 @@ class Client
return $order; return $order;
} }
/**
* Delete order
*
* @param int $orderId order id
* @return bool
*
* @throws ClientException
*/
public function requestOrderDelete(int $orderId) : bool
{
$request = $this->buildRequest('delete', "orders/{$orderId}");
$response = $this->sendAuthenticatedRequest($request);
if ($response->getStatusCode() !== 204) {
$this->throwException($response);
}
return true;
}
/** /**
* Update order * Update order
* *
......
<!-- fid: fid - order - list - delete-confirmation-modal -->
<?php /* Modal for confirmation dialogue */ ?>
<div class="modal fade" id="orderDeleteModal" tabindex="-1" role="dialog" aria-labelledby="<?=$this->translate('CloseModal')?>" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content" style="padding-left: 20px;">
<div class="modal-header">
<h3 class="modal-title"><?=$this->translate('confirm_delete')?></h3>
<h5 id="orderModalTitle"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<br><?=$this->translate('fid::order_delete_modal')?><br><br>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?=$this->translate('Close')?></button>
<a
href=""
data-raw-link="<?=$this->url('fid/admin/deleteOrder')?>"
class="btn btn-primary modal-close btn-fid"
>
<?=$this->translate('Delete')?>
</a>
<br><br>
</div>
</div>
</div>
</div>
<?php $script = <<<JS
$(document).ready(function() {
$('#orderDeleteModal').on('show.bs.modal', function (event) {
let button = $(event.relatedTarget);
let recipient = button.data('order-id');
let title = button.data('order-title');
let link = $(this).find('a');
link[0].href = link.data('raw-link') + recipient;
$('#orderModalTitle').text(title);
});
});
JS;
?>
<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET');?>
<!-- fid: fid - order - list - delete-confirmation-modal - END -->
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<?php break; ?> <?php break; ?>
<?php case 'delete': ?> <?php case 'delete': ?>
<td> <td>
coming soon <?=$this->render('fid/order/list/field-delete')?>
</td> </td>
<?php break; ?> <?php break; ?>
<?php endswitch; ?> <?php endswitch; ?>
......
<!-- fid: fid - order - list - field-delete -->
<a
href="#"
data-toggle="modal"
data-target="#orderDeleteModal"
data-order-id="<?=$order->getId()?>"
data-order-title="<?=htmlspecialchars($order->getLabel())?>"
rel="nofollow"
>
<i aria-hidden="true" class="fa fa-trash">
</a>
<!-- fid: fid - order - list - field-delete - END -->
<!-- fid: fid - order - list - table --> <!-- fid: fid - order - list - table -->
<?php if (in_array('delete', $displayCols)): ?>
<?=$this->render('fid/order/list/delete-confirmation-modal')?>
<?php endif?>
<table class="table table-striped table-resp-data-md"> <table class="table table-striped table-resp-data-md">
<?php /* Table head */ ?> <?php /* Table head */ ?>
<tr> <tr>
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
?> ?>
<?php if ($offlineMode == "ils-offline"): ?> <?php if ($offlineMode == "ils-offline"): ?>
<?=$this->render('Helpers/ils-offline.phtml', ['offlineModeMsg' => 'ils_offline_login_message'])?> <?=$this->render('Helpers/ils-offline.phtml', ['offlineModeMsg' => 'ils_offline_login_message'])?>
<?php elseif (!$this->auth()->getManager()->allowsUserIlsLogin()): ?>
<h3><?=$this->transEsc('Library Catalog Profile')?></h3>
<div class="alert alert-warning"><?=$this->transEsc('ils_connection_failed')?></div>
<?php else: ?> <?php else: ?>
<?php /* finc uses h2 here */ ?> <?php /* finc uses h2 here */ ?>
<h2><?=$this->transEsc('Library Catalog Profile')?></h2> <h2><?=$this->transEsc('Library Catalog Profile')?></h2>
......
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