| 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 |
|
| 9 |
defined('ABSPATH') || exit; |
| 10 |
|
| 11 |
class CreateTicket extends ActionController |
| 12 |
{ |
| 13 |
public function __invoke() |
| 14 |
{ |
| 15 |
$ticketManager = new TicketServiceManager(); |
| 16 |
|
| 17 |
$title = isset($_POST['title']) ? \sanitize_text_field(\wp_unslash($_POST['title'])) : null; |
| 18 |
$subject = isset($_POST['subject']) ? \sanitize_text_field(\wp_unslash($_POST['subject'])) : null; |
| 19 |
$content = isset($_POST['content']) ? \sanitize_textarea_field(\wp_unslash($_POST['content'])) : ''; |
| 20 |
$content = TicketExtraInfoFormatter::appendFromRequest($content, $_POST); |
| 21 |
|
| 22 |
$fileIds = isset($_POST['file_ids']) && is_array($_POST['file_ids']) |
| 23 |
? array_map('intval', $_POST['file_ids']) |
| 24 |
: []; |
| 25 |
|
| 26 |
$result = $ticketManager->createTicket($title, $subject, $content, $fileIds); |
| 27 |
if (isset($result['body'])) $ticket = json_decode($result['body'], true); |
| 28 |
else { |
| 29 |
wp_die('خطایی در ارسال تیکت رخ داده است. لطفا � |
| 30 |
جددا تلاش کنید.'); |
| 31 |
} |
| 32 |
|
| 33 |
wp_safe_redirect(admin_url("admin.php?page=sync_basalam_ticket&ticket_id=" . $ticket['data']['id'])); |
| 34 |
exit(); |
| 35 |
} |
| 36 |
} |
| 37 |
|