You are here

function event_calendar_node_update in Event Calendar 7

Implements hook_node_update().

Sending mail to users selected on module configuration page.

See also

drupal_mail()

token_replace()

File

./event_calendar.module, line 91
The module file that allows events to be created and required admin approval.

Code

function event_calendar_node_update($node) {

  // NODE_TYPE && SELECTED && NOT_EXPIRED.
  $node_type = variable_get('event_calendar_node_type', 'event_calendar');
  if ($node->type == $node_type) {
    $author = user_load($node->uid);
    $to = $author->mail;
    if (!empty($to)) {
      $from = (string) variable_get('site_mail', '');
      $language = language_default();
      $subject = _event_calendar_email_text('users_subject');
      $body = _event_calendar_email_text('users_body');
      $params['subject'] = token_replace($subject, array(
        'event_calendar' => $node->original,
        'node' => $node->original,
      ));
      $params['body'] = token_replace($body, array(
        'event_calendar' => $node->original,
        'node' => $node->original,
      ));
      drupal_mail('event_calendar', 'users', $to, $language, $params, $from, $send = TRUE);
    }
  }
}