Getting started on email retrieval/parsing

remotes/upstream/api-rewrite
Mike Koch 7 years ago
parent 4c7449ea3e
commit b53e9aafd7

@ -0,0 +1,48 @@
<?php
/**
* Created by PhpStorm.
* User: mkoch
* Date: 2/22/2017
* Time: 9:11 PM
*/
namespace BusinessLogic\Emails;
use BusinessLogic\Exceptions\EmailTemplateNotFoundException;
class EmailTemplateRetriever {
function getTemplateForLanguage($templateName, $language) {
}
private function getFromFileSystem($template, $language)
{
global $hesk_settings, $hesklang;
// Demo mode
if (defined('HESK_DEMO')) {
return '';
}
/* Get list of valid emails */
$valid_emails = hesk_validEmails();
/* Verify this is a valid email include */
if (!isset(ValidEmailTemplates::getValidEmailTemplates()[$template])) {
hesk_error($hesklang['inve']);
}
/* Get email template */
$file = 'language/' . $language . '/emails/' . $template . '.txt';
$absoluteFilePath = __DIR__ . '/../../../' . $file;
if (file_exists($absoluteFilePath)) {
return file_get_contents($absoluteFilePath);
} else {
throw new EmailTemplateNotFoundException($template, $language);
}
}
}

@ -0,0 +1,31 @@
<?php
/**
* Created by PhpStorm.
* User: mkoch
* Date: 2/22/2017
* Time: 9:25 PM
*/
namespace BusinessLogic\Emails;
class ValidEmailTemplates {
static function getValidEmailTemplates() {
return array(
'forgot_ticket_id' => 'forgot_ticket_id',
'new_reply_by_staff' => 'new_reply_by_staff',
'new_ticket' => 'ticket_received',
'verify_email' => 'verify_email',
'ticket_closed' => 'ticket_closed',
'category_moved' => 'category_moved',
'new_reply_by_customer' => 'new_reply_by_customer',
'new_ticket_staff' => 'new_ticket_staff',
'ticket_assigned_to_you' => 'ticket_assigned_to_you',
'new_pm' => 'new_pm',
'new_note' => 'new_note',
'reset_password' => 'reset_password',
'calendar_reminder' => 'calendar_reminder',
'overdue_ticket' => 'overdue_ticket',
);
}
}

@ -0,0 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: mkoch
* Date: 2/22/2017
* Time: 10:00 PM
*/
namespace BusinessLogic\Exceptions;
class EmailTemplateNotFoundException extends ApiFriendlyException {
function __construct($emailTemplate, $language) {
parent::__construct(sprintf("The email template '%s' was not found for the language '%s'", $emailTemplate, $language),
'Email Template Not Found!', 400);
}
}
Loading…
Cancel
Save