cron job?

emeij - March 28, 2007 - 14:07
Project:User Import
Version:5.x-1.2-beta
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Description

I couldn't find any (substantial) documentation regarding using cron to automatically and regularly import new users. Do I need to put anything in the database directly, or is updating an importfile and defining a template for it enough to trigger importing?

I haven't had time to look through the code, so I was wondering anyone could help me out this way..

#1

Robert Castelo - March 29, 2007 - 10:53

If you have cron running there isn't anything else to do, Drupal does it all for you.

#2

emeij - April 3, 2007 - 08:02

Robert, thanks for your answer. I'm still a bit confused though. What you're saying is that if I succesfully import a .csv file once and update that file later, the cron will pick it up and add the new instances? Or is there more to it?

Many thanks,

Edgar

#3

Robert Castelo - April 6, 2007 - 00:51

You've misunderstood the feature....

User Import module uses cron to import in batches from a large csv file.

For example if your CSV file has 20,000 users - user import can be configured to import 500 user each cron run.

For what you want to do I recommend importing the first file of users, and saving the setting for the import while you do it, then for the next file of users re-use the settings.

#4

emeij - April 6, 2007 - 06:28

You've misunderstood the feature....

Ah, I see... We have a separate registration procedure, hence the need for this kind of functionality. Do you (or anyone else for that matter :-) ) know of a module that does this? Else I will adopt your User Import code to create this...

Thanks, Edgar

#5

Robert Castelo - April 6, 2007 - 10:58
Component:Documentation» Code
Status:by design» active

Could you explain more about what you're trying to do?

#6

emeij - April 9, 2007 - 08:26

Yes. We have a separate, already existing registration procedure (webform). This form generates an e-mail (or outputfile, whichever works easiest) which I'd like to use to insert a new user into our Drupal site. The following functionality should be the same as User Import (viz. generating a welcoming e-mail, assigning a role, etc.) but automated, e.g. through a cron job (Drupal or system-based).

Does that clarify things?

#7

emeij - April 10, 2007 - 14:23

After playing a bit with the idea of creating a new module, I reckoned it would be easiest to adopt your module and change some things. What I did was comment out line 1474 (if ($settings['setting'] == 'import' && !$finished) $settings['setting'] = 'imported';), such that the module thinks it's not finished. Every new user and his details will be appended to the specified file and, at every cron run, the new users will be added according to the chosen settings.

Do you see anything going wrong with this setup? I won't be using the regular interface anyway, so there's no harm done there..

Edgar

#8

Robert Castelo - April 10, 2007 - 21:09
Status:active» by design

Main disadvantages are:
Security - not good to keep the data file on the server, ideally it should be deleted once import is complete (something I'm working on)
Maintenance - you'll have to keep making changes every time the module is updated.

I'd recomend writing a custom module, look at user.module to see how.

#9

emeij - April 11, 2007 - 06:53
Status:by design» closed

Security - not good to keep the data file on the server, ideally it should be deleted once import is complete (something I'm working on)

True. I'm protecting it with chmod and .htaccess, so it's safe enough for the time being.

Maintenance - you'll have to keep making changes every time the module is updated. I'd recomend writing a custom module, look at user.module to see how.

Of course there's always the issue of not having enough time. In an ideal world... :-)

Thanks for all the help and comments!

Best, Edgar

#10

flamingvan - February 1, 2010 - 18:58

I did it by adding these lines to cron.php:

$import = _user_import_settings_select(10);
_user_import_initialise_import($import);

 
 

Drupal is a registered trademark of Dries Buytaert.