updated node_export, mimemail, menu_attributes

This commit is contained in:
Bachir Soussi Chiadmi
2016-11-05 17:09:40 +01:00
parent 2b028cf376
commit fdefc824d8
50 changed files with 1598 additions and 1555 deletions

View File

@@ -1,6 +1,22 @@
Mime Mail 7.x-1.x, xxxx-xx-xx
-----------------------
Mime Mail 7.x-1.0-beta4, 2015-08-02
-----------------------
- #2413495 by sgabe, siggi_kid: Public images not embedded when file default scheme is private
- #2312747 by Lukas von Blarer: Remove 'itok' token from image URL
- #2366659 by david_garcia: Attachments created by content generate warnings
- #2404719 by alexp999: Missing space in RFC headers breaks DKIM
- #1908318 by jvieille, zionduc, bisonbleu | anrkaid: Sender is double encoded.
- #2359771 by PascalAnimateur: Support for OG membership tokens.
- #2218037 by sgabe | pinkonomy: Fixed integrity constraint violation.
- #2219609 by mitrpaka, sgabe: Convert float properties just for images.
- #2057703 by New Zeal, sgabe: Warning: is_file() expects a valid path.
- #2202127 by k.skarlatos: Added List-Unsubscribe header field for bulk mails.
- #2297135 by tobiasb: Language prefix with absolute-path reference.
- #2297091 by cameron1729: TLDs in Return-Path trimmed to 4 characters.
- #2237109 by Dane Powell: Indicate text format for body in Rules.
Mime Mail 7.x-1.0-beta3, 2014-03-05
-----------------------
- Public files test incorrect if similar path is not below root.

View File

@@ -84,6 +84,12 @@
the mail.css file found anywhere in your theme folder or
the combined CSS style sheets of your theme if enabled.
Since some email clients (namely Outlook 2007 and GMail) is tend to only regard
inline CSS, you can use the Compressor to convert CSS styles into inline style
attributes. It transmogrifies the HTML source by parsing the CSS and inserting the
CSS definitions into tags within the HTML based on the CSS selectors. To use the
Compressor, just enable it.
To create a custom mail template copy the mimemail-message.tpl.php file from
the mimemail/theme directory into your default theme's folder. Both general and
by-mailkey theming can be performed:
@@ -100,17 +106,15 @@
or any other active theme.
Images with absolute URL will be available as remote content. To embed images
into emails you have to use a relative URL or an internal path.
into emails you have to use a relative URL or an internal path. Due to security
concerns, only files residing in the public file system (e.g sites/default/files)
can be used by default.
For example:
instead of http://www.mysite.com/sites/default/files/mypicture.jpg
use /home/www/public_html/drupal/sites/default/files/mypicture.jpg
or /sites/default/files/mypicture.jpg
Since some email clients (namely Outlook 2007 and GMail) is tend to only regard
inline CSS, you can use the Compressor to convert CSS styles into inline style
attributes. It transmogrifies the HTML source by parsing the CSS and inserting the
CSS definitions into tags within the HTML based on the CSS selectors. To use the
Compressor, just enable it.
or public://mypicture.jpg
The 'send arbitrary files' permission allows you to attach or embed files located
outside Drupal's public files directory. Note that this has security implications:

View File

