The way it stands, the multi-value character designation only works if it's a comma. Using this form, the multi-value character designation is broken, and causes issues on many systems when using csv format.

In user.inc on line 297, the explode() function relies on a comma character thereby making the "Multi Value Delimiter" (sic) setting irrelevant.

I'm thinking that we should be able to pass into explode() whatever value is submitted from the multi-value delimiter field... I'm just not sure how to go about doing it.

Thoughts?

(Hopefully all this goes without saying that this module is really fantastic. It's saving my rump right now with L-DAP imports. If we can just figure out how to pass into explode() the multi-value delimiter, I think it could go a long way.)

Comments

Wolf_22’s picture

I think I figured it out (wasn't really that tough to spot once I had time):

In user.inc, change...

...
  if ($field_id == 'roles') {
    $value = user_user_import_roles_data($data[$column_id], $settings['roles_new']);
  }
...

...to...

...
  if ($field_id == 'roles') {
    $value = user_user_import_roles_data($data[$column_id], $settings['roles_new'], $settings['multi_value_delimiter']);
  }
...

In the same file, change line 293 (user_user_import_roles_data()'s declaration) from...

...
function user_user_import_roles_data($data, $new_roles_allowed) {
...

...to...

...
function user_user_import_roles_data($data, $new_roles_allowed, $delimiter) {
...

Finally, change line 297 from...

...
  $values = explode('+', $data);
...

...to...

...
  if(isset($delimiter) && $delimiter !== ''){
	  $values = explode($delimiter, $data);
  }else{
	$values = explode(',', $data);
  }
...

Any possibility we can throw this into dev? (And apologies in advance for my tacky formatting. I don't normally submit code changes.)

egarbeil’s picture

Issue summary: View changes

I ran into the exact same thing. All I did to fix was to change line 297 from using a comma (which doesn't work in .csv format- even with quotes, etc. - I did try) to a '||'. It was a hacked way of doing it but it's a live client on a time commitment. The code above would be fine and could probably be polished to be a little cleaner. This really should be fixed because of the roles field - that's important for many clients.

Wolf_22’s picture

It's extremely helpful to the entire community to see examples of more efficient code and respective rationale for using it. Responses like, "The code above would be fine and could probably be polished to be a little cleaner," just derails things and does nothing for everyone.

Post your rationale and maybe we can all learn something and improve the module.