I use the cck phone module http://drupal.org/project/phone.
I tried to rewrite the email.inc to cs_phone.inc to import my phone numbers but it did not work.
is there anyone who already did it? or is able to help?
thx in advance.

Comments

Robrecht Jacques’s picture

Is there a reason why you called it cs_phone.inc? It probably didn't get included then. Files in supported/ are only included if a module with the same name is enabled. So call it phone.inc.

Could you attach your cs_phone.inc file so I can have a look at it?

HoKe’s picture

The reason that I called it cs_phone.inc is that the I found in table content_node_field that the type for my field is cs_phone as email for some other field.
So I thought it will be the best to use it.
On your advice a changed it as mentioned below. and it works! thx.
It has just one small failure. That it shows unsoupported

file phone.inc

// $Id: phone.inc,v 1.0.0.0 2009/04/12 21:54:41 hoke Exp $

/**
 * @file
 * Support file for the CCK phone module.
 */

/**
 * Implementation of hook_node_import_fields().
 */
function phone_node_import_fields($type) {
  $fields = array();

  foreach (node_import_cck_fields($type, 'phone') as $fieldname => $fieldinfo) {
    foreach ($fieldinfo['columns'] as $colname => $colinfo) {
      $cck_fieldname = node_import_cck_name($fieldname, $colname);

      $fields[$cck_fieldname] = node_import_cck_field_defaults($fieldinfo);

      switch ($colname) {
        case 'phone':
          $fields[$cck_fieldname]['title'] = $fieldinfo['widget']['label'];
          $fields[$cck_fieldname]['is_required'] = $fieldinfo['required'];
          break;

        default:
          $fields[$cck_fieldname]['title'] = t('Unsupported: ') . $fieldinfo['widget']['label'] .' - '. $colname;
          break;
      }
    }
  }

  return $fields;
}

this file is no enough.

there must be added somethink like next code to node_import.inc row 211

        case 'phone':
          $fields[$type][$fieldname]['preprocess'][] = 'node_import_check_phone';
          break;
 

and than to node_import.inc row 1141

 * Check if the value is a valid phone number.
 *
 * Uses: nothing.
 */
function node_import_check_phone(&$value, $field, $options, $preview) {
  if (!valid_phone_number("country code", $value)) {
    node_import_input_error(t('Input error: %value is not a valid phone number.', array('%value' => $value)));
    return FALSE;
  }
  return TRUE;
}

but as I see, there is no valid_phone_number in .inc file like valid_email_number in includes/common.inc
the valid_phone_number is in phone.module and is tested on country code.
which is a little bit to much to me to find the right way. :(

so if any body knows how to do it, it would be great.
thx in advance

Robrecht Jacques’s picture

Status: Active » Needs work

Thanks for the work. I'll look into it tomorrow.

You will probably not need this node_import_check_phone() ... probably the form submission will do that testing. I'll look into it.

Also, it is probably "unsupported" because the "colname" is not "phone" but something else (probably simply "value").

Robrecht Jacques’s picture

Status: Needs work » Fixed

Download phone.inc from CVS and copy it into supported/phone/phone.inc, creating a new directory.

No changes needed to node_import.inc or other files.

This will be included in the -rc5 release (ETA end of the week).

Please report if you find any issues with it, reopening this issue.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.