Add cc/bcc to rest API, re-enable in email_functions
This commit is contained in:
parent
904202488d
commit
81b27ddb2e
@ -543,39 +543,6 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
<?php echo $hesklang['bcc']; ?>
|
<?php echo $hesklang['bcc']; ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
|
||||||
$('input[name="email_type"]').change(function() {
|
|
||||||
if ($('input[name="email_type"]:checked').val() === 'none') {
|
|
||||||
$('#emails_to_receive').hide();
|
|
||||||
} else {
|
|
||||||
$('#emails_to_receive').show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group" id="emails_to_receive" style="display: <?php if ($address_type === 'none') {echo 'none';} else {echo 'block';} ?>">
|
|
||||||
<label for="staff_or_customer" class="col-sm-4 control-label">
|
|
||||||
<?php echo $hesklang['emails_to_receive']; ?>
|
|
||||||
</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<?php
|
|
||||||
$emails_to_receive = empty($value['emails_to_receive']) ? array() : $value['emails_to_receive'];
|
|
||||||
?>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" name="emails_to_receive[]" value="STAFF"
|
|
||||||
<?php if (in_array('STAFF', $emails_to_receive)) {echo 'checked';} ?>>
|
|
||||||
<?php echo $hesklang['emails_sent_to_staff']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" name="emails_to_receive[]" value="CUSTOMER"
|
|
||||||
<?php if (in_array('CUSTOMER', $emails_to_receive)) {echo 'checked';} ?>>
|
|
||||||
<?php echo $hesklang['emails_sent_to_customer']; ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1285,8 +1252,7 @@ function cf_validate()
|
|||||||
case 'email':
|
case 'email':
|
||||||
$cf['email_multi'] = hesk_POST('email_multi') ? 1 : 0;
|
$cf['email_multi'] = hesk_POST('email_multi') ? 1 : 0;
|
||||||
$cf['email_type'] = hesk_POST('email_type', 'none');
|
$cf['email_type'] = hesk_POST('email_type', 'none');
|
||||||
$cf['emails_to_receive'] = $cf['email_type'] === 'none' ? array() : hesk_POST_array('emails_to_receive', array());
|
$cf['value'] = array('multiple' => $cf['email_multi'], 'email_type' => $cf['email_type']);
|
||||||
$cf['value'] = array('multiple' => $cf['email_multi'], 'email_type' => $cf['email_type'], 'emails_to_receive' => $cf['emails_to_receive']);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'hidden':
|
case 'hidden':
|
||||||
|
@ -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();
|
||||||
}
|
}
|
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[$hesk_settings['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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user