updated print
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
* @ingroup print
|
||||
*/
|
||||
|
||||
// Include MIME library
|
||||
@include_once('Mail/mime.php');
|
||||
// Include MIME library, if available.
|
||||
@include_once 'Mail/mime.php';
|
||||
|
||||
/**
|
||||
* Form constructor for the send by email module settings form.
|
||||
@@ -30,7 +30,9 @@ function print_mail_settings() {
|
||||
'#type' => 'select',
|
||||
'#title' => t('Hourly threshold'),
|
||||
'#default_value' => variable_get('print_mail_hourly_threshold', PRINT_MAIL_HOURLY_THRESHOLD),
|
||||
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
|
||||
'#options' => drupal_map_assoc(
|
||||
array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)
|
||||
),
|
||||
'#description' => t('The maximum number of emails a user can send per hour.'),
|
||||
);
|
||||
|
||||
|
@@ -10,8 +10,8 @@
|
||||
* @ingroup print
|
||||
*/
|
||||
|
||||
// Include MIME library
|
||||
@include_once('Mail/mime.php');
|
||||
// Include MIME library, if available.
|
||||
@include_once 'Mail/mime.php';
|
||||
|
||||
/**
|
||||
* Form constructor for the send by email form.
|
||||
@@ -19,12 +19,12 @@
|
||||
* @ingroup forms
|
||||
*/
|
||||
function print_mail_form($form, &$form_state) {
|
||||
// Remove the printmail/ prefix
|
||||
// Remove the printmail/ prefix.
|
||||
$path_arr = explode('/', $_GET['q']);
|
||||
unset($path_arr[0]);
|
||||
$path = filter_xss(implode('/', $path_arr));
|
||||
if (empty($path)) {
|
||||
// If no path was provided, let's try to generate a page for the referer
|
||||
// If no path was provided, let's try to generate a page for the referer.
|
||||
global $base_url;
|
||||
$link = print_mail_print_link();
|
||||
|
||||
@@ -37,11 +37,11 @@ function print_mail_form($form, &$form_state) {
|
||||
}
|
||||
elseif (ctype_digit($path_arr[1])) {
|
||||
if (drupal_lookup_path('source', $path)) {
|
||||
// This is a numeric alias
|
||||
// This is a numeric alias.
|
||||
$path = drupal_get_normal_path($path);
|
||||
}
|
||||
else {
|
||||
// normal nid
|
||||
// Normal nid.
|
||||
$path = 'node/' . $path;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ function print_mail_form($form, &$form_state) {
|
||||
$path = drupal_get_normal_path($path);
|
||||
}
|
||||
|
||||
// Handle the query
|
||||
// Handle the query.
|
||||
$query = $_GET;
|
||||
unset($query['q']);
|
||||
|
||||
@@ -59,6 +59,20 @@ function print_mail_form($form, &$form_state) {
|
||||
/**
|
||||
* Build email form for the page provided in the path argument.
|
||||
*
|
||||
* @param array $form
|
||||
* Form.
|
||||
* @param array $form_state
|
||||
* Form state.
|
||||
* @param string $path
|
||||
* Path.
|
||||
* @param array $query
|
||||
* Query.
|
||||
* @param Object $user
|
||||
* Current user.
|
||||
*
|
||||
* @return array
|
||||
* Modified form.
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $user = NULL) {
|
||||
@@ -81,16 +95,16 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
|
||||
$print_mail_user_recipients_default = variable_get('print_mail_user_recipients', PRINT_MAIL_USER_RECIPIENTS_DEFAULT);
|
||||
$form = array();
|
||||
|
||||
$cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL;
|
||||
$cid = isset($_GET['comment']) ? (int) $_GET['comment'] : NULL;
|
||||
$title = _print_get_title($path);
|
||||
|
||||
$options = array();
|
||||
if ($print_mail_user_recipients_default) {
|
||||
$options = array();
|
||||
if (module_exists('realname')) {
|
||||
$sql = "SELECT u.mail, r.realname AS name from {users} u LEFT JOIN {realname} r ON u.uid = r.uid WHERE u.uid <> :uid ORDER BY name ASC";
|
||||
$sql = "SELECT u.mail, r.realname AS name from {users} u LEFT JOIN {realname} r ON u.uid = r.uid WHERE u.uid <> :uid AND status = 1 ORDER BY name ASC";
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT mail, name from {users} WHERE uid <> :uid ORDER BY name ASC";
|
||||
$sql = "SELECT mail, name from {users} WHERE uid <> :uid AND status = 1 ORDER BY name ASC";
|
||||
}
|
||||
$recipients = db_query($sql, array(':uid' => drupal_anonymous_user()->uid));
|
||||
foreach ($recipients as $recipient) {
|
||||
@@ -101,10 +115,10 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
|
||||
if (count($form_state['input']) == 0) {
|
||||
$nodepath = drupal_get_normal_path($path);
|
||||
db_merge('print_mail_page_counter')
|
||||
->key(array('path' => $nodepath))
|
||||
->key(array('path' => substr($nodepath, 0, 255)))
|
||||
->fields(array(
|
||||
'totalcount' => 1,
|
||||
'timestamp' => REQUEST_TIME,
|
||||
'totalcount' => 1,
|
||||
'timestamp' => REQUEST_TIME,
|
||||
))
|
||||
->expression('totalcount', 'totalcount + 1')
|
||||
->execute();
|
||||
@@ -112,7 +126,7 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
|
||||
|
||||
$form['path'] = array('#type' => 'value', '#value' => $path);
|
||||
$form['query'] = array('#type' => 'value', '#value' => $query);
|
||||
$form['cid'] = array('#type' => 'value', '#value' => $cid);
|
||||
$form['cid'] = array('#type' => 'value', '#value' => $cid);
|
||||
$form['title'] = array('#type' => 'value', '#value' => $title);
|
||||
|
||||
$form['fld_from_addr'] = array(
|
||||
@@ -153,7 +167,7 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
|
||||
'#required' => TRUE,
|
||||
);
|
||||
if (!empty($title)) {
|
||||
// To prevent useless translation strings, try to translate only non-node titles
|
||||
// To prevent useless translation strings, translate only non-node titles.
|
||||
if (drupal_substr($path, 0, 5) != 'node/') {
|
||||
$title = t($title);
|
||||
}
|
||||
@@ -182,12 +196,16 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
|
||||
$form['chk_teaser'] = array('#type' => 'value', '#value' => $print_mail_teaser_default);
|
||||
}
|
||||
|
||||
$form['btn_submit'] = array(
|
||||
$form['actions'] = array(
|
||||
'#type' => 'actions',
|
||||
);
|
||||
|
||||
$form['actions']['submit'] = array(
|
||||
'#name' => 'submit',
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Send email'),
|
||||
);
|
||||
$form['btn_cancel'] = array(
|
||||
$form['actions']['cancel'] = array(
|
||||
'#name' => 'cancel',
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Cancel'),
|
||||
@@ -204,8 +222,12 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
|
||||
$user_name = t('Someone');
|
||||
}
|
||||
$site_name = variable_get('site_name', t('an interesting site'));
|
||||
$form['fld_subject']['#default_value'] = t('!user has sent you a message from !site', array('!user' => $user_name, '!site' => $site_name, '!title' => $title));
|
||||
$form['txt_message']['#default_value'] = t('');
|
||||
$form['fld_subject']['#default_value'] = t('!user has sent you a message from !site', array(
|
||||
'!user' => $user_name,
|
||||
'!site' => $site_name,
|
||||
'!title' => $title,
|
||||
));
|
||||
$form['txt_message']['#default_value'] = '';
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -216,8 +238,11 @@ function print_mail_form_for_path($form, &$form_state, $path, $query = NULL, $us
|
||||
* Adds a class to the form labels. This class is used to place the label on
|
||||
* the left of the input fields.
|
||||
*
|
||||
* @param array $form
|
||||
* Form array
|
||||
* @param array $variables
|
||||
* Theme variables including the form.
|
||||
*
|
||||
* @return string
|
||||
* Send by-email form HTML.
|
||||
*
|
||||
* @see print_mail_form()
|
||||
* @ingroup forms
|
||||
@@ -250,8 +275,11 @@ function theme_print_mail_form($variables) {
|
||||
*
|
||||
* Allows themes and modules to override the default sendlink plain text format.
|
||||
*
|
||||
* @param $params
|
||||
* $params as passed to print_mail_mail().
|
||||
* @param array $params
|
||||
* Value of $params as passed to print_mail_mail().
|
||||
*
|
||||
* @return string
|
||||
* Plain text containing the message and a simple link to the content.
|
||||
*
|
||||
* @ingroup themeable
|
||||
* @ingroup print_themeable
|
||||
@@ -265,8 +293,11 @@ function theme_print_mail_sendlink_plain($params) {
|
||||
*
|
||||
* Allows themes and modules to override the default sendlink HTML format.
|
||||
*
|
||||
* @param $params
|
||||
* $params as passed to print_mail_mail().
|
||||
* @param array $params
|
||||
* Value of $params as passed to print_mail_mail().
|
||||
*
|
||||
* @return string
|
||||
* HTML text containing the message and a simple link to the content.
|
||||
*
|
||||
* @ingroup themeable
|
||||
* @ingroup print_themeable
|
||||
@@ -303,9 +334,9 @@ function print_mail_form_validate($form, &$form_state) {
|
||||
}
|
||||
|
||||
if (!empty($form_state['values']['txt_to']['addrs'])) {
|
||||
// All new-lines are replaced by commas
|
||||
// All new-lines are replaced by commas.
|
||||
$to_addrs = preg_replace('![\r|\n|,]+!', ',', trim($form_state['values']['txt_to']['addrs']));
|
||||
// Create an array from the string
|
||||
// Create an array from the string.
|
||||
$to_array = array_merge($to_array, explode(',', $to_addrs));
|
||||
}
|
||||
|
||||
@@ -313,16 +344,16 @@ function print_mail_form_validate($form, &$form_state) {
|
||||
form_set_error('txt_to', t('You must specify at least one email address or user as a recipient.'));
|
||||
}
|
||||
|
||||
// Verify each element of the array
|
||||
// Verify each element of the array.
|
||||
foreach ($to_array as $key => $address) {
|
||||
$address = trim($address);
|
||||
if (preg_match('/(.*?) <(.*)>/s', $address, $matches)) {
|
||||
// Address is of the type User Name <user@domain.tld>
|
||||
// Address is of the type User Name <user@domain.tld>.
|
||||
$test = user_validate_mail($matches[2]);
|
||||
$to_array[$key] = trim($matches[1]) . ' <' . $matches[2] . '>';
|
||||
}
|
||||
else {
|
||||
// Address must be user@domain.tld
|
||||
// Address must be user@domain.tld.
|
||||
$test = user_validate_mail($address);
|
||||
}
|
||||
if ($test) {
|
||||
@@ -333,19 +364,19 @@ function print_mail_form_validate($form, &$form_state) {
|
||||
$print_mail_hourly_threshold = variable_get('print_mail_hourly_threshold', PRINT_MAIL_HOURLY_THRESHOLD);
|
||||
|
||||
if ((!user_access('send unlimited emails')) && (!flood_is_allowed('print_mail', $print_mail_hourly_threshold - count($to_array) + 1))) {
|
||||
form_set_error('txt_to', t('You cannot send more than %number messages per hour. Please reduce the number of recipients.', array('%number' => $print_mail_hourly_threshold)));
|
||||
form_set_error('txt_to', t('You cannot send more than %number messages per hour. Please reduce the number of recipients.', array('%number' => $print_mail_hourly_threshold)));
|
||||
}
|
||||
|
||||
// In all fields, prevent insertion of custom headers
|
||||
// In all fields, prevent insertion of custom headers.
|
||||
foreach ($form_state['values'] as $key => $string) {
|
||||
if ( (drupal_substr($key, 0, 4) == 'fld_') && ((strpos($string, "\n") !== FALSE) || (strpos($string, "\r") !== FALSE)) ) {
|
||||
if ((drupal_substr($key, 0, 4) == 'fld_') && ((strpos($string, "\n") !== FALSE) || (strpos($string, "\r") !== FALSE))) {
|
||||
form_set_error($key, 'Found invalid character');
|
||||
}
|
||||
}
|
||||
|
||||
$form_state['values']['fld_from_addr'] = $from_addr;
|
||||
$form_state['values']['fld_from_name'] = trim($form_state['values']['fld_from_name']);
|
||||
// Re-create the string from the re-organized array
|
||||
// Re-create the string from the re-organized array.
|
||||
$form_state['values']['txt_to']['addrs'] = implode(', ', $to_array);
|
||||
}
|
||||
|
||||
@@ -357,7 +388,7 @@ function print_mail_form_validate($form, &$form_state) {
|
||||
* @ingroup forms
|
||||
*/
|
||||
function print_mail_form_submit($form, &$form_state) {
|
||||
if (!array_key_exists('cancel', $form_state['values'])) {
|
||||
if (!array_key_exists('cancel', $form_state['input'])) {
|
||||
module_load_include('inc', 'print', 'print.pages');
|
||||
module_load_include('inc', 'print', 'includes/print');
|
||||
|
||||
@@ -375,7 +406,7 @@ function print_mail_form_submit($form, &$form_state) {
|
||||
$params['link'] = url($form_state['values']['path'], array('absolute' => TRUE, 'query' => $form_state['values']['query']));
|
||||
$params['title'] = $form_state['values']['title'];
|
||||
|
||||
// If a name is provided, make From: in the format Common Name <address>
|
||||
// If a name is provided, make From: in the format Common Name <address>.
|
||||
if (!empty($form_state['values']['fld_from_name'])) {
|
||||
$from = '"' . mime_header_encode($form_state['values']['fld_from_name']) . '" <' . $form_state['values']['fld_from_addr'] . '>';
|
||||
}
|
||||
@@ -383,43 +414,60 @@ function print_mail_form_submit($form, &$form_state) {
|
||||
$from = $form_state['values']['fld_from_addr'];
|
||||
}
|
||||
|
||||
// If using reply-to, move the From: info to the params array, so that it is passed to hook_mail later
|
||||
// If using reply-to, move the From: info to the params array, so that it
|
||||
// is passed to hook_mail later.
|
||||
if (variable_get('print_mail_use_reply_to', PRINT_MAIL_USE_REPLY_TO)) {
|
||||
$params['from'] = $from;
|
||||
$from = NULL;
|
||||
}
|
||||
|
||||
// Spaces in img URLs must be replaced with %20
|
||||
// Spaces in img URLs must be replaced with %20.
|
||||
$pattern = '!<(img\s[^>]*?)>!is';
|
||||
$node->content = preg_replace_callback($pattern, '_print_replace_spaces', $node->content);
|
||||
|
||||
$params['body'] = theme('print', array('node' => $node, 'query' => $form_state['values']['query'], 'format' => $link['format'], 'expand_css' => TRUE, 'message' => $params['message']));
|
||||
$params['body'] = theme('print', array(
|
||||
'node' => $node,
|
||||
'query' => $form_state['values']['query'],
|
||||
'format' => $link['format'],
|
||||
'expand_css' => TRUE,
|
||||
'message' => $params['message'],
|
||||
));
|
||||
|
||||
// Img elements must be set to absolute
|
||||
// Img elements must be set to absolute.
|
||||
$pattern = '!<(img\s[^>]*?)>!is';
|
||||
$params['body'] = preg_replace_callback($pattern, '_print_rewrite_urls', $params['body']);
|
||||
|
||||
// Convert the a href elements, to make sure no relative links remain
|
||||
// Convert the a href elements, to make sure no relative links remain.
|
||||
$pattern = '!<(a\s[^>]*?)>!is';
|
||||
$params['body'] = preg_replace_callback($pattern, '_print_rewrite_urls', $params['body']);
|
||||
|
||||
// Enable support for third-party modules to alter the e-mail before it's sent
|
||||
// Enable support for third-party modules to alter the e-mail before
|
||||
// being sent.
|
||||
drupal_alter('print_mail', $params, $to);
|
||||
|
||||
$ok = FALSE;
|
||||
$use_job_queue = variable_get('print_mail_job_queue', PRINT_MAIL_JOB_QUEUE_DEFAULT);
|
||||
$queue = NULL;
|
||||
if ($use_job_queue) {
|
||||
$queue = DrupalQueue::get('print_mail_send');
|
||||
}
|
||||
|
||||
$addresses = explode(', ', $form_state['values']['txt_to']['addrs']);
|
||||
foreach ($addresses as $to) {
|
||||
$ret = array();
|
||||
if ($use_job_queue) {
|
||||
// Use job queue to send mails during cron runs
|
||||
$queue->createItem(array('module' => 'print_mail', 'key' => $print_mail_send_option_default, 'to' => $to, 'language' => language_default(), 'params' => $params, 'from' => $from));
|
||||
// Use job queue to send mails during cron runs.
|
||||
$queue->createItem(array(
|
||||
'module' => 'print_mail',
|
||||
'key' => $print_mail_send_option_default,
|
||||
'to' => $to,
|
||||
'language' => language_default(),
|
||||
'params' => $params,
|
||||
'from' => $from,
|
||||
));
|
||||
}
|
||||
else {
|
||||
// Send mail immediately using Drupal's mail handler
|
||||
// Send mail immediately using Drupal's mail handler.
|
||||
$ret = drupal_mail('print_mail', $print_mail_send_option_default, $to, language_default(), $params, $from);
|
||||
}
|
||||
if ($use_job_queue || $ret['result']) {
|
||||
@@ -429,15 +477,20 @@ function print_mail_form_submit($form, &$form_state) {
|
||||
}
|
||||
if ($ok) {
|
||||
$query = empty($form_state['values']['query']) ? '' : '?' . rawurldecode(drupal_http_build_query($form_state['values']['query']));
|
||||
watchdog('print_mail', '%name [%from] sent %page to [%to]', array('%name' => $form_state['values']['fld_from_name'], '%from' => $form_state['values']['fld_from_addr'], '%page' => $form_state['values']['path'] . $query, '%to' => $form_state['values']['txt_to']['addrs']));
|
||||
watchdog('print_mail', '%name [%from] sent %page to [%to]', array(
|
||||
'%name' => $form_state['values']['fld_from_name'],
|
||||
'%from' => $form_state['values']['fld_from_addr'],
|
||||
'%page' => $form_state['values']['path'] . $query,
|
||||
'%to' => $form_state['values']['txt_to']['addrs'],
|
||||
));
|
||||
$site_name = variable_get('site_name', t('us'));
|
||||
drupal_set_message(check_plain(t('Thank you for spreading the word about !site.', array('!site' => $site_name))));
|
||||
|
||||
$nodepath = drupal_get_normal_path($form_state['values']['path']);
|
||||
db_update('print_mail_page_counter')
|
||||
->fields(array(
|
||||
'sentcount' => 1,
|
||||
'sent_timestamp' => REQUEST_TIME,
|
||||
'sentcount' => 1,
|
||||
'sent_timestamp' => REQUEST_TIME,
|
||||
))
|
||||
->condition('path', $nodepath, '=')
|
||||
->expression('sentcount', 'sentcount + :inc', array(':inc' => count($addresses)))
|
||||
@@ -446,5 +499,9 @@ function print_mail_form_submit($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
|
||||
$form_state['redirect'] = array(preg_replace('!^book/export/html/!', 'node/', $form_state['values']['path']), array('query' => $form_state['values']['query']));
|
||||
$form_state['redirect'] = array(
|
||||
preg_replace('!^book/export/html/!', 'node/', $form_state['values']['path']), array(
|
||||
'query' => $form_state['values']['query'],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -5,9 +5,8 @@ package = "Printer, email and PDF versions"
|
||||
dependencies[] = print
|
||||
configure = admin/config/user-interface/print/email
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-04-02
|
||||
version = "7.x-2.0"
|
||||
; Information added by Drupal.org packaging script on 2018-10-05
|
||||
version = "7.x-2.2"
|
||||
core = "7.x"
|
||||
project = "print"
|
||||
datestamp = "1396426766"
|
||||
|
||||
datestamp = "1538760185"
|
||||
|
@@ -11,9 +11,7 @@
|
||||
* Implements hook_enable().
|
||||
*/
|
||||
function print_mail_enable() {
|
||||
$t = get_t();
|
||||
|
||||
// Module weight
|
||||
// Module weight.
|
||||
db_update('system')
|
||||
->fields(array(
|
||||
'weight' => 1,
|
||||
@@ -27,6 +25,31 @@ function print_mail_enable() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_requirements().
|
||||
*/
|
||||
function print_mail_requirements($phase) {
|
||||
$requirements = array();
|
||||
$t = get_t();
|
||||
switch ($phase) {
|
||||
// At runtime, make sure that a PDF generation tool is selected.
|
||||
case 'runtime':
|
||||
if (module_exists('mailsystem')) {
|
||||
$mail_system = mailsystem_get();
|
||||
if (($mail_system['default-system'] != 'DefaultMailSystem') && (!isset($mail_system['print_mail']) || ($mail_system['print_mail'] != 'DefaultMailSystem'))) {
|
||||
$requirements['print_mail_mailsystem'] = array(
|
||||
'title' => $t('Printer, email and PDF versions - Send by email'),
|
||||
'value' => $t('Incompatible Mail System setting detected'),
|
||||
'description' => $t('The send by email module requires the use of the DefaultMailSystem, please configure it in the !url.', array('!url' => l($t('Mail System Settings page'), 'admin/config/system/mailsystem'))),
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_disable().
|
||||
*/
|
||||
@@ -154,7 +177,7 @@ function print_mail_schema() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove hardcoded numeric deltas from all blocks
|
||||
* Remove hardcoded numeric deltas from all blocks.
|
||||
*/
|
||||
function print_mail_update_7000(&$sandbox) {
|
||||
$renamed_deltas = array(
|
||||
@@ -167,7 +190,7 @@ function print_mail_update_7000(&$sandbox) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable MimeMailSystem for now
|
||||
* Disable MimeMailSystem for now.
|
||||
*/
|
||||
function print_mail_update_7100(&$sandbox) {
|
||||
if (module_exists('mailsystem')) {
|
||||
@@ -176,7 +199,7 @@ function print_mail_update_7100(&$sandbox) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update permissions to new spellings
|
||||
* Update permissions to new spellings.
|
||||
*/
|
||||
function print_mail_update_7101(&$sandbox) {
|
||||
db_update('role_permission')
|
||||
@@ -190,7 +213,7 @@ function print_mail_update_7101(&$sandbox) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete old variables
|
||||
* Delete old variables.
|
||||
*/
|
||||
function print_mail_update_7200(&$sandbox) {
|
||||
variable_del('print_mail_settings');
|
||||
@@ -206,7 +229,7 @@ function print_mail_update_7200(&$sandbox) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable block and help area links
|
||||
* Enable block and help area links.
|
||||
*/
|
||||
function print_mail_update_7202(&$sandbox) {
|
||||
$link_pos = variable_get('print_mail_link_pos', drupal_json_decode('{ "link": "link", "block": "block", "help": "help" }'));
|
||||
@@ -216,11 +239,16 @@ function print_mail_update_7202(&$sandbox) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase size of the path field in the print_mail_page_counter table
|
||||
* Increase size of the path field in the print_mail_page_counter table.
|
||||
*/
|
||||
function print_mail_update_7203(&$sandbox) {
|
||||
db_drop_primary_key('print_mail_page_counter');
|
||||
db_change_field('print_mail_page_counter', 'path', 'path',
|
||||
array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'Page path'),
|
||||
array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Page path',
|
||||
),
|
||||
array('primary key' => array('path')));
|
||||
}
|
||||
|
@@ -115,31 +115,6 @@ function print_mail_variable_info($options) {
|
||||
return $variable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_requirements().
|
||||
*/
|
||||
function print_mail_requirements($phase) {
|
||||
$requirements = array();
|
||||
$t = get_t();
|
||||
switch ($phase) {
|
||||
// At runtime, make sure that a PDF generation tool is selected
|
||||
case 'runtime':
|
||||
if (module_exists('mailsystem')) {
|
||||
$mail_system = mailsystem_get();
|
||||
if (($mail_system['default-system'] != 'DefaultMailSystem') && (!isset($mail_system['print_mail']) || ($mail_system['print_mail'] != 'DefaultMailSystem'))) {
|
||||
$requirements['print_mail_mailsystem'] = array(
|
||||
'title' => $t('Printer, email and PDF versions - Send by email'),
|
||||
'value' => $t('Incompatible Mail System setting detected'),
|
||||
'description' => $t('The send by email module requires the use of the DefaultMailSystem, please configure it in the !url.', array('!url' => l($t('Mail System Settings page'), 'admin/config/system/mailsystem'))),
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_info().
|
||||
*/
|
||||
@@ -153,11 +128,12 @@ function print_mail_block_info() {
|
||||
* Implements hook_block_view().
|
||||
*/
|
||||
function print_mail_block_view($delta = 0) {
|
||||
$block = array();
|
||||
switch ($delta) {
|
||||
case 'print_mail-top':
|
||||
$block['subject'] = t('Most emailed');
|
||||
$result = db_query_range("SELECT path FROM {print_mail_page_counter} LEFT JOIN {node} n ON path = CONCAT('node/', n.nid) WHERE status <> 0 OR status IS NULL ORDER BY sentcount DESC", 0, 3)
|
||||
->fetchAll();
|
||||
->fetchAll();
|
||||
if (count($result)) {
|
||||
$items = array();
|
||||
foreach ($result as $obj) {
|
||||
@@ -217,62 +193,66 @@ function print_mail_mail($key, &$message, $params) {
|
||||
$message['headers']['Reply-To'] = $params['from'];
|
||||
}
|
||||
|
||||
$sendlink_plain = '';
|
||||
$sendlink_html = '';
|
||||
switch ($key) {
|
||||
case 'sendpage':
|
||||
$message['body'][] = check_plain($params['body']);
|
||||
$message['headers']['Content-Type'] = 'text/html; charset=utf-8';
|
||||
break;
|
||||
|
||||
case 'sendlink':
|
||||
// Generate plain-text and html versions of message with link
|
||||
// Generate plain-text and html versions of message with link.
|
||||
$sendlink_plain = theme('print_mail_sendlink_plain', $params);
|
||||
$sendlink_html = theme('print_mail_sendlink_html', $params);
|
||||
|
||||
// Send HTML-only version if MIME library not present
|
||||
// Send HTML-only version if MIME library not present.
|
||||
if (!class_exists('Mail_mime')) {
|
||||
$message['body'][] = check_plain($sendlink_html);
|
||||
$message['headers']['Content-Type'] = 'text/html; charset=utf-8';
|
||||
break;
|
||||
}
|
||||
// no break on purpose
|
||||
// No break on purpose.
|
||||
case 'plain-attachment':
|
||||
case 'inline-attachment':
|
||||
// Configure new MIME object
|
||||
// Configure new MIME object.
|
||||
$mime = new Mail_mime("\n");
|
||||
$mime_params['html_encoding'] = '7bit';
|
||||
$mime_params['html_charset'] = 'utf-8';
|
||||
$mime_params['text_charset'] = 'utf-8';
|
||||
|
||||
// Pass message contents into MIME object
|
||||
// Pass message contents into MIME object.
|
||||
switch ($key) {
|
||||
case 'sendlink':
|
||||
$mime->setTxtBody($sendlink_plain);
|
||||
$mime->setHTMLBody($sendlink_html);
|
||||
break;
|
||||
|
||||
case 'inline-attachment':
|
||||
$mime->setHTMLBody($params['body']);
|
||||
// no break on purpose
|
||||
// No break on purpose.
|
||||
case 'plain-attachment':
|
||||
$mime->setTxtBody($params['message']);
|
||||
$mime->addAttachment($params['body'], 'text/html', 'Attachment.html', FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
// Store MIME message output in message array
|
||||
// Store MIME message output in message array.
|
||||
$message['body'][] = check_plain($mime->get($mime_params));
|
||||
$message['headers'] = $mime->headers($message['headers']);
|
||||
|
||||
// Strip special characters from Content-Type header
|
||||
// Required to prevent mime_header_encode() from disrupting Content-Type header
|
||||
// Strip special characters from Content-Type header. Required to prevent
|
||||
// mime_header_encode() from disrupting Content-Type header.
|
||||
$message['headers']['Content-Type'] = preg_replace('/[^\x20-\x7E]/', '', $message['headers']['Content-Type']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access callback to check a combination of user_acess() and page access
|
||||
* Access callback to check a combination of user_acess() and page access.
|
||||
*
|
||||
* @param string $permission
|
||||
* permission required to view the page
|
||||
* Permission required to view the page.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the user has permission to view the page, FALSE otherwise
|
||||
@@ -287,18 +267,18 @@ function _print_mail_access($permission) {
|
||||
$path = implode('/', $parts);
|
||||
if (ctype_digit($parts[1])) {
|
||||
if (drupal_lookup_path('source', $path)) {
|
||||
// This is a numeric alias
|
||||
// This is a numeric alias.
|
||||
$path = drupal_get_normal_path($path);
|
||||
}
|
||||
else {
|
||||
// normal nid
|
||||
// Normal nid.
|
||||
$path = 'node/' . $path;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$path = drupal_get_normal_path($path);
|
||||
}
|
||||
// If the destination page is not accessible, don't show the form
|
||||
// If the destination page is not accessible, don't show the form.
|
||||
if (!($router_item = menu_get_item($path)) || (!$router_item['access'])) {
|
||||
$page_access = FALSE;
|
||||
}
|
||||
@@ -309,7 +289,7 @@ function _print_mail_access($permission) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Auxiliary function to display a formatted send by email link
|
||||
* Auxiliary function to display a formatted send by email link.
|
||||
*
|
||||
* Function made available so that developers may call this function from
|
||||
* their defined pages/blocks.
|
||||
@@ -320,7 +300,7 @@ function _print_mail_access($permission) {
|
||||
* node object, to be used in checking node access. If the path argument is
|
||||
* not provided, the path used will be node/nid.
|
||||
* @param string $location
|
||||
* where in the page where the link is being inserted ('link', 'corner',
|
||||
* Where in the page where the link is being inserted ('link', 'corner',
|
||||
* 'block', 'help').
|
||||
*
|
||||
* @return string
|
||||
@@ -330,7 +310,8 @@ function _print_mail_access($permission) {
|
||||
*/
|
||||
function print_mail_insert_link($path = NULL, $node = NULL, $location = '') {
|
||||
if (function_exists('print_ui_insert_link')) {
|
||||
return print_ui_insert_link(print_mail_print_link(), array('path' => $path, 'node' => $node, 'location' => $location));
|
||||
return print_ui_insert_link(print_mail_print_link(),
|
||||
array('path' => $path, 'node' => $node, 'location' => $location));
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
@@ -338,14 +319,14 @@ function print_mail_insert_link($path = NULL, $node = NULL, $location = '') {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the link to send by email is allowed depending on the settings
|
||||
* Check if the link to send by email is allowed depending on the settings.
|
||||
*
|
||||
* @param array $args
|
||||
* array containing the possible parameters:
|
||||
* view_mode, node, type, path
|
||||
* Array containing the possible parameters:
|
||||
* view_mode, node, type, path.
|
||||
*
|
||||
* @return bool
|
||||
* FALSE if not allowed, TRUE otherwise
|
||||
* FALSE if not allowed, TRUE otherwise.
|
||||
*/
|
||||
function print_mail_link_allowed($args) {
|
||||
return (user_access('access send by email'));
|
||||
@@ -366,6 +347,7 @@ function print_mail_mollom_form_list() {
|
||||
* Implemenents hook_mollom_form_info().
|
||||
*/
|
||||
function print_mail_mollom_form_info($form_id) {
|
||||
$form_info = array();
|
||||
switch ($form_id) {
|
||||
case 'print_mail_form':
|
||||
$form_info = array(
|
||||
@@ -426,7 +408,7 @@ function print_mail_rules_action_info() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler for the print_mail_action_submit
|
||||
* Action handler for the print_mail_action_submit.
|
||||
*
|
||||
* @ingroup rules
|
||||
*/
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Send by email Views integration
|
||||
* Send by email Views integration.
|
||||
*
|
||||
* @ingroup print
|
||||
*/
|
||||
@@ -25,18 +25,16 @@ function print_mail_views_data() {
|
||||
// 'field' is the foreign key in this table.
|
||||
'left_field' => 'nid',
|
||||
'field' => 'nid',
|
||||
// 'type' => 'INNER',
|
||||
);
|
||||
$data['print_mail_page_counter']['table']['join']['node'] = array(
|
||||
// 'left_field' is the primary key in the referenced table.
|
||||
// 'field' is the foreign key in this table.
|
||||
'left_field' => 'nid',
|
||||
'field' => 'path',
|
||||
// 'type' => 'INNER',
|
||||
'handler' => 'print_join_page_counter',
|
||||
);
|
||||
|
||||
// print_mail_node_conf fields
|
||||
// print_mail_node_conf fields.
|
||||
$data['print_mail_node_conf']['link'] = array(
|
||||
'title' => t('Email: Show link'),
|
||||
'help' => t('Whether to show the send by email link.'),
|
||||
@@ -86,8 +84,7 @@ function print_mail_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
// print_mail_page_counter fields
|
||||
// print_mail_page_counter fields.
|
||||
$data['print_mail_page_counter']['totalcount'] = array(
|
||||
'title' => t('Email: Number of page accesses'),
|
||||
'help' => t('Counter of accesses to the send by email form for this node.'),
|
||||
|
Reference in New Issue
Block a user