sqliimport

Author Message

Andy Woods

Thursday 26 May 2011 9:59:25 am

I've installed sqliimport because I need to import 150 users into ezpublish.

I've looked at the documentation but I don't understand what I have to do to import the users.

Would anyone be kind enough to give me a 'step by step' explaination of what I need to do please?

Thanks,

Andy

Lars Eirik Rønning

Thursday 26 May 2011 10:57:06 pm

Hi Andy.

The important thing to understand is that SQLIImport is an import framework. It is meant to aid developers in doing imports in eZPublish. There is no such thing as a prexisting import solution for users.

Others in the forum suggest that you look into the code to define your own import handler. If you are not a developer you need to a wait for someone else to come up with an sqliimport handler that may be used for your actual situation.

Remember that users (similar to other objects in the system) need to be imported from a datasource. This datasource may be unique for you and thus it would either require the handler to be in a given format, that is the name of the columns in the csv file , the ordering of the user data.

The best take for you is either to look into the extension sqliimport and use this a starting point, but this does require you to understand programming as you need to map your datasource fields to the objects in the system. If the first approach is not for you.. try to request someone to develop such a handler where you state your requirements. It could be that you have added new fields to your userclass which other installations do not have.

I hope this gave you some more understanding of the SQLIImport framework. It is a fantastic import solution and I have used it in numerous projects. I personally am hoping this will become defacto standard which eZSystems adopt.

Feel free to ask further questions.

You could try to state your requirements and perhaps someone will find a quick way of doing this (as it should not be very hard for a seasoned developer..). Make sure you include what type of file the datasource is and the name of the columns. If you have not modifed the existing userclass at all, state this also.

Certified Developer :http://auth.ez.no/certification/verify/365518

Jérôme Vieilledent

Friday 27 May 2011 2:41:18 am

Hi Andy

Lars Eirik explained it very well actually :).

The only thing you need to keep in mind is that a user is no more than a content object with an eZUser attribute. Thus, it can be processed just like other regular content objects.

SQLIImport uses fromString() methods from datatypes (see the fromString doc appendix to learn about the format for several datatypes). For ezuser, here it is :

ezuser
======
'|' separated string with user login, email, password hash, and password hash type

The following code could be taken as an example, in your import handler :

$userOptions = new SQLIContentOptions( array(
 'class_identifier' => "user",
 'remote_id' => "importeduser-$userIDInOldSystem"
) );
$content = SQLIContent::create( $userOptions );
$content->fields->first_name = $firstName;
$content->fields->last_name = $lastName;

// Build the password hash
// md5_user is a concatenation of login and password with a \n, md5 hashed
$passwordHash = md5( "$userLogin\n$userPassword" );

// Format for ezuser is userLogin|userEmail|passwordHash|hashType|isActivated
$content->fields->user_account = "$userLogin|$userEmail|$passwordHash|md5_user|1";

$userPlacementID = eZINI::instance( "UserSettings", "DefaultUserPlacement", "site.ini" );
$content->addLocation( SQLILocation::fromNodeID( $userPlacementID ) );

$publisher = SQLIContentPublisher::getInstance();
$publisher->publish( $content );

I hope it will help you :)

Jérôme Vieilledent

Friday 27 May 2011 2:48:00 am

"

I personally am hoping this will become defacto standard which eZSystems adopt.

"

This might happen in the near future ;)

Andy Woods

Friday 27 May 2011 11:36:44 am

Hi Jérôme,

Thank you for your post.

I am a developer - I've been coding with PHP for 10 years.

All I need is a heads up on the process to create an import handle, ie. which files to add your code to and the various other changes to I need to make.

I would like to import the following from a csv file:

 - first name
 - surname
 - email address
 - username
 - password

Thanks,

Andy

Jérôme Vieilledent

Tuesday 31 May 2011 1:39:49 am

Hi Andy

You can find a quick presentation of SQLIImport on my blog.

You will also find all the information you need in the documentation PDF (checkout the Handler Development paragraph). A simple RSS import handler example is also provided inside the extension.

Hope this helps :)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.