You are here

function email_mail_page in Email Field 6

Same name and namespace in other branches
  1. 5 email.module \email_mail_page()
  2. 6.2 email.module \email_mail_page()
  3. 7 email.module \email_mail_page()

The contact form page.

Parameters

$node: The node object on which the email address is stored.

$field_name: The name of the CCK field which holds the email address.

Return value

Rendered page output containing either the contact form or a flood warning.

1 string reference to 'email_mail_page'
email_menu in ./email.module
Implementation of hook_menu().

File

./email.module, line 289

Code

function email_mail_page($node, $field_name) {
  $field_info = content_fields($field_name, $node->type);
  if (empty($field_info) || $field_info['type'] != 'email') {
    return MENU_NOT_FOUND;
  }

  // Check the field access using CCK's content_access function.
  if (!content_access('view', $field_info, NULL, $node)) {
    return MENU_ACCESS_DENIED;
  }

  // Check if the node has an email address.
  $email = isset($node->{$field_name}[0]['email']) ? $node->{$field_name}[0]['email'] : '';
  if (empty($email)) {
    return MENU_NOT_FOUND;
  }

  // Check the formatters.
  if ($field_info['display_settings']['teaser']['format'] != 'contact' && $field_info['display_settings']['full']['format'] != 'contact') {
    return MENU_NOT_FOUND;
  }
  if (!flood_is_allowed('email', variable_get('email_hourly_threshold', 3))) {
    $output = t("You cannot send more than %number messages per hour. Please try again later.", array(
      '%number' => variable_get('email_hourly_threshold', 3),
    ));
  }
  else {
    $output = drupal_get_form('email_mail_page_form', $node, $field_name, $email);
  }
  return $output;
}