You are here

webform_phone.module in Webform Phone Number 7.2

Same filename and directory in other branches
  1. 7 webform_phone.module

Webform declaration of phone field

File

webform_phone.module
View source
<?php

/**
 * @file
 * Webform declaration of phone field
 */

/**
 * Implements hook_webform_component_info().
 */
function webform_phone_webform_component_info() {
  $components = array();
  $components['phone'] = array(
    'label' => t('Phone Number'),
    'description' => t('Phone Number field'),
    'features' => array(
      // Add content to CSV downloads. Defaults to TRUE.
      'csv' => TRUE,
      // Show this component in e-mailed submissions. Defaults to TRUE.
      'email' => TRUE,
      // Allow this component to be used as an e-mail FROM or TO address.
      // Defaults to FALSE.
      'email_address' => FALSE,
      // Allow this component to be used as an e-mail SUBJECT or FROM name.
      // Defaults to FALSE.
      'email_name' => FALSE,
      // This component may be toggled as required or not. Defaults to TRUE.
      'required' => TRUE,
      // This component has a title that can be toggled as displayed or not.
      'title_display' => TRUE,
      // This component has a title that can be displayed inline.
      'title_inline' => TRUE,
      // If this component can be used as a conditional SOURCE. All components
      // may always be displayed conditionally, regardless of this setting.
      // Defaults to TRUE.
      'conditional' => FALSE,
      // If this component allows other components to be grouped within it
      // (like a fieldset or tabs). Defaults to FALSE.
      'group' => FALSE,
      // If this component can be used for SPAM analysis, usually with Mollom.
      'spam_analysis' => FALSE,
      // If this component saves a file that can be used as an e-mail
      // attachment. Defaults to FALSE.
      'attachment' => FALSE,
    ),
    'file' => 'webform_phone.components.inc',
  );
  return $components;
}

/**
 * Implements hook_webform_validator_alter().
 */
function webform_phone_webform_validator_alter(&$validators) {
  $validators['unique']['component_types'][] = 'phone';
  $validators['oneoftwo']['component_types'][] = 'phone';
  $validators['oneofseveral']['component_types'][] = 'phone';
}

/** Gets the version of the phone module currently installed.
 * This is messy, and I shouldn't have to do this, because the
 * phone module should provide functions to get the version when
 * they do a complete rewrite that would break other modules!
 * @todo: Remove this if phone module ever implements a function to get its version.
 */
function webform_phone_get_phone_version() {
  $info_file_path = drupal_get_path('module', 'phone') . '/' . 'phone.info';
  if (file_exists($info_file_path)) {
    $info = drupal_parse_info_file($info_file_path);
    if (is_array($info) && !empty($info['version'])) {
      $version = ltrim($info['version'], '678.x-');

      //Strip all the other characters off the beginning (safe for d6, d7, d8)
      $version = rtrim($version, '-dev');
      $version = drupal_substr($version, 0, 1);
      return $version;
    }
  }
  return NULL;
}

Functions

Namesort descending Description
webform_phone_get_phone_version Gets the version of the phone module currently installed. This is messy, and I shouldn't have to do this, because the phone module should provide functions to get the version when they do a complete rewrite that would break other modules! @todo:…
webform_phone_webform_component_info Implements hook_webform_component_info().
webform_phone_webform_validator_alter Implements hook_webform_validator_alter().