Skip to content

Commit 9e4d2c5

Browse files
author
Sanjeev Papnoi
committed
Merge remote-tracking branch 'origin/1.0' into HEAD
2 parents b7a9d5e + 663e972 commit 9e4d2c5

10 files changed

Lines changed: 194 additions & 37 deletions

File tree

Controller/Article.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ public function articleListByCategory(Request $request)
8787

8888
public function ArticleListBySolution(Request $request)
8989
{
90-
91-
9290
$solution = $this->getDoctrine()
9391
->getRepository('UVDeskSupportCenterBundle:Solutions')
9492
->findSolutionById(['id' => $request->attributes->get('solution')]);
@@ -212,6 +210,12 @@ public function article(Request $request)
212210
}
213211
public function articleXhr(Request $request)
214212
{
213+
// Proceed only if user has access to the resource
214+
if( (!$this->userService->getSessionUser()) || (!$this->userService->isAccessAuthorized('ROLE_AGENT_MANAGE_KNOWLEDGEBASE')) )
215+
{
216+
throw new \Exception('Access Denied', 403);
217+
}
218+
215219
$json = array();
216220

217221
if ($request->getMethod() == "POST") {

Controller/Customer.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@
1515
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
1616
use Webkul\UVDesk\CoreFrameworkBundle\FileSystem\FileSystem;
1717
use Symfony\Component\Translation\TranslatorInterface;
18+
use Webkul\UVDesk\CoreFrameworkBundle\Services\FileUploadService;
1819

1920
Class Customer extends AbstractController
2021
{
2122
private $translator;
2223
private $fileSystem;
2324
private $passwordEncoder;
25+
private $fileUploadService;
2426

25-
public function __construct(TranslatorInterface $translator, UserPasswordEncoderInterface $passwordEncoder, FileSystem $fileSystem)
27+
public function __construct(TranslatorInterface $translator, UserPasswordEncoderInterface $passwordEncoder, FileSystem $fileSystem, FileUploadService $fileUploadService)
2628
{
2729
$this->translator = $translator;
2830
$this->fileSystem = $fileSystem;
2931
$this->passwordEncoder = $passwordEncoder;
32+
$this->fileUploadService = $fileUploadService;
3033
}
3134

3235
protected function redirectUserToLogin()
@@ -171,10 +174,19 @@ public function Account(Request $request)
171174
$userInstance = $em->getRepository('UVDeskCoreFrameworkBundle:UserInstance')->findOneBy(array('user' => $user->getId()));
172175

173176
if (isset($dataFiles['profileImage'])) {
177+
$previousImage = $userInstance->getProfileImagePath();
178+
if($previousImage != null){
179+
$image = str_replace("\\","/",$this->getParameter('kernel.project_dir').'/public'.$previousImage);
180+
$check = $this->fileUploadService->fileRemoveFromFolder($image);
181+
}
174182
$assetDetails = $this->fileSystem->getUploadManager()->uploadFile($dataFiles['profileImage'], 'profile');
175183
$userInstance->setProfileImagePath($assetDetails['path']);
176184
}
177185

186+
if ($request->get('removeImage') == 'on') {
187+
$userInstance->setProfileImagePath(null);
188+
}
189+
178190
$userInstance = $userInstance->setContactNumber($data['contactNumber']);
179191
$em->persist($userInstance);
180192
$em->flush();

Controller/Ticket.php

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function ticketadd(Request $request)
160160

161161
$customerEmail = $params['email'] = $request->request->get('from');
162162
$customer = $em->getRepository('UVDeskCoreFrameworkBundle:User')->findOneBy(array('email' => $customerEmail));
163-
$params['flag'] = (!$customer) ? 1 : 0;$request->getSession()->getFlashBag()->set('success', $this->translator->trans('Success ! Ticket has been created successfully.'));
163+
$params['flag'] = (!$customer) ? 1 : 0;
164164

165165
$data['firstName'] = current($nameDetails = explode(' ', $request->request->get('name')));
166166
$data['fullname'] = $request->request->get('name');
@@ -197,7 +197,7 @@ public function ticketadd(Request $request)
197197
if($request->request->get('customFields') || $request->files->get('customFields')) {
198198
$this->get('ticket.service')->addTicketCustomFields($ticket, $request->request->get('customFields'), $request->files->get('customFields'));
199199
}
200-
$request->getSession()->getFlashBag()->set('success', sprintf('Success ! Ticket #%s has been created successfully.', $ticket->getId()));
200+
$this->addFlash('success', $this->translator->trans('Success ! Ticket has been created successfully.'));
201201
} else {
202202
$this->addFlash('warning', $this->translator->trans('Warning ! Can not create ticket, invalid details.'));
203203
}
@@ -275,6 +275,14 @@ public function saveReply(int $id, Request $request)
275275
$this->isWebsiteActive();
276276
$data = $request->request->all();
277277
$ticket = $this->getDoctrine()->getRepository('UVDeskCoreFrameworkBundle:Ticket')->find($id);
278+
$user = $this->userService->getSessionUser();
279+
280+
// process only if access for the resource.
281+
if (empty($ticket) || ( (!empty($user)) && $user->getId() != $ticket->getCustomer()->getId()) ) {
282+
if(!$this->isCollaborator($ticket, $user)) {
283+
throw new \Exception('Access Denied', 403);
284+
}
285+
}
278286

279287
if($_POST) {
280288
if(str_replace(' ','',str_replace('&nbsp;','',trim(strip_tags($data['message'], '<img>')))) != "") {
@@ -293,7 +301,7 @@ public function saveReply(int $id, Request $request)
293301
}
294302

295303
// @TODO: Refactor -> Why are we filtering only these two characters?
296-
$data['message'] = str_replace(['&lt;script&gt;', '&lt;/script&gt;'], '', $data['message']);
304+
$data['message'] = str_replace(['&lt;script&gt;', '&lt;/script&gt;'], '', htmlspecialchars($data['message']));
297305

298306
$userDetail = $this->userService->getCustomerPartialDetailById($data['user']->getId());
299307
$data['fullname'] = $userDetail['name'];
@@ -318,10 +326,12 @@ public function saveReply(int $id, Request $request)
318326
if ($thread->getcreatedBy() == 'customer') {
319327
$event = new GenericEvent(CoreWorkflowEvents\Ticket\CustomerReply::getId(), [
320328
'entity' => $ticket,
329+
'thread' => $thread
321330
]);
322331
} else {
323332
$event = new GenericEvent(CoreWorkflowEvents\Ticket\CollaboratorReply::getId(), [
324333
'entity' => $ticket,
334+
'thread' => $thread
325335
]);
326336
}
327337

@@ -504,6 +514,16 @@ public function downloadAttachmentZip(Request $request)
504514
$this->noResultFound();
505515
}
506516

517+
$ticket = $attachment->getThread()->getTicket();
518+
$user = $this->userService->getSessionUser();
519+
520+
// process only if access for the resource.
521+
if (empty($ticket) || ( (!empty($user)) && $user->getId() != $ticket->getCustomer()->getId()) ) {
522+
if(!$this->isCollaborator($ticket, $user)) {
523+
throw new \Exception('Access Denied', 403);
524+
}
525+
}
526+
507527
$zipname = 'attachments/' .$threadId.'.zip';
508528
$zip = new \ZipArchive;
509529

@@ -535,6 +555,12 @@ public function downloadAttachment(Request $request)
535555
$this->noResultFound();
536556
}
537557

558+
$ticket = $attachment->getThread()->getTicket();
559+
// Proceed only if user has access to the resource
560+
if (false == $this->ticketService->isTicketAccessGranted($ticket, $user)) {
561+
throw new \Exception('Access Denied', 403);
562+
}
563+
538564
$path = $this->get('kernel')->getProjectDir() . "/public/". $attachment->getPath();
539565

540566
$response = new Response();
@@ -555,6 +581,14 @@ public function ticketCollaboratorXhr(Request $request)
555581
$content = json_decode($request->getContent(), true);
556582
$em = $this->getDoctrine()->getManager();
557583
$ticket = $em->getRepository('UVDeskCoreFrameworkBundle:Ticket')->find($content['ticketId']);
584+
$user = $this->userService->getSessionUser();
585+
586+
// process only if access for the resource.
587+
if (empty($ticket) || ( (!empty($user)) && $user->getId() != $ticket->getCustomer()->getId()) ) {
588+
if(!$this->isCollaborator($ticket, $user)) {
589+
throw new \Exception('Access Denied', 403);
590+
}
591+
}
558592

559593
if ($request->getMethod() == "POST") {
560594
if ($content['email'] == $ticket->getCustomer()->getEmail()) {
@@ -580,7 +614,6 @@ public function ticketCollaboratorXhr(Request $request)
580614
$ticket->lastCollaborator = $collaborator;
581615
$collaborator = $em->getRepository('UVDeskCoreFrameworkBundle:User')->find($collaborator->getId());
582616

583-
584617
$json['collaborator'] = $this->userService->getCustomerPartialDetailById($collaborator->getId());
585618
$json['alertClass'] = 'success';
586619
$json['alertMessage'] = $this->translator->trans('Success ! Collaborator added successfully.');
@@ -609,4 +642,4 @@ public function ticketCollaboratorXhr(Request $request)
609642
$response->headers->set('Content-Type', 'application/json');
610643
return $response;
611644
}
612-
}
645+
}

