function _subscriptions_content_node_mailvars in Subscriptions 5.2
Same name and namespace in other branches
- 6 subscriptions_content.module \_subscriptions_content_node_mailvars()
Fill given array of mailvars with given node values.
Callback of function _subscriptions_content_node_mailvars().
Parameters
$mailvars: Array of mailvars to be full-filled.
$node: Node object used to fill $mailvars.
$field: Intervall used for filling variable !term_name.
$s: Subscription object.
2 string references to '_subscriptions_content_node_mailvars'
- subscriptions_content_subscriptions in ./
subscriptions_content.module - Implementation of hook_subscriptions().
- subscriptions_taxonomy_subscriptions in ./
subscriptions_taxonomy.module - Implementation of hook_subscriptions().
File
- ./
subscriptions_content.module, line 667 - Subscriptions to content events
Code
function _subscriptions_content_node_mailvars(&$mailvars, $node, $field, $s) {
include_once drupal_get_path('module', 'subscriptions_mail') . '/subscriptions_mail.templates.inc';
$mailvars['!url'] = url('node/' . $node->nid, NULL, NULL, TRUE);
$mailvars['!node_type'] = $node->type;
$mailvars['!title'] = trim($node->title);
$mailvars['!teaser'] = _subscriptions_content_format_text($node->teaser, $node->format);
$mailvars['!body'] = _subscriptions_content_format_text($node->body, $node->format);
$mailvars['!full_node'] = variable_get('subscriptions_generate_full_node', 0) ? _subscriptions_content_format_text(node_view($node, FALSE, TRUE, FALSE)) : '!full_node';
$mailvars['!is_new'] = (int) (!empty($node->_subscriptions_is_new));
$mailvars['!is_updated'] = (int) (!empty($node->_subscriptions_is_updated));
$mailvars['!is_old'] = (int) (empty($node->_subscriptions_is_new) && empty($node->_subscriptions_is_updated));
$mailvars['!is_published'] = $node->status;
$mailvars['!has_new_comments'] = (int) (!empty($node->_subscriptions_comments));
if ($field == 'tid') {
$mailvars['!term_name'] = db_result(db_query('SELECT name FROM {term_data} WHERE tid = %d', $s['value']));
}
elseif (!empty($node->tid)) {
$mailvars['!term_name'] = db_result(db_query('SELECT name FROM {term_data} WHERE tid = %d', $node->tid));
}
else {
unset($mailvars['!term_name']);
}
if ($s['load_function'] == 'subscriptions_content_comment_load' || $s['load_function'] == 'subscriptions_content_node_load' && isset($node->_comments)) {
static $comment_template, $separator;
if (!$comment_template) {
$comment_template = db_result(db_query("SELECT item_body FROM {subscriptions_mail_edit} WHERE mailkey = '%s'", SUBSCRIPTIONS_COMMENT_MAILKEY . '-item'));
$comment_template = $comment_template ? $comment_template : subscriptions_mail_template('CITEM');
$separator = db_result(db_query("SELECT item_body FROM {subscriptions_mail_edit} WHERE mailkey = '%s'", SUBSCRIPTIONS_COMMENT_MAILKEY . '-separator'));
$separator = $separator ? $separator : subscriptions_mail_template('SEP');
}
$mailvars['!comments'] = _subscriptions_content_format_comments($node, $comment_template, $separator);
}
else {
$mailvars['!comments'] = '';
}
$files = '';
if (isset($node->files) && user_access('view uploaded files')) {
foreach ($node->files as $file) {
$files .= file_create_url($file->filepath) . "\n";
}
}
$mailvars['!files'] = $files;
}