Forums / Setup & design / sqliimport

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 :)

eZ debug

Timing: Jan 17 2025 22:44:54
Script start
Timing: Jan 17 2025 22:44:54
Module start 'content'
Timing: Jan 17 2025 22:44:55
Module end 'content'
Timing: Jan 17 2025 22:44:55
Script end

Main resources:

Total runtime0.9045 sec
Peak memory usage4,096.0000 KB
Database Queries207

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 587.5391180.8594
Module start 'content' 0.00530.7879 768.3984630.5000
Module end 'content' 0.79320.1112 1,398.8984341.0859
Script end 0.9044  1,739.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.4299210.0002
Check MTime0.00140.1553210.0001
Mysql Total
Database connection0.00060.068610.0006
Mysqli_queries0.818290.45682070.0040
Looping result0.00220.24642050.0000
Template Total0.875796.820.4378
Template load0.00230.249220.0011
Template processing0.873496.563120.4367
Template load and register function0.00020.020010.0002
states
state_id_array0.00090.099310.0009
state_identifier_array0.00070.078820.0004
Override
Cache load0.00200.2232570.0000
Sytem overhead
Fetch class attribute can translate value0.00150.168940.0004
Fetch class attribute name0.00130.143570.0002
XML
Image XML parsing0.00120.135040.0003
class_abstraction
Instantiating content class attribute0.00000.003690.0000
General
dbfile0.00360.4008280.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 35
 Number of unique templates used: 11

Time used to render debug report: 0.0002 secs