You are here

function _subscriptions_content_node_mailvars in Subscriptions 6

Same name and namespace in other branches
  1. 5.2 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: Internal use 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 615
Subscriptions to content events

Code

function _subscriptions_content_node_mailvars(&$mailvars, $node, $field, $s) {
  global $language;
  include_once drupal_get_path('module', 'subscriptions_mail') . '/subscriptions_mail.templates.inc';
  $mailvars['!url'] = url('node/' . $node->nid, array(
    'absolute' => 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['!nid'] = $node->nid;
  $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->_subscriptions_comments)) {
    $comment_template = subscriptions_mail_template_load(SUBSCRIPTIONS_COMMENT_MAILKEY, $language->language, 'body', 'CITEM');
    $separator = subscriptions_mail_template_load(SUBSCRIPTIONS_COMMENT_MAILKEY, $language->language, 'subject', '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['!has_files'] = empty($files) ? 0 : 1;
  $mailvars['!files'] = $files;
  $account = subscriptions_user_load($node->revision_uid);
  $mailvars['!revision_name'] = $account->name;
  $mailvars['!revision_log'] = _subscriptions_content_format_text($node->log);
}