v1.1.0.0
StocketBase
- <?php
-
- declare(strict_types=1);
-
- if (count(get_included_files()) === 1) {
- http_response_code(403);
- exit;
- }
-
- if (!Auth::hasRoleAtLeast(Auth::ROLE_STORE_MANAGER)) {
- return ['You don\'t have access to orders.', 'error', null];
- }
-
- require_once __DIR__ . '/../includes/orders.php';
-
- $orderId = (int) ($_POST['order_id'] ?? 0);
- $tool = (string) ($_POST['tool'] ?? '');
- $order = Orders::find($orderId);
-
- if ($order === null) {
- return ['We couldn\'t find that order.', 'error', null];
- }
-
- if ($tool === 'resend') {
- if (!Orders::resendConfirmation($orderId)) {
- return ['The email didn\'t go out. Check the email settings and that the order is paid.', 'error', $orderId];
- }
- Orders::addHistory($orderId, (string) $order['status'], 'Confirmation sent again', (int) $currentUser['id']);
-
- return ['Confirmation sent again.', 'success', $orderId];
- }
-
- if ($tool === 'reset_downloads') {
- $count = DigitalFiles::resetGrantsForOrder($orderId);
- Orders::addHistory($orderId, (string) $order['status'], 'Download limits reset', (int) $currentUser['id']);
-
- return [$count > 0 ? 'Download limits reset. The links work again.' : 'There were no download links to reset.', 'success', $orderId];
- }
-
- return ['Unknown action.', 'error', $orderId];
-