Skip to content

Commit

Permalink
Merge branch '1.0' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanjeev Papnoi committed Oct 27, 2021
2 parents 9e4d2c5 + 401105f commit 8474e57
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 33 deletions.
9 changes: 5 additions & 4 deletions Controller/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ public function removeAnnouncementXHR(Request $request)
}

$entityManager = $this->getDoctrine()->getManager();
$knowledgebaseAnnouncementId = $request->attributes->get('id');
$knowledgebaseAnnouncementId = $request->attributes->get('announcementId');

$knowledgebaseAnnouncement = $entityManager->getRepository(Announcement::class)->findOneBy([
'id' => $knowledgebaseAnnouncementId
]);
$knowledgebaseAnnouncement = $this->getDoctrine()->getRepository('UVDeskSupportCenterBundle:Announcement')
->findOneBy([
'id' => $request->attributes->get('announcementId')
]);

if ($knowledgebaseAnnouncement) {
$entityManager->remove($knowledgebaseAnnouncement);
Expand Down
37 changes: 28 additions & 9 deletions Controller/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Webkul\UVDesk\CoreFrameworkBundle\Services\UserService;
use Webkul\UVDesk\CoreFrameworkBundle\Services\UVDeskService;
use Webkul\UVDesk\CoreFrameworkBundle\Services\TicketService;
use Webkul\UVDesk\CoreFrameworkBundle\Services\CustomFieldsService;
use Webkul\UVDesk\CoreFrameworkBundle\FileSystem\FileSystem;
use Symfony\Component\Translation\TranslatorInterface;
use Webkul\UVDesk\CoreFrameworkBundle\Services\ReCaptchaService;
Expand All @@ -32,17 +33,17 @@ class Ticket extends Controller
private $translator;
private $uvdeskService;
private $ticketService;
private $fileSystem;
private $CustomFieldsService;
private $recaptchaService;

public function __construct(UserService $userService, UVDeskService $uvdeskService,EventDispatcherInterface $eventDispatcher, TranslatorInterface $translator, TicketService $ticketService, FileSystem $fileSystem, ReCaptchaService $recaptchaService)
public function __construct(UserService $userService, UVDeskService $uvdeskService,EventDispatcherInterface $eventDispatcher, TranslatorInterface $translator, TicketService $ticketService, CustomFieldsService $CustomFieldsService, ReCaptchaService $recaptchaService)
{
$this->userService = $userService;
$this->eventDispatcher = $eventDispatcher;
$this->translator = $translator;
$this->uvdeskService = $uvdeskService;
$this->ticketService = $ticketService;
$this->fileSystem = $fileSystem;
$this->CustomFieldsService = $CustomFieldsService;
$this->recaptchaService = $recaptchaService;
}

Expand Down Expand Up @@ -97,7 +98,7 @@ public function ticketadd(Request $request)
$message = '';
$ticketType = $em->getRepository('UVDeskCoreFrameworkBundle:TicketType')->find($request->request->get('type'));

if($request->files->get('customFields') && !$this->fileSystem->validateAttachmentsSize($request->files->get('customFields'))) {
if($request->files->get('customFields') && !$this->CustomFieldsService->validateAttachmentsSize($request->files->get('customFields'))) {
$error = true;
$this->addFlash(
'warning',
Expand Down Expand Up @@ -195,7 +196,7 @@ public function ticketadd(Request $request)
if (!empty($thread)) {
$ticket = $thread->getTicket();
if($request->request->get('customFields') || $request->files->get('customFields')) {
$this->get('ticket.service')->addTicketCustomFields($ticket, $request->request->get('customFields'), $request->files->get('customFields'));
$this->get('ticket.service')->addTicketCustomFields($thread, $request->request->get('customFields'), $request->files->get('customFields'));
}
$this->addFlash('success', $this->translator->trans('Success ! Ticket has been created successfully.'));
} else {
Expand Down Expand Up @@ -440,12 +441,15 @@ public function ticketView($id, Request $request)
$entityManager->persist($ticket);
$entityManager->flush();
}

$checkTicket = $entityManager->getRepository('UVDeskCoreFrameworkBundle:Ticket')->isTicketCollaborator($ticket, $user->getEmail());

$twigResponse = [
'ticket' => $ticket,
'searchDisable' => true,
'initialThread' => $this->ticketService->getTicketInitialThreadDetails($ticket),
'localizedCreateAtTime' => $this->userService->getLocalizedFormattedTime($user, $ticket->getCreatedAt()),
'isCollaborator' => $checkTicket,
];

return $this->render('@UVDeskSupportCenter/Knowledgebase/ticketView.html.twig', $twigResponse);
Expand Down Expand Up @@ -507,14 +511,17 @@ public function downloadAttachmentZip(Request $request)
{
$threadId = $request->attributes->get('threadId');
$attachmentRepository = $this->getDoctrine()->getManager()->getRepository('UVDeskCoreFrameworkBundle:Attachment');
$threadRepository = $this->getDoctrine()->getManager()->getRepository('UVDeskCoreFrameworkBundle:Thread');

$thread = $threadRepository->findOneById($threadId);

$attachment = $attachmentRepository->findByThread($threadId);

if (!$attachment) {
$this->noResultFound();
}

$ticket = $attachment->getThread()->getTicket();
$ticket = $thread->getTicket();
$user = $this->userService->getSessionUser();

// process only if access for the resource.
Expand Down Expand Up @@ -556,9 +563,13 @@ public function downloadAttachment(Request $request)
}

$ticket = $attachment->getThread()->getTicket();
// Proceed only if user has access to the resource
if (false == $this->ticketService->isTicketAccessGranted($ticket, $user)) {
throw new \Exception('Access Denied', 403);
$user = $this->userService->getSessionUser();

// process only if access for the resource.
if (empty($ticket) || ( (!empty($user)) && $user->getId() != $ticket->getCustomer()->getId()) ) {
if(!$this->isCollaborator($ticket, $user)) {
throw new \Exception('Access Denied', 403);
}
}

$path = $this->get('kernel')->getProjectDir() . "/public/". $attachment->getPath();
Expand Down Expand Up @@ -611,8 +622,16 @@ public function ticketCollaboratorXhr(Request $request)
$ticket->addCollaborator($collaborator);
$em->persist($ticket);
$em->flush();

$ticket->lastCollaborator = $collaborator;

$collaborator = $em->getRepository('UVDeskCoreFrameworkBundle:User')->find($collaborator->getId());

$event = new GenericEvent(CoreWorkflowEvents\Ticket\Collaborator::getId(), [
'entity' => $ticket,
]);

$this->eventDispatcher->dispatch('uvdesk.automation.workflow.execute', $event);

$json['collaborator'] = $this->userService->getCustomerPartialDetailById($collaborator->getId());
$json['alertClass'] = 'success';
Expand Down
2 changes: 1 addition & 1 deletion Entity/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Article

/**
* @var string
* @ORM\Column(type="string", length=255, nullable=true, name="meta_description")
* @ORM\Column(type="text", length=2000, nullable=true, name="meta_description")
*/
private $metaDescription;

Expand Down
4 changes: 2 additions & 2 deletions Entity/KnowledgebaseWebsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class KnowledgebaseWebsite

/**
* @var string
* @ORM\Column(type="string", length=255, name="meta_description", nullable=true)
* @ORM\Column(type="text", length=2000, name="meta_description", nullable=true)
*/
private $metaDescription;
/**
* @var string
* @ORM\Column(type="string", length=255, name="meta_keywords", nullable=true)
* @ORM\Column(type="text", length=2000, name="meta_keywords", nullable=true)
*/
private $metaKeywords;
/**
Expand Down
2 changes: 1 addition & 1 deletion Fixtures/EmailTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Webkul\UVDesk\SupportCenterBundle\Fixtures;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Webkul\UVDesk\CoreEntities\Entity as CoreEntities;
use Doctrine\Bundle\FixturesBundle\Fixture as DoctrineFixture;
use Webkul\UVDesk\SupportCenterBundle\Templates\Email\Resources as SupportCenterEmailTemplates;
Expand Down
4 changes: 2 additions & 2 deletions Fixtures/KnowledgebaseWebsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Webkul\UVDesk\SupportCenterBundle\Fixtures;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Webkul\UVDesk\CoreFrameworkBundle\Entity as CoreEntities;
use Doctrine\Bundle\FixturesBundle\Fixture as DoctrineFixture;
use Webkul\UVDesk\SupportCenterBundle\Entity as SupportCenterEntities;
Expand Down Expand Up @@ -34,7 +34,7 @@ public function load(ObjectManager $entityManager)

if (empty($website)) {
($website = new CoreEntities\Website())
->setName('Knowledgebase')
->setName('Helpdesk Knowledgebase')
->setCode('knowledgebase')
->setThemeColor('#7E91F0')
->setCreatedAt(new \DateTime())
Expand Down
2 changes: 1 addition & 1 deletion Repository/AnnouncementRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Webkul\UVDesk\SupportCenterBundle\Entity\Announcement;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections;
use Doctrine\ORM\Tools\Pagination\Paginator;
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/routes/private-agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,5 @@ helpdesk_member_knowledgebase_update_marketing_announcement:

helpdesk_member_knowledgebase_remove_marketing_announcement_xhr:
path: /knowledgebase/announcement/remove/{announcementId}
controller: Webkul\UVDesk\SupportCenterBundle\Controller\Announcement::removeAnnouncement
controller: Webkul\UVDesk\SupportCenterBundle\Controller\Announcement::removeAnnouncementXHR
defaults: { announcementId: 0 }
8 changes: 4 additions & 4 deletions Resources/views/Knowledgebase/article.html.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% extends "@UVDeskSupportCenter/Templates/layout.html.twig" %}

{% if article.slug %}
{% block canonical %}{{ url('helpdesk_knowledgebase_read_slug_article', {'slug':article.slug }) }}{% endblock %}
{% block ogcanonical %}{{ url('helpdesk_knowledgebase_read_slug_article', {'slug':article.slug }) }}{% endblock %}
{% endif %}

{% block canonical %} {% if article.slug %} {{ url('helpdesk_knowledgebase_read_slug_article', {'slug':article.slug }) }} {% endif %} {% endblock %}
{% block ogcanonical %} {% if article.slug %} {{ url('helpdesk_knowledgebase_read_slug_article', {'slug':article.slug }) }} {% endif %} {% endblock %}


{% block title %}{{ article.metaTitle ? article.metaTitle : article.name }}{% endblock %}
{% block ogtitle %}{{ article.metaTitle ? article.metaTitle : article.name }}{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Knowledgebase/login.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
initialize: function () {
Backbone.Validation.bind(this);
{% if error.messageKey is defined %}
app.appView.renderResponseAlert({'alertClass': 'danger', 'alertMessage': "{{ error.messageKey }}"})
app.appView.renderResponseAlert({'alertClass': 'danger', 'alertMessage': '{{ error.messageKey|trans}}'})
{% endif %}
},
formChanegd: function(e) {
Expand Down
9 changes: 9 additions & 0 deletions Resources/views/Knowledgebase/ticket.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@
$('label[for="' + value + '"]').parent().hide();
});
{% endif %}
$('.uv-header-date').datetimepicker({
format: 'YYYY-MM-DD',
});
$('.uv-header-time').datetimepicker({
format: 'LT',
});
$('.uv-header-datetime').datetimepicker({
format: 'YYYY-MM-DD H:m:s'
});
var CreateTicketModel = Backbone.Model.extend({
idAttribute : "id",
defaults : {
Expand Down
9 changes: 9 additions & 0 deletions Resources/views/Knowledgebase/ticketList.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@
<% if(sort == 'name') { %>
<span class="uv-sorting <% if(direction == 'asc') { %> descend <% } else { %> ascend <% } %>"></span>
<% } %>
</li>
<li class="<% if(sort == 't.updatedAt') { %>uv-drop-list-active<% } %>">
<a href="#<% if(queryString != '') { %><%- queryString %>/<% } %><% if(page) { %>page/<%- page %><% } else { %>page/1<% } %>/sort/t.updatedAt/<% if(sort == 't.updatedAt') { %><% if(direction) { %>direction/<%- direction %><% } else { %>direction/asc<% } %><% } else { %>direction/desc<% } %>" data-field="t.updatedAt">
{{ 'Last Updated'|trans }}
</a>
<% if(sort == 't.updatedAt') { %>
<span class="uv-sorting <% if(direction == 'asc') { %> descend <% } else { %> ascend <% } %>"></span>
<% } %>
</li>
</script>
Expand Down
6 changes: 4 additions & 2 deletions Resources/views/Knowledgebase/ticketView.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,15 @@
</div>

<div class="uv-element-block cc-bcc">
{% if isCollaborator != true %}
<label>
<div class="uv-checkbox">
<input type="checkbox" class="cc-bcc-toggle">
<span class="uv-checkbox-view"></span>
</div>
<span class="uv-checkbox-label">{{ 'CC/BCC'|trans }}</span>
</label>
{% endif %}
<div class="uv-field-block" style="display: none">
<div class="uv-group">
<input class="uv-group-field" type="text">
Expand Down Expand Up @@ -494,7 +496,7 @@
</div>
<div class="uv-ticket-main-lt">
<% if(user && smallThumbnail != null) { %>
<img src="{{ app.request.scheme ~'://' ~ app.request.httpHost ~ asset('') }}<%= smallThumbnail %>" />
<img src="{{ app.request.scheme ~'://' ~ app.request.httpHost ~ asset('') }}<%= smallThumbnail.slice(1) %>" />
<% } else { %>
<img src="<% if(userType == 'agent') { %> {{ asset(default_agent_image_path) }} <% } else { %> {{ asset(default_customer_image_path) }} <% } %>" />
<% } %>
Expand All @@ -515,7 +517,7 @@
<h4>{{ 'Uploaded Files'|trans }}</h4>
<div class="uv-ticket-uploads-strip uv-viewer-images">
<% _.each(attachments, function(file) { %>
<a href="<%-file.downloadURL %>" target ="_blank" class="uv-ticket-uploads-brick uv-no-pointer-events" data-toggle="tooltip" title="<%- file.name %>">
<a href="<%-file.downloadURL.replace("member","customer") %>" target ="_blank" class="uv-ticket-uploads-brick uv-no-pointer-events" data-toggle="tooltip" title="<%- file.name %>">
<img src="<%-file.iconURL %>" class="uv-auto-pointer-events">
</a>
<% }) %>
Expand Down
5 changes: 3 additions & 2 deletions Resources/views/Staff/Announcement/listAnnouncement.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@

<script type="text/javascript">
var path = "{{ path('helpdesk_member_knowledgebase_update_marketing_announcement', {'announcementId': 'replaceId' }) }}";
var deletePath = "{{ path('helpdesk_member_knowledgebase_remove_marketing_announcement_xhr', { 'announcementId': 'replaceId' }) }}";
$(function () {
var globalMessageResponse = "";
Expand Down Expand Up @@ -208,7 +209,7 @@
app.appView.showLoader();
self = this;
this.model.destroy({
url : "{{ path('helpdesk_member_knowledgebase_remove_marketing_announcement_xhr') }}/"+this.model.get('announcementId'),
url: deletePath.replace('replaceId', this.model.get('id')),
success : function (model, response, options) {
app.appView.hideLoader();
globalMessageResponse = response;
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Staff/Articles/articleForm.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@
$(".uv-tabs li").removeClass('uv-tab-error')
currentElement = Backbone.$(e.currentTarget);
this.model.clear();
let formData = this.$el.find('form#article-form').serializeFormObject();
let formData = this.$el.find('form#article-form').serializeObject();
this.model.set(formData);
self = this;
var contentNotHasError = this.validateForm(e);
Expand Down
6 changes: 5 additions & 1 deletion Resources/views/Templates/layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
<html lang="{{app.request.getLocale()}}">
<head>
<link rel="stylesheet" href="{{ asset('bundles/uvdesksupportcenter/css/knowledgebase.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.1/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.4.0/backbone-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.validation/0.11.5/backbone-validation-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.paginator/2.0.8/backbone.paginator.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>


<script src="{{ asset('bundles/uvdesksupportcenter/js/_common.js') }}"></script>
<script src = "{{ asset('bundles/uvdesksupportcenter/js/uikit.front.js') }}"></script>
Expand All @@ -27,7 +31,7 @@
{% endif %}

{% if websiteDetails %}
<title>{% block title %}{% trans %}HelpDesk{% endtrans %} {{ websiteDetails.name ? websiteDetails.name : 'Knowledge Base'|trans }} {% endblock %}</title>
<title>{% block title %}{{ websiteDetails.name ? websiteDetails.name : 'Knowledge Base'|trans }} {% endblock %}</title>
{% if websiteConfiguration.metaDescription %}
<meta name="description" content="{% block metaDescription %}{{ websiteConfiguration.metaDescription }}{% endblock %}"/>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.3 || ^8.0",
"uvdesk/composer-plugin": "^1.0",
"uvdesk/core-framework": "^1.0.4"
},
Expand Down

0 comments on commit 8474e57

Please sign in to comment.