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 Mar 17, 2020
2 parents 2d6f660 + 92b458a commit 249a9ee
Show file tree
Hide file tree
Showing 134 changed files with 1,122 additions and 302 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ CHANGELOG for 1.0.x

This changelog references any relevant changes introduced in 1.0 minor versions.

* 1.0.9 (2020-03-17)
* **Misc. Updates:**
* **Added Missing translation**

* **Bug Fixes:**
* **Issue #285:** No Ticket counts when login as another administrative account.
* **Issue #289:** Error when trying to open Email templates.
* **Issue #288:** Uploading image in branding showing tmp file doesn't exist.

* 1.0.8 (2020-02-12)
* **Misc. Updates:**
* **#175:** Set default article text color equals to black.
Expand Down
10 changes: 5 additions & 5 deletions Controller/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public function forgotPassword(Request $request)
]);

$this->get('event_dispatcher')->dispatch('uvdesk.automation.workflow.execute', $event);
$request->getSession()->getFlashBag()->set('success', 'Please check your mail for password update.');
$this->addFlash('success', $this->get('translator')->trans('Please check your mail for password update'));

return $this->redirect($this->generateUrl('helpdesk_knowledgebase'));

} else {
$request->getSession()->getFlashBag()->set('warning', 'This email address is not registered with us.');
$this->addFlash('warning', $this->get('translator')->trans('This email address is not registered with us'));
}
}
}
Expand All @@ -75,7 +75,7 @@ public function updateCredentials($email, $verificationCode, Request $request, U
$user = $entityManager->getRepository('UVDeskCoreFrameworkBundle:User')->findOneByEmail($email);

if (empty($user) || $user->getVerificationCode() != $verificationCode) {
$request->getSession()->getFlashBag()->set('warning', "You have already update password using this link if you wish to change password again click on forget password link here from login page!!");
$this->addFlash('success', $this->get('translator')->trans('You have already update password using this link if you wish to change password again click on forget password link here from login page'));

return $this->redirect($this->generateUrl('helpdesk_knowledgebase'));
}
Expand All @@ -90,11 +90,11 @@ public function updateCredentials($email, $verificationCode, Request $request, U
$entityManager->persist($user);
$entityManager->flush();

$request->getSession()->getFlashBag()->set('success', 'Your password has been successfully updated. Login using updated password');
$this->addFlash('success', $this->get('translator')->trans('Your password has been successfully updated. Login using updated password'));

return $this->redirect($this->generateUrl('helpdesk_knowledgebase'));
} else {
$request->getSession()->getFlashBag()->set('warning', "Please try again. The passwords do not match.");
$this->addFlash('success', $this->get('translator')->trans('Please try again, The passwords do not match'));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Controller/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ public function bookmarkCustomer(Request $request)
$em->persist($userInstance);
$em->flush();
$json['alertClass'] = 'success';
$json['message'] = 'unstarred Action Completed successfully';
$json['message'] = $this->get('translator')->trans('unstarred Action Completed successfully');
} else {
$userInstance->setIsStarred(1);
$em->persist($userInstance);
$em->flush();
$json['alertClass'] = 'success';
$json['message'] = 'starred Action Completed successfully';
$json['message'] = $this->get('translator')->trans('starred Action Completed successfully');
}
$response = new Response(json_encode($json));
$response->headers->set('Content-Type', 'application/json');
Expand Down
4 changes: 2 additions & 2 deletions Controller/CustomerXHR.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public function removeCustomerXHR(Request $request)
$this->get('event_dispatcher')->dispatch('uvdesk.automation.workflow.execute', $event);

$json['alertClass'] = 'success';
$json['alertMessage'] = ('Success ! Customer removed successfully.');
$json['alertMessage'] = $this->get('translator')->trans('Success ! Customer removed successfully.');
} else {
$json['alertClass'] = 'danger';
$json['alertMessage'] = ('Error ! Invalid customer id.');
$json['alertMessage'] = $this->get('translator')->trans('Error ! Invalid customer id.');
$json['statusCode'] = Response::HTTP_NOT_FOUND;
}
}
Expand Down
5 changes: 3 additions & 2 deletions Controller/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ public function templateForm(Request $request)
$entityManager->flush();

