FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
107
sites/all/modules/contrib/mail/maillog/includes/maillog.mail.inc
Normal file
107
sites/all/modules/contrib/mail/maillog/includes/maillog.mail.inc
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* An interface for pluggable mail back-ends.
|
||||
*/
|
||||
class MaillogMailSystem implements MailSystemInterface {
|
||||
/**
|
||||
* Format a message composed by drupal_mail() prior sending.
|
||||
*
|
||||
* @param $message
|
||||
* A message array, as described in hook_mail_alter().
|
||||
*
|
||||
* @return
|
||||
* The formatted $message.
|
||||
*/
|
||||
public function format(array $message) {
|
||||
$default = new DefaultMailSystem();
|
||||
return $default->format($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message composed by drupal_mail().
|
||||
*
|
||||
* @param $message
|
||||
* Message array with at least the following elements:
|
||||
* - id: A unique identifier of the e-mail type. Examples: 'contact_user_copy',
|
||||
* 'user_password_reset'.
|
||||
* - to: The mail address or addresses where the message will be sent to.
|
||||
* The formatting of this string must comply with RFC 2822. Some examples:
|
||||
* - user@example.com
|
||||
* - user@example.com, anotheruser@example.com
|
||||
* - User <user@example.com>
|
||||
* - User <user@example.com>, Another User <anotheruser@example.com>
|
||||
* - subject: Subject of the e-mail to be sent. This must not contain any
|
||||
* newline characters, or the mail may not be sent properly.
|
||||
* - body: Message to be sent. Accepts both CRLF and LF line-endings.
|
||||
* E-mail bodies must be wrapped. You can use drupal_wrap_mail() for
|
||||
* smart plain text wrapping.
|
||||
* - headers: Associative array containing all additional mail headers not
|
||||
* defined by one of the other parameters. PHP's mail() looks for Cc
|
||||
* and Bcc headers and sends the mail to addresses in these headers too.
|
||||
*
|
||||
* @return
|
||||
* TRUE if the mail was successfully accepted for delivery, otherwise FALSE.
|
||||
*/
|
||||
public function mail(array $message) {
|
||||
// Log the e-mail
|
||||
if (variable_get('maillog_log', TRUE)) {
|
||||
$record = new stdClass;
|
||||
|
||||
// In case the subject/from/to is already encoded, decode with mime_header_decode
|
||||
$record->header_message_id = isset($message['headers']['Message-ID']) ? $message['headers']['Message-ID'] : NULL;
|
||||
$record->subject = $message['subject'];
|
||||
$record->subject = mime_header_decode($record->subject);
|
||||
$record->body = $message['body'];
|
||||
$record->header_from = isset($message['from']) ? $message['from'] : NULL;
|
||||
$record->header_from = mime_header_decode($record->header_from);
|
||||
|
||||
$header_to = array();
|
||||
if (isset($message['to'])) {
|
||||
if (is_array($message['to'])) {
|
||||
foreach($message['to'] as $value) {
|
||||
$header_to[] = mime_header_decode($value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$header_to[] = mime_header_decode($message['to']);
|
||||
}
|
||||
}
|
||||
$record->header_to = implode(', ', $header_to);
|
||||
|
||||
$record->header_reply_to = isset($message['headers']['Reply-To']) ? $message['headers']['Reply-To'] : '';
|
||||
$record->header_all = serialize($message['headers']);
|
||||
$record->sent_date = REQUEST_TIME;
|
||||
|
||||
drupal_write_record('maillog', $record);
|
||||
}
|
||||
|
||||
// Display the e-mail using Devel module
|
||||
if (variable_get('maillog_devel', TRUE) && function_exists('dpm')) {
|
||||
$devel_msg = array();
|
||||
$devel_msg[t('Subject')] = $message['subject'];
|
||||
$devel_msg[t('From')] = $message['from'];
|
||||
$devel_msg[t('To')] = $message['to'];
|
||||
$devel_msg[t('Reply-To')] = isset($message['reply_to']) ? $message['reply_to'] : NULL;
|
||||
$devel_msg[t('Header')] = $message['headers'];
|
||||
$devel_msg[t('Body')] = $message['body'];
|
||||
|
||||
dpm($devel_msg, 'maillog');
|
||||
}
|
||||
|
||||
if (variable_get('maillog_send', TRUE)) {
|
||||
$default = new DefaultMailSystem();
|
||||
$result = $default->mail($message);
|
||||
}
|
||||
elseif (user_access('administer maillog')) {
|
||||
$message = t('Sending of e-mail messages is disabled by Maillog module. Go <a href="@href">here</a> to enable.', array('@href' => url('admin/reports/maillog')));
|
||||
|
||||
drupal_set_message($message, 'warning', TRUE);
|
||||
}
|
||||
else {
|
||||
global $user;
|
||||
watchdog('maillog', 'Attempted to send an email, but sending emails is disabled.');
|
||||
}
|
||||
return isset($result) ? $result : TRUE;
|
||||
}
|
||||
}
|
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Make the fields from node type 'Logged Mail' available in views
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_views_data().
|
||||
*/
|
||||
function maillog_views_data() {
|
||||
$data['maillog']['table']['group'] = t('Maillog');
|
||||
|
||||
$data['maillog']['table']['base'] = array(
|
||||
'field' => 'idmaillog',
|
||||
'title' => t('Maillog'),
|
||||
'help' => t("This table contains the logged e-mails."),
|
||||
'weight' => -10,
|
||||
);
|
||||
|
||||
$data['maillog']['idmaillog'] = array(
|
||||
'title' => t('Maillog_ID'),
|
||||
'help' => t('The primary key of the maillog table.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['header_message_id'] = array(
|
||||
'title' => t('Message_ID'),
|
||||
'help' => t("The 'Message_ID' e-mail address."),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['header_from'] = array(
|
||||
'title' => t('From'),
|
||||
'help' => t("The 'From' field of the e-mail address."),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['header_to'] = array(
|
||||
'title' => t('To'),
|
||||
'help' => t("The 'To' field of the e-mail address."),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['header_reply_to'] = array(
|
||||
'title' => t('Reply To'),
|
||||
'help' => t("The 'Reply-To' field of the e-mail address."),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['header_all'] = array(
|
||||
'title' => t('Header'),
|
||||
'help' => t("The 'Header' field of the e-mail."),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['body'] = array(
|
||||
'title' => t('Body'),
|
||||
'help' => t("The 'Body' field of the e-mail."),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['subject'] = array(
|
||||
'title' => t('Subject'),
|
||||
'help' => t("The 'Subject' field of the e-mail."),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['sent_date'] = array(
|
||||
'title' => t('Date'),
|
||||
'help' => t("The 'Date' field of the e-mail."),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_date',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['maillog']['delete_maillog'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Delete link'),
|
||||
'help' => t('Provide a simple link to delete an eMail entry from the maillog table.'),
|
||||
'handler' => 'maillog_handler_field_maillog_link_delete',
|
||||
),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_views_handlers() to register all of the basic handlers
|
||||
* views uses.
|
||||
*/
|
||||
function maillog_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'maillog') . '/includes',
|
||||
),
|
||||
'handlers' => array(
|
||||
// field handlers
|
||||
'maillog_handler_field_maillog_link_delete' => array(
|
||||
'parent' => 'views_handler_field',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Creates the default view for the 'Log Mail' module
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_views_default_views().
|
||||
*/
|
||||
function maillog_views_default_views() {
|
||||
$view = new view;
|
||||
$view->name = 'Maillog';
|
||||
$view->description = 'Displays the list of e-mails logged by the \'Mail Log\' module.';
|
||||
$view->tag = '';
|
||||
$view->view_php = '';
|
||||
$view->base_table = 'maillog';
|
||||
$view->is_cacheable = FALSE;
|
||||
$view->api_version = 2;
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
$handler = $view->new_display('default', 'Defaults', 'default');
|
||||
$handler->override_option('fields', array(
|
||||
'idmaillog' => array(
|
||||
'label' => 'Maillog_ID',
|
||||
'alter' => array(
|
||||
'alter_text' => 0,
|
||||
'text' => '',
|
||||
'make_link' => 0,
|
||||
'path' => '',
|
||||
'link_class' => '',
|
||||
'alt' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'target' => '',
|
||||
'help' => '',
|
||||
'trim' => 0,
|
||||
'max_length' => '',
|
||||
'word_boundary' => 1,
|
||||
'ellipsis' => 1,
|
||||
'html' => 0,
|
||||
'strip_tags' => 0,
|
||||
),
|
||||
'empty' => '',
|
||||
'hide_empty' => 0,
|
||||
'empty_zero' => 0,
|
||||
'exclude' => 1,
|
||||
'id' => 'idmaillog',
|
||||
'table' => 'maillog',
|
||||
'field' => 'idmaillog',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'sent_date' => array(
|
||||
'label' => 'Date',
|
||||
'alter' => array(
|
||||
'alter_text' => 0,
|
||||
'text' => '',
|
||||
'make_link' => 0,
|
||||
'path' => '',
|
||||
'link_class' => '',
|
||||
'alt' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'target' => '',
|
||||
'help' => '',
|
||||
'trim' => 0,
|
||||
'max_length' => '',
|
||||
'word_boundary' => 1,
|
||||
'ellipsis' => 1,
|
||||
'html' => 0,
|
||||
'strip_tags' => 0,
|
||||
),
|
||||
'empty' => '',
|
||||
'hide_empty' => 0,
|
||||
'empty_zero' => 0,
|
||||
'exclude' => 0,
|
||||
'id' => 'sent_date',
|
||||
'table' => 'maillog',
|
||||
'field' => 'sent_date',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'header_message_id' => array(
|
||||
'id' => 'header_message_id',
|
||||
'table' => 'maillog',
|
||||
'field' => 'header_message_id',
|
||||
),
|
||||
'subject' => array(
|
||||
'label' => 'Subject',
|
||||
'alter' => array(
|
||||
'alter_text' => 0,
|
||||
'text' => '',
|
||||
'make_link' => 1,
|
||||
'path' => 'maillog/details/[idmaillog]',
|
||||
'link_class' => '',
|
||||
'alt' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'target' => '',
|
||||
'help' => '',
|
||||
'trim' => 0,
|
||||
'max_length' => '',
|
||||
'word_boundary' => 1,
|
||||
'ellipsis' => 1,
|
||||
'html' => 0,
|
||||
'strip_tags' => 0,
|
||||
),
|
||||
'empty' => '',
|
||||
'hide_empty' => 0,
|
||||
'empty_zero' => 0,
|
||||
'exclude' => 0,
|
||||
'id' => 'subject',
|
||||
'table' => 'maillog',
|
||||
'field' => 'subject',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'header_from' => array(
|
||||
'label' => 'From',
|
||||
'alter' => array(
|
||||
'alter_text' => 0,
|
||||
'text' => '',
|
||||
'make_link' => 0,
|
||||
'path' => '',
|
||||
'link_class' => '',
|
||||
'alt' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'target' => '',
|
||||
'help' => '',
|
||||
'trim' => 0,
|
||||
'max_length' => '',
|
||||
'word_boundary' => 1,
|
||||
'ellipsis' => 1,
|
||||
'html' => 0,
|
||||
'strip_tags' => 0,
|
||||
),
|
||||
'empty' => '',
|
||||
'hide_empty' => 0,
|
||||
'empty_zero' => 0,
|
||||
'exclude' => 0,
|
||||
'id' => 'header_from',
|
||||
'table' => 'maillog',
|
||||
'field' => 'header_from',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'header_to' => array(
|
||||
'label' => 'To',
|
||||
'alter' => array(
|
||||
'alter_text' => 0,
|
||||
'text' => '',
|
||||
'make_link' => 0,
|
||||
'path' => '',
|
||||
'link_class' => '',
|
||||
'alt' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'target' => '',
|
||||
'help' => '',
|
||||
'trim' => 0,
|
||||
'max_length' => '',
|
||||
'word_boundary' => 1,
|
||||
'ellipsis' => 1,
|
||||
'html' => 0,
|
||||
'strip_tags' => 0,
|
||||
),
|
||||
'empty' => '',
|
||||
'hide_empty' => 0,
|
||||
'empty_zero' => 0,
|
||||
'exclude' => 0,
|
||||
'id' => 'header_to',
|
||||
'table' => 'maillog',
|
||||
'field' => 'header_to',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'delete_maillog' => array(
|
||||
'label' => 'Delete link',
|
||||
'alter' => array(
|
||||
'alter_text' => 0,
|
||||
'text' => '',
|
||||
'make_link' => 0,
|
||||
'path' => '',
|
||||
'link_class' => '',
|
||||
'alt' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'target' => '',
|
||||
'help' => '',
|
||||
'trim' => 0,
|
||||
'max_length' => '',
|
||||
'word_boundary' => 1,
|
||||
'ellipsis' => 1,
|
||||
'html' => 0,
|
||||
'strip_tags' => 0,
|
||||
),
|
||||
'empty' => '',
|
||||
'hide_empty' => 0,
|
||||
'empty_zero' => 0,
|
||||
'exclude' => 0,
|
||||
'id' => 'delete_maillog',
|
||||
'table' => 'maillog',
|
||||
'field' => 'delete_maillog',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
$handler->override_option('sorts', array(
|
||||
'sent_date' => array(
|
||||
'order' => 'DESC',
|
||||
'id' => 'sent_date',
|
||||
'table' => 'maillog',
|
||||
'field' => 'sent_date',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
$handler->override_option('access', array(
|
||||
'type' => 'perm',
|
||||
'perm' => 'view maillog',
|
||||
));
|
||||
$handler->override_option('cache', array(
|
||||
'type' => 'none',
|
||||
));
|
||||
$handler->override_option('title', 'Maillog');
|
||||
$handler->override_option('empty', 'Maillog is currently empty. Send a mail!');
|
||||
$handler->override_option('empty_format', '1');
|
||||
$handler->override_option('use_pager', '1');
|
||||
$handler->override_option('style_plugin', 'table');
|
||||
$handler = $view->new_display('page', 'Page', 'page_1');
|
||||
$handler->override_option('path', 'admin/reports/maillog');
|
||||
$handler->override_option('menu', array(
|
||||
'type' => 'normal',
|
||||
'title' => 'Maillog',
|
||||
'description' => 'Show the logged mails',
|
||||
'weight' => '0',
|
||||
'name' => 'management',
|
||||
));
|
||||
$handler->override_option('tab_options', array(
|
||||
'type' => 'none',
|
||||
'title' => '',
|
||||
'description' => '',
|
||||
'weight' => 0,
|
||||
'name' => 'navigation',
|
||||
));
|
||||
|
||||
$views[$view->name] = $view;
|
||||
return $views;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Handler for providing an 'Delete link' in views
|
||||
*/
|
||||
|
||||
class maillog_handler_field_maillog_entry_link_delete extends views_handler_field {
|
||||
function construct() {
|
||||
parent::construct();
|
||||
$this->additional_fields['maillog_id'] = 'maillog_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to add the field to a query.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$this->add_additional_fields();
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
// ensure user has access to edit this node.
|
||||
if (!user_access('delete maillog')) {
|
||||
return;
|
||||
}
|
||||
$text = !empty($this->options['text']) ? $this->options['text'] : t('delete');
|
||||
return l($text, "maillog/delete/$values->maillog_id", array('query' => drupal_get_destination()));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Handler for providing an 'Delete link' in views
|
||||
*/
|
||||
|
||||
class maillog_handler_field_maillog_link_delete extends views_handler_field {
|
||||
function construct() {
|
||||
parent::construct();
|
||||
$this->additional_fields['idmaillog'] = 'idmaillog';
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to add the field to a query.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$this->add_additional_fields();
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
// ensure user has access to edit this node.
|
||||
if (!user_access('delete maillog')) {
|
||||
return;
|
||||
}
|
||||
$text = !empty($this->options['text']) ? $this->options['text'] : t('delete');
|
||||
return l($text, "maillog/delete/$values->idmaillog", array('query' => drupal_get_destination()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user