Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into HEAD
  • Loading branch information
akshay kumar committed Oct 22, 2019
2 parents 9abd8bf + ebed41b commit 9171fa4
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 200 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This changelog references any relevant changes introduced in 1.0 minor versions.
* 1.0.1 (2019-10-15)
* **Issue #79:** User profile gets hidden
* **Issue #75:** Profile issue inside ticket page
* **Misc. Updates:**
* Updated README.md with link to the official gitter chat for uvdesk/support-center-bundle

* 1.0.0 (Released on 2019-10-09)
* **Issue #76:** tinymce text editor added for article section. (raised by papnoisanjeev)
Expand Down
136 changes: 21 additions & 115 deletions Controller/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

namespace Webkul\UVDesk\SupportCenterBundle\Controller;

use Webkul\UVDesk\CoreFrameworkBundle\Entity\User;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use Webkul\UVDesk\CoreFrameworkBundle\Form\UserProfile;
use Webkul\UVDesk\CoreFrameworkBundle\Utils\TokenGenerator;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\User;
use Symfony\Component\EventDispatcher\GenericEvent;
use Webkul\UVDesk\CoreFrameworkBundle\Form\UserProfile;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Webkul\UVDesk\CoreFrameworkBundle\Workflow\Events as CoreWorkflowEvents;
use Webkul\UVDesk\CoreFrameworkBundle\Utils\TokenGenerator;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Webkul\UVDesk\SupportCenterBundle\Entity\KnowledgebaseWebsite;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Website as CoreWebsite;