@@ -84,6 +84,10 @@ function mimemail_admin_settings() {
'#default_value' => variable_get('mimemail_format', filter_fallback_format()),
'#access' => count($formats) > 1,
'#attributes' => array('class' => array('filter-list')),
'#description' => t('The filter set that will be applied to the message body.
If you are using Mime Mail as default mail sytem, make sure to enable
"Convert line breaks into HTML" and "Convert URLs into links" with a long
enough maximum length for e.g. password reset URLs!'),
);
$form['mimemail']['advanced'] = array(

View File

@@ -37,7 +37,7 @@ function mimemail_rfc_headers($headers) {
$value = wordwrap($value, 50, "$crlf ", FALSE);
}
}
$header .= $key . ":" . $value . $crlf;
$header .= $key . ": " . $value . $crlf;
}
return trim($header);
}
@@ -66,7 +66,8 @@ function mimemail_headers($headers, $from = NULL) {
}
// This may not work. The MTA may rewrite the Return-Path.
if (!isset($headers['Return-Path']) || $headers['Return-Path'] == $default_from) {
if (preg_match('/[a-z\d\-\.\+_]+@(?:[a-z\d\-]+\.)+[a-z\d]{2,4}/i', $from, $matches)) {
// According to IANA the current longest TLD is 23 characters.
if (preg_match('/[a-z\d\-\.\+_]+@(?:[a-z\d\-]+\.)+[a-z\d]{2,23}/i', $from, $matches)) {
$headers['Return-Path'] = "<$matches[0]>";
}
}
@@ -80,7 +81,10 @@ function mimemail_headers($headers, $from = NULL) {
// Run all headers through mime_header_encode() to convert non-ascii
// characters to an rfc compliant string, similar to drupal_mail().
foreach ($headers as $key => $value) {
$headers[$key] = mime_header_encode($value);
// According to RFC 2047 addresses MUST NOT be encoded.
if ($key !== 'From' && $key !== 'Sender') {
$headers[$key] = mime_header_encode($value);
}
}
return $headers;
@@ -187,19 +191,22 @@ function _mimemail_file($url = NULL, $content = NULL, $name = '', $type = '', $d
$file = $content;
}
if (isset($file) && (@is_file($file) || $content)) {
$public_path = file_default_scheme() . '://';
$no_access = !user_access('send arbitrary files');
$not_in_public_path = strpos(drupal_realpath($file), drupal_realpath($public_path)) !== 0;
if (@is_file($file) && $not_in_public_path && $no_access) {
return $url;
if (isset($file)) {
$is_file = @is_file($file);
if ($is_file) {
$access = user_access('send arbitrary files');
$in_public_path = strpos(@drupal_realpath($file), drupal_realpath('public://')) === 0;
if (!$in_public_path && !$access) {
return $url;
}
}
if (!$name) {
$name = (@is_file($file)) ? basename($file) : 'attachment.dat';
$name = $is_file ? basename($file) : 'attachment.dat';
}
if (!$type) {
$type = ($name) ? file_get_mimetype($name) : file_get_mimetype($file);
$type = $is_file ? file_get_mimetype($file) : file_get_mimetype($name);
}
$id = md5($file) .'@'. $_SERVER['HTTP_HOST'];
@@ -322,7 +329,7 @@ function mimemail_multipart_body($parts, $content_type = 'multipart/mixed; chars
}
if (isset($part['file'])) {
$file = (is_file($part['file'])) ? file_get_contents($part['file']) : $part['file'];
$file = (@is_file($part['file'])) ? file_get_contents($part['file']) : $part['file'];
$part_body = chunk_split(base64_encode($file), 76, variable_get('mimemail_crlf', "\n"));
}
@@ -457,17 +464,14 @@ function _mimemail_url($url, $to_embed = NULL) {
else {
$url = preg_replace('!^' . base_path() . '!', '', $url, 1);
if ($is_image) {
// Remove security token from URL, this allows for styled image embedding.
// @see https://drupal.org/drupal-7.20-release-notes
$url = preg_replace('/\\?itok=.*$/', '', $url);
if ($to_link) {
// Exclude images from embedding if needed.
$url = file_create_url($url);
$url = str_replace(' ', '%20', $url);
}
else {
// Remove security token from URL, this allows for styled image embedding.
// @see https://drupal.org/drupal-7.20-release-notes
$url = preg_replace('/\\?itok=.*$/', '', $url);
}
}
return $url;
}
@@ -490,9 +494,10 @@ function _mimemail_url($url, $to_embed = NULL) {
$language = language_default();
// Check for language prefix.
$path = trim($path, '/');
$args = explode('/', $path);
foreach ($languages as $lang) {
if ($args[0] == $lang->prefix) {
if (!empty($args) && $args[0] == $lang->prefix) {
$prefix = array_shift($args);
$language = $lang;
$path = implode('/', $args);

View File

@@ -14,9 +14,9 @@ files[] = tests/mimemail.test
files[] = tests/mimemail_rules.test
files[] = tests/mimemail_compress.test
; Information added by Drupal.org packaging script on 2014-03-05
version = "7.x-1.0-beta3"
; Information added by Drupal.org packaging script on 2015-08-02
version = "7.x-1.0-beta4"
core = "7.x"
project = "mimemail"
datestamp = "1394018015"
datestamp = "1438530555"

View File

@@ -5,13 +5,6 @@
* Install, update and uninstall functions for Mime Mail module.
*/
/**
* Implements hook_install().
*/
function mimemail_install() {
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('edit mimemail user settings'));
}
/**
* Implements hook_enable().
*/
@@ -23,6 +16,8 @@ function mimemail_enable() {
'mimemail' => 'MimeMailSystem',
)
);
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('edit mimemail user settings'));
}
/**

View File

@@ -157,6 +157,7 @@ function mimemail_mail($key, &$message, $params) {
'cc' => 'Cc',
'bcc' => 'Bcc',
'reply-to' => 'Reply-to',
'list-unsubscribe' => 'List-Unsubscribe',
);
foreach ($address_headers as $param_key => $address_header) {
$params[$param_key] = empty($params[$param_key]) ? array() : explode(',', $params[$param_key]);

View File

@@ -57,6 +57,12 @@ function mimemail_rules_action_info() {
'description' => t("The address to reply to. Leave it empty to use the sender's address."),
'optional' => TRUE,
),
'list_unsubscribe' => array(
'type' => 'text',
'label' => t('Unsubscription e-mail and/or URL'),
'description' => t("An e-mail address and/or a URL which can be used for unsubscription. Values must be enclosed by angel brackets and separated by a comma."),
'optional' => TRUE,
),
'subject' => array(
'type' => 'text',
'label' => t('Subject'),
@@ -66,7 +72,7 @@ function mimemail_rules_action_info() {
'body' => array(
'type' => 'text',
'label' => t('Body'),
'description' => t("The mail's message HTML body."),
'description' => t('The mail\'s HTML body. Will be formatted using the text format selected on the <a href="@url">settings</a> page.', array('@url' => url('admin/config/system/mimemail'))),
'sanitize' => TRUE,
'optional' => TRUE,
'translatable' => TRUE,
@@ -74,7 +80,7 @@ function mimemail_rules_action_info() {
'plaintext' => array(
'type' => 'text',
'label' => t('Plain text body'),
'description' => t("The mail's message plaintext body."),
'description' => t("The mail's plaintext body."),
'optional' => TRUE,
'translatable' => TRUE,
),
@@ -238,7 +244,7 @@ function mimemail_rules_action_mail_to_users_of_role_upgrade($element, RulesPlug
/**
* Action Implementation: Send HTML mail.
*/
function rules_action_mimemail($key, $to, $cc = NULL, $bcc = NULL, $from_name = NULL, $from_mail = NULL, $reply_to = NULL, $subject, $body, $plaintext = NULL, $attachments = array(), $langcode, $settings, RulesState $state, RulesPlugin $element) {
function rules_action_mimemail($key, $to, $cc = NULL, $bcc = NULL, $from_name = NULL, $from_mail = NULL, $reply_to = NULL, $list_unsubscribe = NULL, $subject, $body, $plaintext = NULL, $attachments = array(), $langcode, $settings, RulesState $state, RulesPlugin $element) {
module_load_include('inc', 'mimemail');
// Set the sender name and from address.
@@ -268,6 +274,7 @@ function rules_action_mimemail($key, $to, $cc = NULL, $bcc = NULL, $from_name =
'cc' => $cc,
'bcc' => $bcc,
'reply-to' => $reply_to,
'list-unsubscribe' => $list_unsubscribe,
'plaintext' => $plaintext,
'attachments' => $attachments,
);

View File

@@ -6,9 +6,9 @@ dependencies[] = trigger
core = 7.x
; Information added by Drupal.org packaging script on 2014-03-05
version = "7.x-1.0-beta3"
; Information added by Drupal.org packaging script on 2015-08-02
version = "7.x-1.0-beta4"
core = "7.x"
project = "mimemail"
datestamp = "1394018015"
datestamp = "1438530555"

View File

@@ -24,7 +24,11 @@ function mimemail_action_info() {
*/
function mimemail_send_email_action($entity, $context) {
if (empty($context['node'])) {
$context['node'] = $entity;
if (get_class($entity) == 'OgMembership') {
$context['user'] = user_load($entity->etid);
} else {
$context['node'] = $entity;
}
}
$to = token_replace($context['to'], $context);

View File

@@ -145,7 +145,7 @@ class mimemail_compress {
// Convert float to align for images.
$float = preg_match ('/float:(left|right)/', $style, $matches);
if ($float) {
if ($node->nodeName == 'img' && $float) {
$node->setAttribute('align', $matches[1]);
$node->setAttribute('vspace', 5);
$node->setAttribute('hspace', 5);

View File

@@ -6,9 +6,9 @@ core = 7.x
files[] = mimemail_compress.inc
; Information added by Drupal.org packaging script on 2014-03-05
version = "7.x-1.0-beta3"
; Information added by Drupal.org packaging script on 2015-08-02
version = "7.x-1.0-beta4"
core = "7.x"
project = "mimemail"
datestamp = "1394018015"
datestamp = "1438530555"

View File

@@ -0,0 +1,12 @@
name = Mime Mail Example
description = Example of how to use the Mime Mail module.
dependencies[] = mimemail
package = Example modules
core = 7.x
; Information added by Drupal.org packaging script on 2015-08-02
version = "7.x-1.0-beta4"
core = "7.x"
project = "mimemail"
datestamp = "1438530555"

View File

@@ -0,0 +1,20 @@
<?php
/**
* @file
* Install, update and uninstall functions for Mime Mail Example module.
*/
/**
* Implements hook_enable().
*/
function mimemail_example_enable() {
mailsystem_set(array('mimemail_example' => 'MimeMailSystem'));
}
/**
* Implements hook_disable().
*/
function mimemail_example_disable() {
mailsystem_clear(array('mimemail_example' => 'MimeMailSystem'));
}

View File

@@ -0,0 +1,170 @@
<?php
/**
* @file
* Core and contrib hook implementations for Mime Mail Example module.
*/
/**
* Implements hook_menu().
*/
function mimemail_example_menu() {
$items['example/mimemail_example'] = array(
'title' => 'Mime Mail Example',
'page callback' => 'drupal_get_form',
'page arguments' => array('mimemail_example_form'),
'access arguments' => array('access content'),
);
return $items;
}
/**
* Implements hook_mail().
*/
function mimemail_example_mail($key, &$message, $params) {
$message['subject'] = $params['subject'];
$message['body'][] = $params['body'];
}
/**
* The example email contact form.
*/
function mimemail_example_form() {
global $user;
$form['intro'] = array(
'#markup' => t('Use this form to send a HTML message to an e-mail address. No spamming!'),
);
$form['key'] = array(
'#type' => 'textfield',
'#title' => t('Key'),
'#default_value' => 'test',
'#required' => TRUE,
);
$form['to'] = array(
'#type' => 'textfield',
'#title' => t('To'),
'#default_value' => $user->mail,
'#required' => TRUE,
);
$form['from'] = array(
'#type' => 'textfield',
'#title' => t('Sender name'),
);
$form['from_mail'] = array(
'#type' => 'textfield',
'#title' => t('Sender e-mail address'),
);
$form['params'] = array(
'#tree' => TRUE,
'headers' => array(
'Cc' => array(
'#type' => 'textfield',
'#title' => t('Cc'),
),
'Bcc' => array(
'#type' => 'textfield',
'#title' => t('Bcc'),
),
'Reply-to' => array(
'#type' => 'textfield',
'#title' => t('Reply to'),
),
'List-unsubscribe' => array(
'#type' => 'textfield',
'#title' => t('List-unsubscribe'),
),
),
'subject' => array(
'#type' => 'textfield',
'#title' => t('Subject'),
),
'body' => array(
'#type' => 'textarea',
'#title' => t('HTML message'),
),
'plain' => array(
'#type' => 'hidden',
'#states' => array(
'value' => array(
':input[name="body"]' => array('value' => ''),
),
),
),
'plaintext' => array(
'#type' => 'textarea',
'#title' => t('Plain text message'),
),
'attachments' => array(
'#name' => 'files[attachment]',
'#type' => 'file',
'#title' => t('Choose a file to send as attachment'),
),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Send message'),
);
return $form;
}
/**
* Form validation logic for the email contact form.
*/
function mimemail_example_form_validate($form, &$form_state) {
$values = &$form_state['values'];
if (!valid_email_address($values['to'])) {
form_set_error('to', t('That e-mail address is not valid.'));
}
$file = file_save_upload('attachment');
if ($file) {
$file = file_move($file, 'public://');
$values['params']['attachments'][] = array(
'filepath' => $file->uri,
);
}
}
/**
* Form submission logic for the email contact form.
*/
function mimemail_example_form_submit($form, &$form_state) {
$values = $form_state['values'];
$module = 'mimemail_example';
$key = $values['key'];
$to = $values['to'];
$language = language_default();
$params = $values['params'];
if (!empty($values['from_mail'])) {
module_load_include('inc', 'mimemail');
$from = mimemail_address(array(
'name' => $values['from'],
'mail' => $values['from_mail'],
));
}
else {
$from = $values['from'];
}
$send = TRUE;
$result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
if ($result['result'] == TRUE) {
drupal_set_message(t('Your message has been sent.'));
}
else {
drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
}
}

View File

@@ -71,12 +71,16 @@ class MimeMailWebTestCase extends DrupalWebTestCase {
public function setUp() {
parent::setUp('mailsystem', 'mimemail');
// Create and login user.
$this->adminUser = $this->drupalCreateUser(array(
$permissions = array(
'access administration pages',
'administer site configuration',
));
);
// Check to make sure that the array of permissions are valid.
$this->checkPermissions($permissions, TRUE);
// Create and login user.
$this->adminUser = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->adminUser);
}

View File

@@ -24,15 +24,20 @@ class MimeMailRulesTestCase extends DrupalWebTestCase {
public function setUp() {
parent::setUp('mailsystem', 'locale', 'entity', 'entity_token', 'rules', 'mimemail');
// Create and login user.
$this->adminUser = $this->drupalCreateUser(array(
$permissions = array(
'access administration pages',
'edit mimemail user settings',
'administer languages',
'administer rules',
'bypass rules access',
'access rules debug',
));
);
// Check to make sure that the array of permissions are valid.
$this->checkPermissions($permissions, TRUE);
// Create and login user.
$this->adminUser = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->adminUser);
// Enable another language too.