PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.6
ووسلام – همگام سازی ووکامرس و باسلام v1.10.6
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
sync-basalam / includes / Actions / Controller / TicketActions / CreateTicketItem.php

CreateTicketItem.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.6, at includes/Actions/Controller/TicketActions/CreateTicketItem.php

69 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Actions\Controller\TicketActions;
4
5 use SyncBasalam\Actions\Controller\ActionController;
6 use SyncBasalam\Services\TicketServiceManager;
7 use SyncBasalam\Utilities\TicketExtraInfoFormatter;
8 use SyncBasalam\Utilities\TicketAccessData;
9
10 defined('ABSPATH') || exit;
11
12 class CreateTicketItem extends ActionController
13 {
14 public function __invoke()
15 {
16 if (!current_user_can('manage_options')) {
17 wp_die('دسترسی غیر�
18 جاز!');
19 }
20
21 $this->processSubmission();
22 }
23
24 /** Run reply creation before the optional access replacement. */
25 public function processSubmission(?TicketServiceManager $ticketManager = null): void
26 {
27 $ticketManager = $ticketManager ?: new TicketServiceManager();
28
29 $content = isset($_POST['content']) ? TicketExtraInfoFormatter::sanitizeContent($_POST['content']) : '';
30 try {
31 $accessData = TicketAccessData::fromRequest($_POST);
32 } catch (\InvalidArgumentException $e) {
33 wp_die(esc_html($e->getMessage()));
34 }
35 if ($content === '' && !empty($accessData)) {
36 $content = 'اطلاعات دسترسی به‌روزرسانی شد.';
37 }
38 $ticketId = isset($_POST['ticket_id']) ? intval(\wp_unslash($_POST['ticket_id'])) : 0;
39
40 if ($ticketId <= 0) return;
41
42 $ticketResponse = $ticketManager->fetchTicket($ticketId);
43 $ticket = isset($ticketResponse['body']) ? json_decode($ticketResponse['body'], true) : null;
44
45 if (is_array($ticket) && TicketServiceManager::isTicketClosed($ticket)) return;
46
47 $fileIds = isset($_POST['file_ids']) && is_array($_POST['file_ids'])
48 ? array_map('intval', $_POST['file_ids'])
49 : [];
50
51 $itemResult = $ticketManager->createTicketItem($ticketId, $content, $fileIds);
52 if (!TicketServiceManager::isSuccessful($itemResult)) {
53 wp_die('خطایی در ارسال پاسخ تیکت رخ داد. لطفا �
54 جددا تلاش کنید.');
55 }
56
57 if (!empty($accessData)) {
58 $accessResult = $ticketManager->upsertTicketSiteAccess($ticketId, $accessData);
59 if (!TicketServiceManager::isSuccessful($accessResult)) {
60 wp_die(esc_html(
61 'پاسخ تیکت ثبت شد، ا�
62 ا اطلاعات دسترسی ذخیره نشد. '
63 . 'لطفا دوباره اطلاعات دسترسی را ارسال کنید.'
64 ));
65 }
66 }
67 }
68 }
69