Class Customer extends Controller
{
Expand All @@ -22,22 +24,25 @@ protected function redirectUserToLogin()

protected function isWebsiteActive()
{
$error = false;
$entityManager = $this->getDoctrine()->getManager();
$website = $entityManager->getRepository(CoreWebsite::class)->findOneByCode('knowledgebase');

if (!empty($website)) {
$knowledgebaseWebsite = $entityManager->getRepository(KnowledgebaseWebsite::class)->findOneBy(['website' => $website->getId(), 'status' => 1]);

if (!empty($knowledgebaseWebsite) && true == $knowledgebaseWebsite->getIsActive()) {
return true;
}
}

if($error)
$this->noResultFound();
$this->noResultFound();
}

protected function noResultFound()
{
throw new NotFoundHttpException('Permission Denied !');
}

protected function encodePassword(User $user, $plainPassword)
{
return $encodedPassword = $this->container->get('security.password_encoder')->encodePassword($user, $plainPassword);
}

protected function isLoginDisabled()
{
$entityManager = $this->getDoctrine()->getManager();
Expand All @@ -59,8 +64,11 @@ protected function isLoginDisabled()

public function login(Request $request)
{
if($this->redirectUserToLogin())
$this->isWebsiteActive();

if ($this->redirectUserToLogin()) {
return $this->redirect($this->generateUrl('helpdesk_customer_ticket_collection')); // Replace with Dashboard route
}

/** check disabled customer login **/
if($this->isLoginDisabled()) {
Expand Down Expand Up @@ -89,108 +97,6 @@ public function login(Request $request)
]);
}

public function forgotPassword(Request $request)
{
if ($this->isLoginDisabled()) {
$this->addFlash('warning', $this->get('translator')->trans('Warning ! Customer Login disabled by admin.'));
return $this->redirect($this->generateUrl('webkul_support_center_front_solutions'));
}

if ($request->getMethod() == 'POST') {
$entityManager = $this->getDoctrine()->getManager();
$user = new User();
$data = $request->request->all();
$repository = $this->getDoctrine()->getRepository('UVDeskCoreFrameworkBundle:User');
$user = $entityManager->getRepository('UVDeskCoreFrameworkBundle:User')->findOneBy(array('email' => $data['email']));

if ($user) {
$key = time();

// Trigger agent forgot event
$event = new GenericEvent(CoreWorkflowEvents\Customer\ForgotPassword::getId(), [
'entity' => $user,
]);

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

$request->getSession()->getFlashBag()->set(
'success',
$this->get('translator')->trans('Please check your mail for password update.')
);

return $this->redirect($this->generateUrl('helpdesk_customer_login'));
//@TODO: NEEDS TO SEND EMAIL FOR CHANGE PASSWORD URL.
} else {
$request->getSession()->getFlashBag()->set(
'warning',
$this->get('translator')->trans('This Email is not registered with us.')
);
}
}

return $this->render('@UVDeskSupportCenter/Knowledgebase/forgotPassword.html.twig', [
'searchDisable' => true,
'breadcrumbs' => [
[
'label' => $this->get('translator')->trans('Support Center'),
'url' => $this->generateUrl('helpdesk_knowledgebase')
],
['label' => $this->get('translator')->trans('Forgot Password'), 'url' => '#']
]
]);
}


public function updateCredentials($email, $verificationCode)
{
if ($this->isLoginDisabled() || (empty($email) || empty($verificationCode))) {
return $this->redirect($this->generateUrl('helpdesk_knowledgebase'));
}

$entityManager = $this->getDoctrine()->getManager();
$request = $this->get('request_stack')->getCurrentRequest();

// Validate request
$user = $entityManager->getRepository('UVDeskCoreFrameworkBundle:User')->findOneByEmail($email);

if (empty($user) || null == $user->getCustomerInstance() || $user->getVerificationCode() != $verificationCode) {
return $this->redirect($this->generateUrl('helpdesk_knowledgebase'));
}

if ($request->getMethod() == 'POST') {
$updatedCredentials = $request->request->all();

if ($updatedCredentials['password'] === $updatedCredentials['confirmPassword']) {
$user->setPassword($this->encodePassword($user, $updatedCredentials['password']));
$user->setVerificationCode(TokenGenerator::generateToken());

$entityManager->persist($user);
$entityManager->flush();

$request->getSession()->getFlashBag()->set('success', 'Your password has been updated successfully.');
return $this->redirect($this->generateUrl('helpdesk_customer_login'));
} else {
$request->getSession()->getFlashBag()->set(
'warning',
$this->get('translator')->trans('Password don\'t match.')
);
}
}

return $this->render('@UVDeskSupportCenter/Knowledgebase/resetPassword.html.twig', [
'searchDisable' => true,
'breadcrumbs' => [
[
'label' => $this->get('translator')->trans('Support Center'),
'url' => 'helpdesk_knowledgebase'
], [
'label' => $this->get('translator')->trans('Account Validation'),
'url' => '#'
]
]
]);
}

public function Account(Request $request)
{
$this->isWebsiteActive();
Expand Down
31 changes: 17 additions & 14 deletions Controller/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,33 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\EventDispatcher\GenericEvent;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Thread;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Website;
use Symfony\Component\Validator\Constraints\DateTime;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\TicketRating;
use Webkul\UVDesk\SupportCenterBundle\Form\Ticket as TicketForm;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Webkul\UVDesk\SupportCenterBundle\Entity\KnowledgebaseWebsite;
use Webkul\UVDesk\CoreFrameworkBundle\Entity\Ticket as TicketEntity;
use Webkul\UVDesk\CoreFrameworkBundle\Workflow\Events as CoreWorkflowEvents;

class Ticket extends Controller
{
protected function isWebsiteActive()
{
$error = false;
$currentKnowledgebase = $this->getWebsiteDetails();

if (!$currentKnowledgebase) {
$this->noResultFound();
$entityManager = $this->getDoctrine()->getManager();
$website = $entityManager->getRepository(Website::class)->findOneByCode('knowledgebase');

if (!empty($website)) {
$knowledgebaseWebsite = $entityManager->getRepository(KnowledgebaseWebsite::class)->findOneBy(['website' => $website->getId(), 'status' => 1]);

if (!empty($knowledgebaseWebsite) && true == $knowledgebaseWebsite->getIsActive()) {
return true;
}
}
}

protected function getWebsiteDetails()
{
$knowledgebaseWebsite = $this->getDoctrine()->getManager()->getRepository('UVDeskCoreFrameworkBundle:Website')->findOneByCode('knowledgebase');

return $knowledgebaseWebsite;
$this->noResultFound();
}

/**
Expand All @@ -48,12 +49,14 @@ public function ticketadd(Request $request)
$this->isWebsiteActive();

$formErrors = $errors = array();
$websiteConfiguration = $this->get('uvdesk.service')->getActiveConfiguration($this->getWebsiteDetails()->getId());
$em = $this->getDoctrine()->getManager();
$website = $em->getRepository(Website::class)->findOneByCode('knowledgebase');
$websiteConfiguration = $this->get('uvdesk.service')->getActiveConfiguration($website->getId());

if(!$websiteConfiguration || !$websiteConfiguration->getTicketCreateOption() || ($websiteConfiguration->getLoginRequiredToCreate() && !$this->getUser()))
if (!$websiteConfiguration || !$websiteConfiguration->getTicketCreateOption() || ($websiteConfiguration->getLoginRequiredToCreate() && !$this->getUser())) {
return $this->redirect($this->generateUrl('helpdesk_knowledgebase'));
}

$em = $this->getDoctrine()->getManager();
$post = $request->request->all();

if($request->getMethod() == "POST") {
Expand Down
2 changes: 1 addition & 1 deletion Controller/Website.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private function isKnowledgebaseActive()
$website = $entityManager->getRepository(CoreWebsite::class)->findOneByCode('knowledgebase');

if (!empty($website)) {
$knowledgebaseWebsite = $entityManager->getRepository(KnowledgebaseWebsite::class)->findOneByWebsite($website->getId());
$knowledgebaseWebsite = $entityManager->getRepository(KnowledgebaseWebsite::class)->findOneBy(['website' => $website->getId(), 'status' => true]);

if (!empty($knowledgebaseWebsite) && true == $knowledgebaseWebsite->getIsActive()) {
return true;
Expand Down
1 change: 0 additions & 1 deletion Fixtures/EmailTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class EmailTemplates extends DoctrineFixture
{
private static $seeds = [
SupportCenterEmailTemplates\Customer\AccountCreated::class,
SupportCenterEmailTemplates\Customer\ForgotPassword::class,
];

public function load(ObjectManager $entityManager)
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
<img src="https://s3-ap-southeast-1.amazonaws.com/cdn.uvdesk.com/uvdesk/bundles/webkuldefault/images/uvdesk-wide.svg">
</a></p>

UVDeskSupportCenterBundle
--------------
<p align="center">
<a href="https://packagist.org/packages/uvdesk/support-center-bundle"><img src="https://poser.pugx.org/uvdesk/support-center-bundle/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/uvdesk/support-center-bundle"><img src="https://poser.pugx.org/uvdesk/support-center-bundle/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/uvdesk/support-center-bundle"><img src="https://poser.pugx.org/uvdesk/support-center-bundle/license.svg" alt="License"></a>
<a href="https://gitter.im/uvdesk/support-center-bundle"><img src="https://badges.gitter.im/uvdesk/support-center-bundle.svg" alt="connect on gitter"></a>
</p>

The **UVDeskSupportCenterBundle** introduces the Support Center portal to the [UVDesk Community][1] helpdesk, a nifty solution to provide your customers with an easy interface to manage their tickets and easily engage with your support staff. The Support Center also includes a Knowledgebase that can be easily managed by your support staff.

Expand Down
9 changes: 0 additions & 9 deletions Resources/config/routes/private-customers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ helpdesk_customer_account:
path: /account
controller: Webkul\UVDesk\SupportCenterBundle\Controller\Customer::Account

helpdesk_customer_forgot_password:
path: /forgot-password
controller: Webkul\UVDesk\SupportCenterBundle\Controller\Customer::forgotPassword

helpdesk_customer_update_account_credentials:
path: /update-credentials/{email}/{verificationCode}
controller: Webkul\UVDesk\SupportCenterBundle\Controller\Customer::updateCredentials
defaults: { email: 0, verificationCode: 0 }

# Customer ticket routing resources
helpdesk_customer_ticket_collection:
path: /tickets
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 @@ -27,7 +27,7 @@
<div class="uv-element-block">
<label class="uv-field-label">{{ 'Password'|trans }}</label>
<div class="uv-field-block uv-relative">
<a class="uv-forgot-pwd" href="{{ path('helpdesk_customer_forgot_password') }}" tabIndex="-1">{{ 'Forgot Password?'|trans }}</a>
<a class="uv-forgot-pwd" href="{{ path('helpdesk_forgot_account_password') }}" tabIndex="-1">{{ 'Forgot Password?'|trans }}</a>
<input class="uv-field" type="password" name="_password">
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/Knowledgebase/ticketList.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<% } else { %>
<img class="uv-table-agent" src="{{ asset(default_agent_image_path) }}" alt=""/>
<% } %>
<%- agent.name %>
<%- agent.firstName + ' ' + (agent.lastName == null ? '' : agent.lastName) %>
<% } else { %>
{{ 'Unassigned'|trans }}
<% } %>
Expand Down
12 changes: 10 additions & 2 deletions Resources/views/Templates/header.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
color: #2750C4;
text-decoration: none;
}
.uv-profile-block .uv-dropdown-list {
top: 72px;
.uv-profile-block .uv-bottom-right{
top: auto !important;
}
.uv-rtl header .uv-header-rt > span {
display: block;
Expand Down Expand Up @@ -49,6 +49,14 @@
color: {{ websiteConfiguration.linkHoverColor }} !important;
}
{% endif %}
{% if websiteConfiguration is defined and websiteConfiguration.articleTextColor is defined %}
.uv-paper-article .uv-paper-section > section > p {
color: {{ websiteConfiguration.articleTextColor }} !important;
}
.uv-paper-article .uv-paper-section > section > ul {
color: {{ websiteConfiguration.articleTextColor }} !important;
}
{% endif %}
.goog-te-gadget-simple .goog-te-menu-value, .goog-te-gadget-simple .goog-te-menu-value:hover {
color: #333!important;
}
Expand Down
54 changes: 0 additions & 54 deletions Templates/Email/Resources/Customer/ForgotPassword.php

This file was deleted.

0 comments on commit 9171fa4

Please sign in to comment.