Then help me bridge the gap. I'd love to use my creative energy to program simple snippets. I've always liked marrying the creative with the technical. I just don't know how!
UltraSEF, for one I think it's a much harder thing to learn to program and create the most intuitive and efficient processes for creating a dynamic system. Personally, I'm studying a language called Scheme in a class I'm taking now and I can tell you it's been hugely rewarding (if that's what you meant by bridge the gap!). But I do agree about the importance and share a similar love for the other aspects of development.
As to the snippet, my problem is not with the idea of looking at his snippet (though I don't know fully know the best way for that besides github. The problem is with my understanding of how the backend creates a user in Revolution. There's parts that I haven't understood that are critical for making the loop work. Besides that, there seem to be other problems but I'm not sure. I was hoping some higher-end dev's who really know ModX might comment and shed some light on the problems.
[ed. note: silverman63 last edited this post 14 years, 7 months ago.]
Most of your answers to this will be in the core/model/modx/processors/ folder, specifically in this case security/user/create.php for pre-2.2, or security/user/create.class.php for 2.2+. This is the processor the manager uses when creating a new user.
$scriptProperties ($properties for 2.2) is an array containing all the form data posted to the processor when you hit the 'save' button in the manager. Your job really is to load the user data from your csv into this array and then use a variation of the create processor to write the new user to the system using this data.
I suggested to modify ImportX as it might save you a bit of time working out how to implement the CMP as a nice interface to facilitate importing your users.
Thanks for the encouragement silverman63 and Lucas.
I'm reading Chapters 7 & 8 in BobRay's most excellent book. This old dog is very ready to learn new tricks.
-
☆ A M B ☆
- 3,141 Posts
I actually did a quicky for a client that does just that.. 7 months ago. If only I'd seen this topic in that time!
I put it up on Gist, except I hit the "Create Private Gist" instead of the "Create Public Gist" button, so it doesn't actually show up in the public list :/
Aaaanyway:
https://gist.github.com/1f3056c2f7897dbe8beb
There's some comments in there to help you through it. I know there's also a comment that says it's untested, but I've been sharing that link every now and then with people and they've all said it works.. so I guess it does.
I wonder if it would be nice to update ImportX to allow importing users (that gist does most of the hard work anyway, just need an updated UI that parses CSV to the arrays).. if enough people say they want me to, I might!
-
☆ A M B ☆
- 3,141 Posts
Quote from: okyanet at Feb 14, 2012, 03:44 AMMost of your answers to this will be in the core/model/modx/processors/ folder, specifically in this case security/user/create.php for pre-2.2, or security/user/create.class.php for 2.2+. This is the processor the manager uses when creating a new user.
That does bring to mind the ability of just reusing the processor...
$user = array(
'username' => 'test',
'password' => 'omghithere',
'fullname' => 'Test User',
'email' => '[email protected]',
);
$result = $modx->runProcessor('security/user/create',$user);
if ($result->isError()) {
echo $result->getMessage();
} else {
echo 'Created user!';
}
$scriptProperties ($properties for 2.2) is an array containing all the form data posted to the processor when you hit the 'save' button in the manager.
Did that really change in 2.2? Can't remember noticing that, but have been working with 2.2 for a few months now!
How does your snippet get the array?
-
☆ A M B ☆
- 3,141 Posts
Quote from: ultrasef at Feb 15, 2012, 05:13 AMHow does your snippet get the array?
That's the part that would have to be customized depending on your need. As long as what you feed to that gist is in the format of that array, the rest should work. Which was the idea of putting that in.
In ImportX this process function is called for taking the raw CSV content (stored in $this->data) and parsing that, validating it and returning an array similar to what the user import needs, except for resources of course:
https://github.com/Mark-H/importX/blob/master/core/components/importx/processors/prepare/csv.php
I'm not sure if a snippet is the best idea in terms of creating an import script, and a CMP like ImportX would probably be easiest.. especially if we want to move it into the extras repository

The gist I posted can help people with a quick one-off import though, all they need to do is format their data to the arrays.