Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tag1_d7es to version 7.x-1.2 #211

Open
wants to merge 1 commit into
base: default
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/pantheon/tag1_d7es/tag1_d7es.info
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ files[] = tests/tag1_d7es_fetch_url.test
files[] = tests/tag1_d7es_mail.test
files[] = tests/tag1_d7es_update.test

; Information added by Drupal.org packaging script on 2024-11-27
version = "7.x-1.1"
; Information added by Drupal.org packaging script on 2024-12-20
version = "7.x-1.2"
core = "7.x"
project = "tag1_d7es"
datestamp = "1732731772"
datestamp = "1734725574"
28 changes: 20 additions & 8 deletions modules/pantheon/tag1_d7es/tag1_d7es.module
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function tag1_d7es_preflight($site_id, $billing_email, $display_messages = FALSE

// Ensure the billing email address is provided.
if (!$billing_email) {
$config_error = 'Unable to send data because the billing email address is not provided.';
$config_error = 'Unable to send data because the customer email address is not provided.';
$message = "$config_error Please visit <a href='/admin/config/system/tag1-d7es'>the configuration page</a> to provide it.";
watchdog(
'tag1_d7es',
Expand All @@ -84,7 +84,7 @@ function tag1_d7es_preflight($site_id, $billing_email, $display_messages = FALSE
* Send data to Tag1.
*
* @param string $billing_email
* The primary billing email address, used for authentication.
* The primary account email address, used for authentication.
* @param array $data
* The data payload.
* @param bool $display_messages
Expand All @@ -97,7 +97,7 @@ function tag1_d7es_preflight($site_id, $billing_email, $display_messages = FALSE
*/
function _tag1_d7es_transmit($billing_email, $data, $display_messages = FALSE, $override_url = '') {
$url = $override_url ?: _tag1_d7es_get_endpoint();
$auth_token = base64_encode($billing_email);
$auth_token = _tag1_d7es_encode_email($billing_email);
$headers = array(
'Content-Type' => 'application/json',
'Authorization' => 'Basic ' . $auth_token,
Expand Down Expand Up @@ -126,7 +126,7 @@ function _tag1_d7es_transmit($billing_email, $data, $display_messages = FALSE, $
return TRUE;

case 403:
$message = 'Authentication error. Please review the billing address and API endpoint (if configured).';
$message = 'Authentication error. Please review the customer email address and API endpoint (if configured).';
watchdog(
'tag1_d7es',
$message,
Expand Down Expand Up @@ -164,13 +164,24 @@ function _tag1_d7es_transmit($billing_email, $data, $display_messages = FALSE, $
return FALSE;
}

/**
* Encode the email address.
*
* @param string $email
* The email address to encode.
*/
function _tag1_d7es_encode_email($email) {
$encodedEmail = \base64_encode($email);
return \strlen($encodedEmail) < 20 ? \str_pad($encodedEmail, 20, '!', \STR_PAD_RIGHT) : $encodedEmail;
}

/**
* Build the phone-home payload.
*
* @param string $site_id
* Pass the site ID if it's already known.
* @param string $billing_email
* Pass the billing email if it's already known.
* Pass the account email if it's already known.
*
* @return array
* The data array for the request.
Expand Down Expand Up @@ -308,15 +319,16 @@ function tag1_d7es_admin_form($form, $form_state) {
'#markup' => '<p>' . t("Configure this module to communicate with Tag1's D7ES service. Installation and use of this module constitutes your acceptance of and agreement to be bound by Tag1 Consulting Inc's Terms of Service and Privacy Policy, as published at <a href='https://d7es.tag1.com/'>D7ES.Tag1.com</a>") . '</p>',
);

// The billing email address is only needed for non-platform customers.
// The account (formerly billing) email address is only needed for non-
// platform customers.
$form['tag1_d7es_billing_email'] = array(
'#type' => 'textfield',
'#title' => t('Billing email address'),
'#title' => t('Customer email address'),
'#size' => 80,
'#maxlength' => 255,
'#default_value' => variable_get('tag1_d7es_billing_email', ''),
'#required' => TRUE,
'#description' => t('The primary billing email address.'),
'#description' => t('The email address of the customer account.'),
'#access' => !(tag1_d7es_detect_platform()),
);

Expand Down
Loading