Merge branch '520-email-custom-field' into '3-3-0'
Resolve "cc/bcc Email Custom Fields Not Being Appended To Sent Emails" See merge request mike-koch/Mods-for-HESK!93
This commit is contained in:
commit
559f2d7011
@ -519,7 +519,9 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
<?php echo $hesklang['email_custom_field_label']; ?>
|
<?php echo $hesklang['email_custom_field_label']; ?>
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<?php $address_type = empty($value['email_type']) ? 'none' : $value['email_type']; ?>
|
<?php
|
||||||
|
$address_type = empty($value['email_type']) ? 'none' : $value['email_type'];
|
||||||
|
?>
|
||||||
<div class="radio">
|
<div class="radio">
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="email_type" value="none"
|
<input type="radio" name="email_type" value="none"
|
||||||
|
@ -12,10 +12,10 @@ class Addressees extends \BaseClass {
|
|||||||
/**
|
/**
|
||||||
* @var $cc string[]|null
|
* @var $cc string[]|null
|
||||||
*/
|
*/
|
||||||
public $cc;
|
public $cc = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var $bcc string[]|null
|
* @var $bcc string[]|null
|
||||||
*/
|
*/
|
||||||
public $bcc;
|
public $bcc = array();
|
||||||
}
|
}
|
@ -10,9 +10,11 @@ use PHPMailer;
|
|||||||
class BasicEmailSender extends \BaseClass implements EmailSender {
|
class BasicEmailSender extends \BaseClass implements EmailSender {
|
||||||
|
|
||||||
function sendEmail($emailBuilder, $heskSettings, $modsForHeskSettings, $sendAsHtml) {
|
function sendEmail($emailBuilder, $heskSettings, $modsForHeskSettings, $sendAsHtml) {
|
||||||
if (preg_match("/\n|\r|\t|%0A|%0D|%08|%09/", $emailBuilder->to . $emailBuilder->subject)) {
|
foreach ($emailBuilder->to as $to) {
|
||||||
|
if (preg_match("/\n|\r|\t|%0A|%0D|%08|%09/", $to . $emailBuilder->subject)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$mailer = new PHPMailer();
|
$mailer = new PHPMailer();
|
||||||
|
|
||||||
|
17
api/BusinessLogic/Tickets/CustomFields/CustomField.php
Normal file
17
api/BusinessLogic/Tickets/CustomFields/CustomField.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
namespace BusinessLogic\Tickets\CustomFields;
|
||||||
|
|
||||||
|
|
||||||
|
class CustomField {
|
||||||
|
/* @var $id int */
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/* @var $name string */
|
||||||
|
public $name;
|
||||||
|
|
||||||
|
/* @var $type string */
|
||||||
|
public $type;
|
||||||
|
|
||||||
|
/* @var $properties array */
|
||||||
|
public $properties;
|
||||||
|
}
|
@ -9,6 +9,7 @@ use BusinessLogic\Emails\EmailTemplateRetriever;
|
|||||||
use BusinessLogic\Exceptions\ValidationException;
|
use BusinessLogic\Exceptions\ValidationException;
|
||||||
use BusinessLogic\Statuses\DefaultStatusForAction;
|
use BusinessLogic\Statuses\DefaultStatusForAction;
|
||||||
use DataAccess\AuditTrail\AuditTrailGateway;
|
use DataAccess\AuditTrail\AuditTrailGateway;
|
||||||
|
use DataAccess\CustomFields\CustomFieldsGateway;
|
||||||
use DataAccess\Security\UserGateway;
|
use DataAccess\Security\UserGateway;
|
||||||
use DataAccess\Settings\ModsForHeskSettingsGateway;
|
use DataAccess\Settings\ModsForHeskSettingsGateway;
|
||||||
use DataAccess\Statuses\StatusGateway;
|
use DataAccess\Statuses\StatusGateway;
|
||||||
@ -61,6 +62,9 @@ class TicketCreator extends \BaseClass {
|
|||||||
/* @var $auditTrailGateway AuditTrailGateway */
|
/* @var $auditTrailGateway AuditTrailGateway */
|
||||||
private $auditTrailGateway;
|
private $auditTrailGateway;
|
||||||
|
|
||||||
|
/* @var $customFieldsGateway CustomFieldsGateway */
|
||||||
|
private $customFieldsGateway;
|
||||||
|
|
||||||
function __construct(NewTicketValidator $newTicketValidator,
|
function __construct(NewTicketValidator $newTicketValidator,
|
||||||
TrackingIdGenerator $trackingIdGenerator,
|
TrackingIdGenerator $trackingIdGenerator,
|
||||||
Autoassigner $autoassigner,
|
Autoassigner $autoassigner,
|
||||||
@ -70,7 +74,8 @@ class TicketCreator extends \BaseClass {
|
|||||||
EmailSenderHelper $emailSenderHelper,
|
EmailSenderHelper $emailSenderHelper,
|
||||||
UserGateway $userGateway,
|
UserGateway $userGateway,
|
||||||
ModsForHeskSettingsGateway $modsForHeskSettingsGateway,
|
ModsForHeskSettingsGateway $modsForHeskSettingsGateway,
|
||||||
AuditTrailGateway $auditTrailGateway) {
|
AuditTrailGateway $auditTrailGateway,
|
||||||
|
CustomFieldsGateway $customFieldsGateway) {
|
||||||
$this->newTicketValidator = $newTicketValidator;
|
$this->newTicketValidator = $newTicketValidator;
|
||||||
$this->trackingIdGenerator = $trackingIdGenerator;
|
$this->trackingIdGenerator = $trackingIdGenerator;
|
||||||
$this->autoassigner = $autoassigner;
|
$this->autoassigner = $autoassigner;
|
||||||
@ -81,6 +86,7 @@ class TicketCreator extends \BaseClass {
|
|||||||
$this->userGateway = $userGateway;
|
$this->userGateway = $userGateway;
|
||||||
$this->modsForHeskSettingsGateway = $modsForHeskSettingsGateway;
|
$this->modsForHeskSettingsGateway = $modsForHeskSettingsGateway;
|
||||||
$this->auditTrailGateway = $auditTrailGateway;
|
$this->auditTrailGateway = $auditTrailGateway;
|
||||||
|
$this->customFieldsGateway = $customFieldsGateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,6 +168,19 @@ class TicketCreator extends \BaseClass {
|
|||||||
$addressees = new Addressees();
|
$addressees = new Addressees();
|
||||||
$addressees->to = $ticket->email;
|
$addressees->to = $ticket->email;
|
||||||
|
|
||||||
|
foreach ($ticket->customFields as $key => $value) {
|
||||||
|
$customField = $this->customFieldsGateway->getCustomField($key, $heskSettings);
|
||||||
|
if ($customField !== null &&
|
||||||
|
$customField->type === 'email' &&
|
||||||
|
$customField->properties['email_type'] !== 'none') {
|
||||||
|
if ($customField->properties['email_type'] === 'cc') {
|
||||||
|
$addressees->cc[] = $value;
|
||||||
|
} elseif ($customField->properties['email_type'] === 'bcc') {
|
||||||
|
$addressees->bcc[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($ticketRequest->sendEmailToCustomer && $emailVerified) {
|
if ($ticketRequest->sendEmailToCustomer && $emailVerified) {
|
||||||
$this->emailSenderHelper->sendEmailForTicket(EmailTemplateRetriever::NEW_TICKET, $ticketRequest->language, $addressees, $ticket, $heskSettings, $modsForHeskSettings);
|
$this->emailSenderHelper->sendEmailForTicket(EmailTemplateRetriever::NEW_TICKET, $ticketRequest->language, $addressees, $ticket, $heskSettings, $modsForHeskSettings);
|
||||||
} else if ($modsForHeskSettings['customer_email_verification_required'] && !$emailVerified) {
|
} else if ($modsForHeskSettings['customer_email_verification_required'] && !$emailVerified) {
|
||||||
|
@ -11,7 +11,7 @@ class CommonDao extends \BaseClass {
|
|||||||
*/
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
if (!function_exists('hesk_dbConnect')) {
|
if (!function_exists('hesk_dbConnect')) {
|
||||||
throw new Exception('Database not loaded!');
|
throw new \BaseException('Database not loaded!');
|
||||||
}
|
}
|
||||||
hesk_dbConnect();
|
hesk_dbConnect();
|
||||||
}
|
}
|
||||||
|
26
api/DataAccess/CustomFields/CustomFieldsGateway.php
Normal file
26
api/DataAccess/CustomFields/CustomFieldsGateway.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
namespace DataAccess\CustomFields;
|
||||||
|
|
||||||
|
use BusinessLogic\Tickets\CustomFields\CustomField;
|
||||||
|
use DataAccess\CommonDao;
|
||||||
|
|
||||||
|
class CustomFieldsGateway extends CommonDao {
|
||||||
|
public function getCustomField($id, $heskSettings) {
|
||||||
|
$this->init();
|
||||||
|
|
||||||
|
$rs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_fields` WHERE `id` = " . intval($id));
|
||||||
|
|
||||||
|
if ($row = hesk_dbFetchAssoc($rs)) {
|
||||||
|
$customField = new CustomField();
|
||||||
|
$customField->id = $row['id'];
|
||||||
|
$names = json_decode($row['name'], true);
|
||||||
|
$customField->name = (isset($names[$heskSettings['language']])) ? $names[$heskSettings['language']] : reset($names);
|
||||||
|
$customField->type = $row['type'];
|
||||||
|
$customField->properties = json_decode($row['value'], true);
|
||||||
|
|
||||||
|
return $customField;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -50,20 +50,19 @@ function hesk_notifyCustomerForVerifyEmail($email_template = 'verify_email', $ac
|
|||||||
$ccEmails = array();
|
$ccEmails = array();
|
||||||
$bccEmails = array();
|
$bccEmails = array();
|
||||||
|
|
||||||
//TODO Update the email custom field to handle this properly
|
foreach ($hesk_settings['custom_fields'] as $k => $v) {
|
||||||
/*foreach ($hesk_settings['custom_fields'] as $k => $v) {
|
|
||||||
if ($v['use']) {
|
if ($v['use']) {
|
||||||
if ($v['type'] == 'email' && !empty($ticket[$k])) {
|
if ($v['type'] == 'email' && !empty($ticket[$k])) {
|
||||||
if ($v['value'] == 'cc') {
|
if ($v['value']['email_type'] == 'cc') {
|
||||||
$emails = explode(',', $ticket[$k]);
|
$emails = explode(',', $ticket[$k]);
|
||||||
array_push($ccEmails, $emails);
|
array_push($ccEmails, $emails);
|
||||||
} elseif ($v['value'] == 'bcc') {
|
} elseif ($v['value']['email_type'] == 'bcc') {
|
||||||
$emails = explode(',', $ticket[$k]);
|
$emails = explode(',', $ticket[$k]);
|
||||||
array_push($bccEmails, $emails);
|
array_push($bccEmails, $emails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
hesk_mail($ticket['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, $ccEmails, $bccEmails, $hasMessage);
|
hesk_mail($ticket['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, $ccEmails, $bccEmails, $hasMessage);
|
||||||
}
|
}
|
||||||
@ -95,18 +94,19 @@ function hesk_notifyCustomer($modsForHesk_settings, $email_template = 'new_ticke
|
|||||||
$ccEmails = array();
|
$ccEmails = array();
|
||||||
$bccEmails = array();
|
$bccEmails = array();
|
||||||
|
|
||||||
//TODO Update the email custom field to handle this properly
|
foreach ($hesk_settings['custom_fields'] as $k => $v) {
|
||||||
/*foreach ($hesk_settings['custom_fields'] as $k => $v) {
|
|
||||||
if ($v['use']) {
|
if ($v['use']) {
|
||||||
if ($v['type'] == 'email' && !empty($ticket[$k])) {
|
if ($v['type'] == 'email' && !empty($ticket[$k]) && isset($v['value']['emails_to_receive'])) {
|
||||||
if ($v['value'] == 'cc') {
|
if ($v['value']['email_type'] == 'cc') {
|
||||||
array_push($ccEmails, $ticket[$k]);
|
$emails = explode(',', $ticket[$k]);
|
||||||
} elseif ($v['value'] == 'bcc') {
|
array_push($ccEmails, $emails);
|
||||||
array_push($bccEmails, $ticket[$k]);
|
} elseif ($v['value']['email_type'] == 'bcc') {
|
||||||
|
$emails = explode(',', $ticket[$k]);
|
||||||
|
array_push($bccEmails, $emails);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
// Send e-mail
|
// Send e-mail
|
||||||
hesk_mail($ticket['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, $ccEmails, $bccEmails, $hasMessage);
|
hesk_mail($ticket['email'], $subject, $message, $htmlMessage, $modsForHesk_settings, $ccEmails, $bccEmails, $hasMessage);
|
||||||
|
@ -2239,6 +2239,9 @@ $hesklang['highlight_ticket_rows_based_on_priority'] = 'Highlight ticket rows ba
|
|||||||
$hesklang['highlight_ticket_rows_based_on_priority_help'] = 'If enabled, each ticket on the tickets page will be highlighted based on priority. If disabled, only * Critical * and High priority tickets will be highlighted.';
|
$hesklang['highlight_ticket_rows_based_on_priority_help'] = 'If enabled, each ticket on the tickets page will be highlighted based on priority. If disabled, only * Critical * and High priority tickets will be highlighted.';
|
||||||
$hesklang['highlight_ticket_rows_based_on_priority_descr'] = 'Highlight all ticket rows based on priority';
|
$hesklang['highlight_ticket_rows_based_on_priority_descr'] = 'Highlight all ticket rows based on priority';
|
||||||
$hesklang['protected_group'] = 'This is a protected group; you cannot change accessible categories / features.';
|
$hesklang['protected_group'] = 'This is a protected group; you cannot change accessible categories / features.';
|
||||||
|
$hesklang['emails_to_receive'] = 'Emails to receive';
|
||||||
|
$hesklang['emails_sent_to_staff'] = 'Emails sent to staff';
|
||||||
|
$hesklang['emails_sent_to_customer'] = 'Emails sent to customer';
|
||||||
|
|
||||||
// DO NOT CHANGE BELOW
|
// DO NOT CHANGE BELOW
|
||||||
if (!defined('IN_SCRIPT')) die('PHP syntax OK!');
|
if (!defined('IN_SCRIPT')) die('PHP syntax OK!');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user