if ($request->attributes->get('template')) {
$message = 'Success! Template has been updated successfully.';
$message = $this->get('translator')->trans('Success! Template has been updated successfully.');
} else {
$message = 'Success! Template has been added successfully.';
$message = $this->get('translator')->trans('Success! Template has been added successfully.');

}

$this->addFlash('success', $message);
Expand Down
14 changes: 12 additions & 2 deletions Controller/EmailSettingsXHR.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@ class EmailSettingsXHR extends Controller
public function updateSettingsXHR(Request $request)
{
$filePath = $this->get('kernel')->getProjectDir() . '/config/packages/uvdesk.yaml';
$app_locales = 'en|fr|it'; //default app_locales values

foreach ( file($filePath) as $val) {
$exploded = explode(":", trim($val));
if($exploded[0] == 'app_locales' && ($app_locales != $exploded[1]))
{
$app_locales = trim($exploded[1]);
}
}

$supportEmailConfiguration = json_decode($request->getContent(), true);

$mailer_id = ( $supportEmailConfiguration['mailer_id'] == 'None Selected' ? '~' : $supportEmailConfiguration['mailer_id'] );

$file_content_array = strtr(require __DIR__ . "/../Templates/uvdesk.php", [
'{{ SUPPORT_EMAIL_ID }}' => $supportEmailConfiguration['id'],
'{{ SUPPORT_EMAIL_NAME }}' => $supportEmailConfiguration['name'],
'{{ SUPPORT_EMAIL_MAILER_ID }}' => $mailer_id,
'{{ SITE_URL }}' => $this->container->getParameter('uvdesk.site_url'),
'{{ APP_LOCALES }}' => $app_locales,
]);

// update uvdesk.yaml file
Expand All @@ -33,7 +43,7 @@ public function updateSettingsXHR(Request $request)
'name' => $supportEmailConfiguration['name'],
'mailer_id' => $supportEmailConfiguration['mailer_id'],
],
'alertMessage' => "Success ! Email settings are updated successfully.",
'alertMessage' => $this->get('translator')->trans('Success ! Email settings are updated successfully.'),
];

return new Response(json_encode($result), 200, ['Content-Type' => 'application/json']);
Expand Down
5 changes: 2 additions & 3 deletions Controller/Privilege.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function createPrivilege(Request $request)

$this->addFlash('success', $this->get('translator')->trans('Success ! Privilege information saved successfully.'));
return $this->redirect($this->generateUrl('helpdesk_member_privilege_collection'));

}

return $this->render('@UVDeskCoreFramework/Privileges/createSupportPrivelege.html.twig', [
Expand Down Expand Up @@ -78,8 +77,8 @@ public function editPrivilege($supportPrivilegeId)
$entityManager->persist($supportPrivilege);
$entityManager->flush();

$this->addFlash('success', 'Privilege updated successfully.');

$this->addFlash('success', $this->get('translator')->trans('Privilege updated successfully.'));
return $this->redirect($this->generateUrl('helpdesk_member_privilege_collection'));
}

Expand Down
2 changes: 1 addition & 1 deletion Controller/PrivilegeXHR.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function deletePrivilegeXHR($supportPrivilegeId)

return new Response(json_encode([
'alertClass' => 'success',
'alertMessage' => 'Support Privilege removed successfully.',
'alertMessage' => $this->get('translator')->trans('Support Privilege removed successfully'),
]), 200, ['Content-Type' => 'application/json']);
}
}
Expand Down
5 changes: 3 additions & 2 deletions Controller/SavedReplies.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public function updateSavedReplies(Request $request)
$em->persist($template);
$em->flush();

$this->addFlash('success', $request->attributes->get('template') ? 'Success! Reply has been updated successfully.': 'Success! Reply has been added successfully.');
$this->addFlash('success', $request->attributes->get('template') ? $this->get('translator')->trans('Success! Reply has been updated successfully.'): $this->get('translator')->trans('Success! Reply has been added successfully.'));

