Merge branch 'application_submit' into 'develop'

HelpDesk controller. Email setup

See merge request !185
parents df2a2a8d e2bdd9a5
...@@ -56,5 +56,10 @@ function epal_mail($key, &$message, $params) { ...@@ -56,5 +56,10 @@ function epal_mail($key, &$message, $params) {
$message['subject'] = t('Ικανοποίηση ηλεκτρονικής δήλωσης προτίμησης ΕΠΑΛ', $options); $message['subject'] = t('Ικανοποίηση ηλεκτρονικής δήλωσης προτίμησης ΕΠΑΛ', $options);
$message['body'][] = $params['message']; $message['body'][] = $params['message'];
break; break;
case 'help_desk':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('Σύστημα υποβολής ηλεκτρονικών δηλώσεων προτίμησης ΕΠΑΛ για το νέο σχολικό έτος: Αίτημα Υποστήριξης', $options);
$message['body'][] = $params['message'];
break;
} }
} }
...@@ -31,7 +31,7 @@ class HelpDesk extends ControllerBase { ...@@ -31,7 +31,7 @@ class HelpDesk extends ControllerBase {
public function __construct( public function __construct(
EntityTypeManagerInterface $entityTypeManager, EntityTypeManagerInterface $entityTypeManager,
LoggerChannelFactoryInterface $loggerChannel, LoggerChannelFactoryInterface $loggerChannel,
Connection $connection Connection $connection
) { ) {
$this->entityTypeManager = $entityTypeManager; $this->entityTypeManager = $entityTypeManager;
...@@ -68,17 +68,14 @@ class HelpDesk extends ControllerBase { ...@@ -68,17 +68,14 @@ class HelpDesk extends ControllerBase {
"message" => t("Method Not Allowed") "message" => t("Method Not Allowed")
], Response::HTTP_METHOD_NOT_ALLOWED); ], Response::HTTP_METHOD_NOT_ALLOWED);
} }
$postData = null; $postData = null;
if ($content = $request->getContent()) { if ($content = $request->getContent()) {
$postData = json_decode($content); $postData = json_decode($content);
$this->sendEmailwithcommets($postData->userEmail, $postData->userName, $postData->userMessage,$postData->userSurname); $this->sendEmailToHelpDesk($postData->userEmail, $postData->userName, $postData->userMessage,$postData->userSurname);
return $this->respondWithStatus([ return $this->respondWithStatus([
'userEmail' => $postData->userEmail, 'error_code' => 0,
'name' => $postData->userName,
'surname' => $postData->userSurname,
'message' => $postData->userMessage,
], Response::HTTP_OK); ], Response::HTTP_OK);
} }
else { else {
...@@ -90,16 +87,14 @@ class HelpDesk extends ControllerBase { ...@@ -90,16 +87,14 @@ class HelpDesk extends ControllerBase {
} }
private function sendEmailwithcommets($email, $name, $cont_message, $surname) { private function sendEmailToHelpDesk($email, $name, $cont_message, $surname) {
$mailManager = \Drupal::service('plugin.manager.mail'); $mailManager = \Drupal::service('plugin.manager.mail');
$module = 'HelpDesk'; $module = 'epal';
$key = 'send_mail'; $key = 'help_desk';
$to = 'aspakatsi@yahoo.gr'; $to = 'dialogos_eek@minedu.gov.gr';
$params['message'] = 'Αποστολέας:'.$email.'Όνομα:'.$name.'Επωνυμο:'.$surname.'Μήνυμα:'.$cont_message; $params['message'] = '<p>Αποστολέας:'.$email.'</p><p>Όνομα: '.$name.'</p><p>Επώνυμο: '.$surname.'</p><p>Μήνυμα: '.$cont_message .'</p>';
$langcode = 'el'; $langcode = 'el';
$send = true; $send = true;
...@@ -109,7 +104,7 @@ class HelpDesk extends ControllerBase { ...@@ -109,7 +104,7 @@ class HelpDesk extends ControllerBase {
$this->logger->info("Mail Sent successfully."); $this->logger->info("Mail Sent successfully.");
} }
else { else {
$this->logger->info("There is error in sending mail."); $this->logger->info("There was an error in sending mail.");
} }
return; return;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment