| [06:17:28] | <karna[m]> | Hey Mike, can you suggest how I go about batch adding users who I'm migrating over from our old site? I have usernames and emails and can randomly generate passwords which will be e-mailed out to them |
| [06:17:29] | <karna[m]> | I would then like to use the quick form I've created/modified to add assets for and attribute to them to a specific area which I will point to co-ordinates derived from the postcode data I have and allow users to geometrically plot their growing space |
| [06:22:14] | <karna[m]> | I'm thinking I reconfigure my modular quick form such that it allows the creation of new users in it too and then run a script to batch add all of my people/asset/area data. The only thing I'm unsure about is how I go about attributing assets/areas to a person |
| [06:22:37] | <karna[m]> | like how I can have the form handle that |
| [08:51:23] | <mstenta[m]> | karna: You might want to look into Drush |
| [08:51:43] | <mstenta[m]> | https://www.drush.org/ |
| [08:51:53] | <mstenta[m]> | It is a command line utility for Drupal |
| [08:52:09] | <mstenta[m]> | One of the commands/tools it comes with allows you to run an arbitrary PHP script from the command line |
| [08:52:31] | <mstenta[m]> | So you could create a script that creates all your users, called create-users.php |
| [08:52:43] | <mstenta[m]> | Then run `drush php-script create-users.php` |
| [08:53:01] | <mstenta[m]> | And it will run the script in a fully-bootstrapped Drupal context (so you have access to all Drupal functions, database, etc) |
| [08:53:21] | <mstenta[m]> | > The only thing I'm unsure about is how I go about attributing assets/areas to a person |
| [08:53:46] | <mstenta[m]> | As for this (attributing assets/areas to a person)... |
| [08:54:21] | <mstenta[m]> | farmOS does have a user ID column in the {farm_asset} database table |
| [08:54:44] | <mstenta[m]> | Currently that is not used/displayed anywhere in farmOS - but it does automatically store the user ID of the person who created the asset |
| [08:55:01] | <mstenta[m]> | Areas, on the other hand, do not have any way of being assigned to a particular person currently |
| [08:55:22] | <mstenta[m]> | This is something that's come up before, though - so we should open a feature request for it and discuss |
| [08:55:44] | <mstenta[m]> | In the meantime, you could consider adding your own database table via a custom module, which maintains an association between areas and users |
| [08:56:06] | <mstenta[m]> | Check out Drupal's hook_schema() for adding database tables: https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func... |
| [11:52:00] | <mstenta[m]> | FYI: https://twitter.com/farmOSorg/status/1145721387849527297 |
| [16:25:03] | * JustTB has joined #farmos |
| [17:55:09] | <karna[m]> | mstenta: nice one Mike, thanks for laying it out the steps so clearly for me ^_^ will get to work on it tomorrow |
| [18:01:07] | <mstenta[m]> | Sure thing! Good luck @karna:matrix.org |