return $this->redirectToRoute('helpdesk_member_saved_replies');
}

Expand Down Expand Up @@ -153,7 +154,7 @@ public function savedRepliesXHR(Request $request)

$responseContent = [
'alertClass' => 'success',
'alertMessage' => 'Success! Saved Reply has been deleted successfully.'
'alertMessage' => $this->get('translator')->trans('Success! Saved Reply has been deleted successfully.')
];
}

Expand Down
5 changes: 2 additions & 3 deletions Controller/SwiftMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public function createMailerConfiguration(Request $request)

try {
$swiftmailer->writeSwiftMailerConfigurations($configurations);

$this->addFlash('success', 'SwiftMailer configuration created successfully.');
$this->addFlash('success', $this->get('translator')->trans('SwiftMailer configuration created successfully.'));
return new RedirectResponse($this->generateUrl('helpdesk_member_swiftmailer_settings'));
} catch (\Exception $e) {
$this->addFlash('warning', $e->getMessage());
Expand Down Expand Up @@ -78,7 +77,7 @@ public function updateMailerConfiguration($id, Request $request)
$swiftmailerConfigurations[$index] = $swiftmailerConfiguration;
$swiftmailerService->writeSwiftMailerConfigurations($swiftmailerConfigurations);

$this->addFlash('success', 'SwiftMailer configuration updated successfully.');
$this->addFlash('success', $this->get('translator')->trans('SwiftMailer configuration updated successfully.'));
return new RedirectResponse($this->generateUrl('helpdesk_member_swiftmailer_settings'));
}

Expand Down
4 changes: 2 additions & 2 deletions Controller/SwiftMailerXHR.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public function removeMailerConfiguration(Request $request)

return new JsonResponse([
'alertClass' => 'success',
'alertMessage' => 'Swiftmailer configuration removed successfully.',
'alertMessage' => $this->get('translator')->trans('Swiftmailer configuration removed successfully.'),
]);
}
}

return new JsonResponse([
'alertClass' => 'error',
'alertMessage' => 'No swiftmailer configurations found for mailer id: ' . $params['id'],
'alertMessage' => $this->get('translator')->trans('No swiftmailer configurations found for mailer id:') . $params['id'],
], 404);
}
}
3 changes: 2 additions & 1 deletion Controller/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public function createTeam(Request $request)
$em->persist($supportTeam);
$em->flush();

$this->addFlash('success', $this->translator->trans('Success ! Team information saved successfully.'));
$this->addFlash('success', $this->get('translator')->trans('Success ! Team information saved successfully.'));

return $this->redirect($this->generateUrl('helpdesk_member_support_team_collection'));
}

Expand Down
4 changes: 2 additions & 2 deletions Controller/TeamXHR.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public function deleteTeamXHR($supportTeamId, TranslatorInterface $translator)
if (!empty($supportTeam)) {
$entityManager->remove($supportTeam);
$entityManager->flush();

return new Response(json_encode([
'alertClass' => 'success',
'alertMessage' => $translator->trans('Support Team removed successfully.'),
'alertMessage' => $this->get('translator')->trans('Support Team removed successfully.'),
]), 200, ['Content-Type' => 'application/json']);
}
}
Expand Down
8 changes: 4 additions & 4 deletions Controller/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function saveThread($ticketId, Request $request)
$parsedMessage = str_replace(' ', '', $parsedMessage);

if (null == $parsedMessage) {
$this->addFlash('warning', "Reply content cannot be left blank.");
$this->addFlash('warning', $this->get('translator')->trans('Reply content cannot be left blank.'));
}

// @TODO: Validate file attachments
Expand Down Expand Up @@ -100,7 +100,7 @@ public function saveThread($ticketId, Request $request)
$this->get('event_dispatcher')->dispatch('uvdesk.automation.workflow.execute', $event);

