WebOrbiton
v1.1.0.0

StocketBase

41 lines · 1.2 KB
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. ​
  5. if (count(get_included_files()) === 1) {
  6. http_response_code(403);
  7. exit;
  8. }
  9. ​
  10. if (!Auth::hasRoleAtLeast(Auth::ROLE_STORE_MANAGER)) {
  11. return ['You don\'t have access to orders.', 'error', null];
  12. }
  13. ​
  14. require_once __DIR__ . '/../includes/orders.php';
  15. ​
  16. $orderId = (int) ($_POST['order_id'] ?? 0);
  17. $tool = (string) ($_POST['tool'] ?? '');
  18. $order = Orders::find($orderId);
  19. ​
  20. if ($order === null) {
  21. return ['We couldn\'t find that order.', 'error', null];
  22. }
  23. ​
  24. if ($tool === 'resend') {
  25. if (!Orders::resendConfirmation($orderId)) {
  26. return ['The email didn\'t go out. Check the email settings and that the order is paid.', 'error', $orderId];
  27. }
  28. Orders::addHistory($orderId, (string) $order['status'], 'Confirmation sent again', (int) $currentUser['id']);
  29. ​
  30. return ['Confirmation sent again.', 'success', $orderId];
  31. }
  32. ​
  33. if ($tool === 'reset_downloads') {
  34. $count = DigitalFiles::resetGrantsForOrder($orderId);
  35. Orders::addHistory($orderId, (string) $order['status'], 'Download limits reset', (int) $currentUser['id']);
  36. ​
  37. return [$count > 0 ? 'Download limits reset. The links work again.' : 'There were no download links to reset.', 'success', $orderId];
  38. }
  39. ​
  40. return ['Unknown action.', 'error', $orderId];
  41. ​