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.

eZ debug

Timing: Jan 18 2025 01:13:07
Script start
Timing: Jan 18 2025 01:13:07
Module start 'layout'
Timing: Jan 18 2025 01:13:07
Module start 'content'
Timing: Jan 18 2025 01:13:08
Module end 'content'
Timing: Jan 18 2025 01:13:08
Script end

Main resources:

Total runtime1.1503 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 587.7891152.6094
Module start 'layout' 0.00530.0032 740.398439.4063
Module start 'content' 0.00861.1396 779.8047625.4453
Module end 'content' 1.14810.0021 1,405.250016.2031
Script end 1.1502  1,421.4531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2853160.0002
Check MTime0.00140.1257160.0001
Mysql Total
Database connection0.00080.066910.0008
Mysqli_queries1.078393.7420700.0154
Looping result0.00090.0817680.0000
Template Total1.118797.320.5594
Template load0.00200.172920.0010
Template processing1.116797.082320.5584
Template load and register function0.00010.011210.0001
states
state_id_array0.00080.073010.0008
state_identifier_array0.00150.130520.0008
Override
Cache load0.00180.1573570.0000
Sytem overhead
Fetch class attribute can translate value0.00070.059130.0002
Fetch class attribute name0.00130.108770.0002
XML
Image XML parsing0.00090.078230.0003
class_abstraction
Instantiating content class attribute0.00000.001990.0000
General
dbfile0.00150.1335170.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
4content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 35
 Number of unique templates used: 11

Time used to render debug report: 0.0001 secs