Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in tickets view page download attachments #652

Closed
21 changes: 16 additions & 5 deletions Controller/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
use Webkul\UVDesk\CoreFrameworkBundle\Entity\User;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketPriority;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketStatus;
use Webkul\UVDesk\CoreFrameworkBundle\Entity as CoreEntites;


class Ticket extends AbstractController
{
Expand Down Expand Up @@ -172,11 +174,11 @@ public function saveTicket(Request $request)
$requestParams = $request->request->all();
$entityManager = $this->getDoctrine()->getManager();
$response = $this->redirect($this->generateUrl('helpdesk_member_ticket_collection'));

if ($request->getMethod() != 'POST' || false == $this->userService->isAccessAuthorized('ROLE_AGENT_CREATE_TICKET')) {
return $response;
}

// Get referral ticket if any
$ticketValidationGroup = 'CreateTicket';
$referralURL = $request->headers->get('referer');
Expand All @@ -185,16 +187,23 @@ public function saveTicket(Request $request)
$iterations = explode('/', $referralURL);
$referralId = array_pop($iterations);
$expectedReferralURL = $this->generateUrl('helpdesk_member_ticket', ['ticketId' => $referralId], UrlGeneratorInterface::ABSOLUTE_URL);

if ($referralURL === $expectedReferralURL) {
$referralTicket = $entityManager->getRepository(CoreBundleTicket::class)->findOneById($referralId);

if (!empty($referralTicket)) {
$ticketValidationGroup = 'CustomerCreateTicket';
}
}
}

$email = $request->request->get('from');
$website = $entityManager->getRepository(CoreEntites\Website::class)->findOneByCode('knowledgebase');
if(!empty($email) && $this->ticketService->isEmailBlocked($email, $website)) {
$request->getSession()->getFlashBag()->set('warning', $this->translator->trans('Warning ! Cannot create ticket, given email is blocked.'));
return $this->redirect($this->generateUrl('helpdesk_member_ticket_collection'));
}

$ticketType = $entityManager->getRepository(TicketType::class)->findOneById($requestParams['type']);

try {
Expand Down Expand Up @@ -493,6 +502,7 @@ public function downloadZipAttachment(Request $request)
$response->setStatusCode(200);
$response->headers->set('Content-type', 'application/zip');
$response->headers->set('Content-Disposition', 'attachment; filename=' . $threadId . '.zip');
$response->headers->set('Content-length', filesize($zipname));
$response->sendHeaders();
$response->setContent(readfile($zipname));

Expand Down Expand Up @@ -531,7 +541,8 @@ public function downloadAttachment(Request $request)

$response->setStatusCode(200);
$response->sendHeaders();
$response->setContent(readfile($path));
// $response->setContent(readfile($path));
readfile($path);

return $response;
}
Expand Down
5 changes: 4 additions & 1 deletion FileSystem/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ public function getFileTypeAssociations(Attachment $attachment, $firewall = 'mem
}

if (!empty($assetDetails['downloadURL'])) {
$assetDetails['downloadURL'] = $this->container->get('uvdesk.service')->generateCompleteLocalResourcePathUri($assetDetails['downloadURL']);
$scheme = $this->container->get('router')->getContext()->getScheme();
$host = $this->container->get('router')->getContext()->getHost();
$baseUrl = "$scheme://$host";
$assetDetails['downloadURL'] = $baseUrl.$assetDetails['downloadURL'];
}

return $assetDetails;
Expand Down
7 changes: 7 additions & 0 deletions Resources/views/Snippets/createMemberTicket.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@
},
'reply' : {
fn: function(value) {
var content = tinyMCE.activeEditor.getContent();
if (content) {
return false;
}else {
return true;
}

if(!tinyMCE.get("uv-edit-create-thread"))
return false;
var html = tinyMCE.get("uv-edit-create-thread").getContent();
Expand Down