User Import Howto
Import definition file
Edit the content of the file 'Admin/Import/definitions/admin_user_import_csv.xml', so that it contains information about all fields of the later used CSV file:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<model>Tinebase_Model_FullUser</model>
<plugin>Admin_Import_Csv</plugin>
<type>import</type>
<headline>1</headline>
<dryrun>1</dryrun>
<delimiter>;</delimiter>
<mapping>
<field>
<source>firstname</source>
<destination>accountFirstName</destination>
</field>
<field>
<source>lastname</source>
<destination>accountLastName</destination>
</field>
<field>
<source>loginname</source>
<destination>accountLoginName</destination>
</field>
<field>
<source>password</source>
<destination>password</destination>
</field>
<field>
<source>email</source>
<destination>accountEmailAddress</destination>
</field>
</mapping>
</config>
The 'dryrun' is set to 1, then the import is not added to the database. This should be used for testing purposed. Switch it to 0 (means no dry-run) to do the real import.
See the sourcecode in 'Tinebase/Model/FullUser.php' for more possible fields.
CSV file
Create a CSV file which contains colums defined in the previous XML file. Example:
firstname;lastname;loginname;password;email John;Doe;jdoe;secret;john.doe@domain.example
The first line must contain the fieldnames, specified in the 'source' tags and all values have to be separated by the value used between the 'delimiter' tags.
Don't place the CSV file in your webservers document root. Other users may download it or find it in search engines caches, even it's allready removed!
Importing
Change into your Tine20 folder and run
php tine20.php -v --username admin20 --method Admin.importUser /path/to/file.csv Admin/Import/definitions/admin_user_import_csv.xml
Replace the username 'admin20' with an account that is member of the 'administrator' role of your installation and adapt the path to your CSV file.
It's recommented that you set 'dryrun' to '1' in the definition file, to see if everything is fine. If no errors occure, switch 'dryrun' to '0' and start the real import.
If the import (or dry-run) was successfull, you see
reading file test.csv ...done. Imported 1 records. Import failed for 0 records.