Resources/views/Knowledgebase/customerAccount.html.twig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,18 @@
187187
</div>
188188
</div>
189189
<!-- //Profile image -->
190-
190+
191+
{% if isHaveImage %}
192+
<div class="uv-element-block">
193+
<label>
194+
<div class="uv-checkbox">
195+
<input name="removeImage" id="removeImage" type="checkbox">
196+
<span class="uv-checkbox-view"></span>
197+
</div><span class="uv-checkbox-label">{{ 'Remove profile picture'|trans }}</span>
198+
</label>
199+
</div>
200+
{% endif %}
201+
191202
<!-- Field -->
192203
<div class="uv-element-block">
193204
<label class="uv-field-label">{{ 'First Name'|trans }}</label>

Resources/views/Knowledgebase/ticket.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@
217217
{{ include('@UVDeskCoreFramework/Templates/attachment.html.twig') }}
218218

219219
<script type="text/javascript">
220+
{% if user_service.isfileExists('apps/uvdesk/form-component') == false %}
221+
customFieldValidation = {};
222+
{% endif %}
220223
$(function () {
221224
{% if(removeMe is defined) %}
222225
$.each({{ removeMe | json_encode |raw }}, function(key, value){

Resources/views/Knowledgebase/ticketList.html.twig

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,21 @@
192192
</td>
193193
<td data-value="{{ 'Status'|trans }}">
194194
<a class="not-shiny" href="<%- path %>">
195-
<%- status.description %>
195+
<% if (status.description == 'Open') { %>
196+
{{ 'Open'|trans }}
197+
<% } else if (status.description == 'Closed') { %>
198+
{{ 'Closed'|trans }}
199+
<% } else if (status.description == 'Pending') { %>
200+
{{ 'Pending'|trans }}
201+
<% } else if (status.description == 'Answered') { %>
202+
{{ 'Answered'|trans }}
203+
<% } else if(status.description == 'Resolved') { %>
204+
{{ 'Resolved'|trans }}
205+
<% } else if(status.description == 'UnAnswered') { %>
206+
{{ 'UnAnswered'|trans }}
207+
<% } else if(status.description == 'UnAssigned') { %>
208+
{{ 'UnAssigned'|trans }}
209+
<% } %>
196210
</a>
197211
</td>
198212
<td data-value="{{ 'Timestamp'|trans }}">

Resources/views/Knowledgebase/ticketView.html.twig

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,44 @@
415415
</div>
416416
</div>
417417

418+
<div class="uv-kudo">
419+
<div class="uv-kudo-button">
420+
<!--uv-kudo-button-active-->
421+
<div class="uv-kudo-icon"></div>
422+
<span>{{ 'Rate Support'|trans }}</span>
423+
</div>
424+
425+
<div class="uv-kudo-plank">
426+
{% set count = 0 %}
427+
{% for rating in ticket.ratings %}
428+
{% if rating.getCustomer.id == app.user.id %}
429+
{% set count = rating.getStars %}
430+
{% endif %}
431+
{% endfor %}
432+
<div class="uv-kudo-response-wrapper">
433+
<span class="uv-kudo-response uv-kudo-very-sad {% if count == 1 %}uv-kudo-done{% endif %}" data-id="1"></span>
434+
<span class="uv-kudo-response uv-kudo-sad {% if count == 2 %}uv-kudo-done{% endif %}" data-id="2"></span>
435+
<span class="uv-kudo-response uv-kudo-neutral {% if count == 3 %}uv-kudo-done{% endif %}" data-id="3"></span>
436+
<span class="uv-kudo-response uv-kudo-happy {% if count == 4 %}uv-kudo-done{% endif %}" data-id="4"></span>
437+
<span class="uv-kudo-response uv-kudo-very-happy {% if count == 5 %}uv-kudo-done{% endif %}" data-id="5"></span>
438+
</div>
439+
440+
<span class="uv-kudo-message">
441+
{% if count == 1 %}
442+
{{ 'I am very Sad'|trans }}
443+
{% elseif count == 2 %}
444+
{{ 'I am Sad'|trans }}
445+
{% elseif count == 3 %}
446+
{{ 'I am Neutral'|trans }}
447+
{% elseif count == 4 %}
448+
{{ 'I am Happy'|trans }}
449+
{% elseif count == 5 %}
450+
{{ 'I am Very Happy'|trans }}
451+
{% endif %}
452+
</span>
453+
</div>
454+
</div>
455+
418456
<div class="uv-pop-up-overlay" id="confirm-ticket-close-modal" style="display: none;">
419457
<div class="uv-pop-up-box uv-pop-up-slim">
420458
<span class="uv-pop-up-close"></span>
@@ -519,6 +557,7 @@
519557
el: $('.uv-body'),
520558
stopDraftSaveFlag: 0,
521559
events: {
560+
'click .uv-kudo-response-wrapper .uv-kudo-response': 'rateTicket',
522561
'click .collaborator-list .uv-btn-tag': 'removeCcCollaborator',
523562
'change .uv-element-block.cc-bcc .cc-bcc-toggle': 'showCcBccBlock',
524563
'keypress .uv-element-block.cc-bcc .uv-group-field': 'addCcBccInput',
@@ -535,7 +574,40 @@
535574
$('#confirm-ticket-close-modal').hide();
536575
this.validateForm(e);
537576
},
577+
ratingText: {
578+
'1' : "{{ 'I am very Sad'|trans }}",
579+
'2' : "{{ 'I am Sad'|trans }}",
580+
'3' : "{{ 'I am Neutral'|trans }}",
581+
'4' : "{{ 'I am Happy'|trans }}",
582+
'5' : "{{ 'I am Very Happy'|trans }}",
583+
},
538584
loaderTemplate : _.template($("#loader-tmp").html()),
585+
rateTicket : function(e) {
586+
var element = Backbone.$(e.currentTarget);
587+
var count = element.attr('data-id');
588+
this.model.set('rating', count);
589+
590+
var self = this;
591+
app.appView.showLoader()
592+
this.model.save({}, {
593+
url : "{{ path('helpdesk_customer_rate_ticket', {'id': ticket.id}) }}",
594+
success: function (model, response, options) {
595+
app.appView.hideLoader()
596+
if(response.alertClass == 'success') {
597+
$('.uv-kudo-response').removeClass('uv-kudo-done');
598+
element.addClass('uv-kudo-done');
599+
$('.uv-kudo-message').text(self.ratingText[count])
600+
$('.uv-kudo-button').trigger('click')
601+
} else {
602+
app.appView.renderResponseAlert(response);
603+
}
604+
},
605+
error: function (model, xhr, options) {
606+
if(url = xhr.getResponseHeader('Location'))
607+
window.location = url;
608+
}
609+
});
610+
},
539611
addCCCollaborators: function() {
540612
if(collaboratorCollection.length) {
541613
var collaboratorContainer = $('.uv-element-block.collaborators');
@@ -876,4 +948,19 @@
876948
}
877949
});
878950
</script>
951+
952+
<script>
953+
document.addEventListener("DOMContentLoaded", function(){
954+
var uvKudoButton = document.querySelector(".uv-kudo-button");
955+
var uvKudoIcon = document.querySelector(".uv-kudo-icon");
956+
var uvKudoPlank = document.querySelector(".uv-kudo-plank");
957+
var uvKudoMessage = document.querySelector(".uv-kudo-message");
958+
var uvKudoResponse = document.querySelector(".uv-kudo-response");
959+
960+
uvKudoButton.addEventListener("click", function(){
961+
uvKudoButton.classList.toggle("uv-kudo-button-active");
962+
uvKudoPlank.classList.toggle("uv-kudo-plank-active");
963+
});
964+
});
965+
</script>
879966
{% endblock %}

0 commit comments

Comments
 (0)