// @TODO: Render response on the basis of event response (if propogation was stopped or not)
$request->getSession()->getFlashBag()->set('success', 'Note added to ticket successfully.');
$this->addFlash('success', $this->get('translator')->trans('Note added to ticket successfully.'));
break;
case 'reply':
$event = new GenericEvent(CoreWorkflowEvents\Ticket\AgentReply::getId(), [
Expand All @@ -111,7 +111,7 @@ public function saveThread($ticketId, Request $request)
$this->get('event_dispatcher')->dispatch('uvdesk.automation.workflow.execute', $event);

// @TODO: Render response on the basis of event response (if propogation was stopped or not)
$request->getSession()->getFlashBag()->set('success', 'Reply added to ticket successfully.');
$this->addFlash('success', $this->get('translator')->trans('Reply added to ticket successfully.'));
break;
case 'forward':
// Prepare headers
Expand Down Expand Up @@ -145,7 +145,7 @@ public function saveThread($ticketId, Request $request)
}

// @TODO: Render response on the basis of event response (if propogation was stopped or not)
$request->getSession()->getFlashBag()->set('success', 'Reply added to the ticket and forwarded successfully.');
$this->addFlash('success', $this->translator->trans('Reply added to the ticket and forwarded successfully.'));
break;
default:
break;
Expand Down
6 changes: 3 additions & 3 deletions Controller/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function saveTicket(Request $request)
return $this->redirect($this->generateUrl('helpdesk_member_ticket', ['ticketId' => $ticket->getId()]));
}
} else {
$request->getSession()->getFlashBag()->set('warning', 'Could not create ticket, invalid details.');
$this->addFlash('warning', $this->get('translator')->trans('Could not create ticket, invalid details.'));
}

return $this->redirect(!empty($referralURL) ? $referralURL : $this->generateUrl('helpdesk_member_ticket_collection'));
Expand Down Expand Up @@ -230,9 +230,9 @@ public function ticketType(Request $request)
$em->flush();

if (!$request->attributes->get('ticketTypeId')) {
$this->addFlash('success', sprintf('Success! Ticket type saved successfully.'));
$this->addFlash('success', $this->get('translator')->trans('Success! Ticket type saved successfully.'));
} else {
$this->addFlash('success', sprintf('Success! Ticket type updated successfully.'));
$this->addFlash('success', $this->get('translator')->trans('Success! Ticket type updated successfully.'));
}

return $this->redirect($this->generateUrl('helpdesk_member_ticket_type_collection'));
Expand Down
2 changes: 1 addition & 1 deletion Controller/TicketXHR.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function updateTicketAttributes($ticketId)

return new Response(json_encode([
'alertClass' => 'success',
'alertMessage' => 'Ticket assigned to support group ' . $supportGroup->getName(),
'alertMessage' => $this->get('translator')->trans('Ticket assigned to support group '). $supportGroup->getName(),
]), 200, ['Content-Type' => 'application/json']);
}
break;
Expand Down
54 changes: 54 additions & 0 deletions Dashboard/Segments/HomepageSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace Webkul\UVDesk\CoreFrameworkBundle\Dashboard\Segments;

use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\HttpFoundation\Request;

abstract class HomepageSection implements HomepageSectionInterface
{
private $collection = [];
Expand All @@ -25,4 +29,54 @@ public function getItemCollection() : array
{
return $this->collection;
}

public static function dynamicTranslation($data) : string
{
$request = Request::createFromGlobals();
$path = $request->getPathInfo();
$locale = explode("/", $path);
$translator = new Translator($locale[1]);

switch($locale[1])
{
case 'en':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../translations/messages.en.yml", 'en');
break;
case 'es':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../translations/messages.es.yml", 'es');
break;
case 'fr':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../translations/messages.fr.yml", 'fr');
break;
case 'da':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../translations/messages.da.yml", 'da');
break;
case 'de':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../translations/messages.de.yml", 'de');
break;
case 'it':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../translations/messages.it.yml", 'it');
break;
case 'ar':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../translations/messages.ar.yml", 'ar');
break;
case 'tr':
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../translations/messages.tr.yml", 'tr');
break;
default:
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml',__DIR__."/../../../../../../translations/messages.en.yml", 'en');
break;
}

return $translator->trans($data);
}
}
Loading

0 comments on commit 249a9ee

Please sign in to comment.