You are here

function format_phone_number in Phone 6

Same name and namespace in other branches
  1. 5 phone.module \format_phone_number()
  2. 7 phone.module \format_phone_number()

Verification for Phone Numbers.

Parameters

string $countrycode:

string $phonenumber:

Return value

boolean Returns boolean FALSE if the phone number is not valid.

4 calls to format_phone_number()
ILPhoneNumberTestCase::testPhoneILFormatting in tests/phone-il.test
NZPhoneNumberTestCase::testPhoneNZFormatting in tests/phone-nz.test
phone_field in ./phone.module
Implementation of hook_field().
ZAPhoneNumberTestCase::testPhoneZAFormatting in tests/phone-za.test

File

./phone.module, line 960
Defines phone number fields for CCK. Provide some verifications on the phone numbers

Code

function format_phone_number($countrycode, $phonenumber, $field) {
  $countrycode = trim($countrycode);
  $phonenumber = trim($phonenumber);
  if (phone_supported_countrycode($countrycode)) {

    //drupal_set_message('langue = ' . $countrycode, 'error');
    $format_phone_function = 'format_' . $countrycode . '_phone_number';
    module_load_include('inc', 'phone', 'phone.' . $countrycode);
    if (function_exists($format_phone_function)) {
      return $format_phone_function($phonenumber, $field);
    }
    else {
      return FALSE;
    }
  }
  else {

    //Country not taken into account yet
    return FALSE;
  }
}