The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Aug 22, 2005 11:20 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Aug 17, 2005 10:13 pm
Posts: 871
Location: Lexington, VA
I have revised the kick-start instructions provided by ch8667 in an old thread on this subject:

Note: These kick-start instructions are for MamboImportScript.zip. If you use mambo_import_with_dupecheck_and_email.zip you will want to customize the email that is sent to the new users before uploading the PHP script.


1) Upload the PHP script and the .csv file onto your webserver
2) Enter the URL to the script in your browser

Wayne Stewart, the creator of these two scripts, explains some details about these scripts:
[quote="Wayne Stewart"]It does not matter whether the delimiter is [,] or [","]. Either will work. Just avoid mixing them in the same CSV file.

Excel is good for working with and/or creating CSV files. You can open CSV files easily in Excel. In fact, Excel usually associates itself with the .csv file extension.

To save any file you are working on in Excel as a CSV choose File->Save As->Save As Type: CSV (Comma Delimited). Excel will give the file a CSV extension and save the file with proper delimiting for text and numbers etc.

Excel doesn't normally show the delimiters themselves while editing the file. You can check the CSV file that Excel creates by opening it with either Notepad (c:\windows\system32\notepad.exe) or WordPad (c:\windows\system32\write.exe) or any text editor. Either will show the CSV in its "raw" state.

For the script to work there must be three fields on each line of the CSV file. The proper order is:
MamboUserName, Full Name, user's@emailaddress

In CSV files text strings are usually quoted. This script will still work if they are not. The script will assume that the fields in a record are in this order. It will ignore any fields after the third one.

Make sure you have no column header row in the file. In Excel it should look like this:
Image

Don't worry about how wide the columns are as long as you can see all the data. Save it as a CSV using File->Save As->Save As Type: CSV (Comma Delimited) and Excel will format it properly.

The only issue you MAY find is the one about deleting users and having their user ID corrupted because of the way Mambo leaves orphan records behind in one of their tables. This post details that issue and the suggested fix for it. It is unlikely that you will need this.[/quote]

I must include the point made by dogslife in an old thread on this subject. He said that you might also consider including "your grandmother's low-sodium Hash recipe in the email." There you have it.

Here is the plain import script:
http://www.nuthinwerked.com/images/osm_ ... Script.zip

Here is the import script that checks for duplicates and send the new user a customizable email with their login info:
http://www.nuthinwerked.com/images/osm_ ... _email.zip

A thread on a seldomly used server that contains lots of info on these scripts is also available here:
http://forum.mamboserver.com/showthread.php?t=17358

_________________
http://gigcalendar.net: the world's first free solution for maintaining a touring calendar for Joomla!


Last edited by gsbe on Mon Aug 22, 2005 11:44 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Aug 22, 2005 11:38 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Aug 17, 2005 10:13 pm
Posts: 871
Location: Lexington, VA
I will work with anyone that plans on maintaining these scripts to provide a location to download them from. Currently, you cannot attach .zip files to posts...this is why I am linking to these files offsite for now. FYI, access to these files may be down for a few hours over the next 24. Sorry...working out some issues.

_________________
http://gigcalendar.net: the world's first free solution for maintaining a touring calendar for Joomla!


Top
 Profile  
 
PostPosted: Mon Aug 22, 2005 11:43 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Aug 17, 2005 10:13 pm
Posts: 871
Location: Lexington, VA
These are some interesting comments from script developer Wayne Stewart regarding re-using id numbers:

[QUOTE=Wayne Stewart]Good question Steven!

After reading your question something nagged at the back of my mind because I had a similar question when I was writing the script. To avoid re-using id numbers I used this code:

Code:
// Create new starting "id" number for mos_users table by
// getting the current highest id number and adding 1
$current_id = mysql_query('SELECT MAX(id) FROM mos_users');
while ($row = mysql_fetch_array($current_id)) {
    $old_id = $row[0];
    $new_id = $old_id + 1;
    print ("<p>Current highest 'id' in mos_users is: " . $row[0]);
    print ("<br>The new 'id' numbers will start at: " . $new_id) . "<br>";
}


However you're quite right about what might happen if you delete users THEN use this script. That's much sloppier database programming than I've come to expect from the Mambo development team. After all, maintaining "referential integrity" is a cornerstone of proper database application design. Orphans shouldn't happen, period.

There is a way around this though. Just get the id value from the table that ISN'T updated when you delete a user, like the mos_core_acl_aro table for example.

So the code above becomes:

Code:
// Create new starting "id" number for mos_users table by
// getting the current highest id number and adding 1
$current_id = mysql_query('SELECT MAX(aro_id) FROM mos_core_acl_aro');
while ($row = mysql_fetch_array($current_id)) {
    $old_id = $row[0];
    $new_id = $old_id + 1;
    print ("<p>Current highest 'id' in mos_users is: " . $row[0]);
    print ("<br>The new 'id' numbers will start at: " . $new_id) . "<br>";
}


It's unfortunate that it's necessary, but it would work.

As for the orphans, I don't know what harm would be done by deleting them. I suspect that they aren't used for anything once their respective user record is deleted but you would need to check with a member of the dev team to be certain.

Thanks for pointing this out Steven!

Wayne

[QUOTE=candoit]Hello all,

When a new user is created, a record is created in the database for that user in 3 different tables. When the User is deleted by an Administrator in the Backend, the user record (also known as a "row") in the database is only removed from the mos_users table.

A row for the user remains in the mos_core_acl_aro table and in the mos_core_acl_groups_aro_map table.

At least this is the way it is working in my Mambo v 4.5.2.1

Is this the way it is supposed to be? If it is, what data or actions are associated with the records in these 2 tables that are being maintained for the, now deleted, user?

This is IMPORTANT IN REGARDS TO THIS SCRIPT for mass importing of users. If the admin has deleted users in the User Manager and then tries to use the script, an error occurs because MySQL can't create a new record in mos_core_acl_aro or in mos_core_acl_groups_aro_map because the id# from mos_user has already existed and is used in the field "section_value_value_aro" which must be unique and in "group_id_aro_id_groups_aro_map" which also must be unique. Basically what seems to be happening is that MySQL is reusing the ID# of the deleted user but then, since that ID is used in the other tables, can't create the corresponding records in those other tables.

So, any thoughts?

Also, would problems be created by deleting those rows manually? I don't think so since I have done so already.
I assume that, if I create a user and immediately delete the user before they have done anything on the system, I may delete the mos_core_acl_aro and the mos_core_acl_groups_aro_map records for that user with impunity. What about latter? If they are not used for anything after the user is deleted from the mos_users table then they should be removed from the other tables too. I just hate to have orphaned records in my database and as we can see, it can create problems.


Thank you very much for your time.

I really appreciate this forum. I have learned so much from this thread in particular.

Steven[/QUOTE]
[/QUOTE]

_________________
http://gigcalendar.net: the world's first free solution for maintaining a touring calendar for Joomla!


Top
 Profile  
 
PostPosted: Tue Aug 30, 2005 10:08 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Aug 23, 2005 9:54 am
Posts: 219
Location: Oslo
http://forum.opensourcematters.org/inde ... 828.0.html

_________________
Did you know there's a Joomla irc channel? Chat to Joomla people live 24/7 - Join #joomla on the Freenode network ( irc.freenode.net )


Top
 Profile  
 
PostPosted: Mon Feb 20, 2006 6:52 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Aug 22, 2005 8:56 pm
Posts: 225
Bringing up an old and important topic. Hope this is the right place for it.

I am trying - quite desperately - to import 1100 users into my Joomla 1.0.7 site and email these existing users their log-in data (so I do not have to do it manually).

After much research here and on mambo boards (see: http://forum.mamboserver.com/showthread ... ser+import) I found a wonderful little component callec com_importusers_03.

I tested that component on a test server running Joomla 1.0.5 and it worked like a charm!
But when I installed on my live 1.0.7 site I get the following errors:

Code:
PHP Version : 4.4.1
PHP Version OK
Uploads are allowed in this environment
File type: csv

Warning: move_uploaded_file(/home/myserver/public_html/site/test_userlist.csv): failed to open stream: Permission denied in /home/myserver/public_html/site/administrator/components/com_importusers/admin.importusers.php on line 60

Warning: move_uploaded_file(): Unable to move '/tmp/phpFzMsX6' to '/home/myserver/public_html/site/test_userlist.csv' in /home/myserver/public_html/site/administrator/components/com_importusers/admin.importusers.php on line 60
Mode: Actual import
Connected to Mambo Database at: localhost.myserver_joom1

Current highest 'id' in jos_users is: 71
The new 'id' numbers will start at: 72

Warning: fopen(/home/myserver/public_html/site/test_userlist.csv): failed to open stream: No such file or directory in /home/myserver/public_html/site/administrator/components/com_importusers/admin.importusers.php on line 275

Warning: fgetcsv(): supplied argument is not a valid stream resource in /home/myserver/public_html/site/administrator/components/com_importusers/admin.importusers.php on line 278

Warning: fclose(): supplied argument is not a valid stream resource in /home/myserver/public_html/site/administrator/components/com_importusers/admin.importusers.php on line 375

0 users added to the Mambo Database


Any ideas what I need to do to make this work? I'm not a programmer, so opted for this component instead of Wayne's import script (this com is actually a wrapper of Wayne's import script -- details are in the thread linked above).

Would DEEPLY appreciate any help possible as I have a client expecting that I know what I'm doin' ;) and I really don't want to manually add 1100 users and then individually email them with their username and password.

THANKS!!


Top
 Profile  
 
PostPosted: Mon Feb 20, 2006 7:40 pm 
User avatar
Joomla! Master
Joomla! Master
Online

Joined: Thu Aug 18, 2005 7:13 am
Posts: 16285
Have you tried juice? http://developer.joomla.org/sf/projects/juice

_________________
Joomla forum global moderator.

Take care


Top
 Profile  
 
PostPosted: Mon Feb 20, 2006 7:56 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Aug 22, 2005 8:56 pm
Posts: 225
I have tried JUICE but it does not provide the functionality to email the username/passwords to each member. JUICE works GREAT otherwise ...


Top
 Profile  
 
PostPosted: Thu May 04, 2006 12:25 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Nov 06, 2005 5:27 am
Posts: 7
If you are using Community builder then you will have to alter the csv import script to add users to the CB table too!
: around line 140 you'll have to add a line like:

mysql_query("INSERT INTO jos_comprofiler (id, user_id, firstname, hits, avatarapproved, approved, confirmed, banned, acceptedterms)  VALUES ('$new_id', '$new_id', '$name',0,1,1,1,0,1") or die("
CB table not updated. Error is: " . mysql_error());

Also note that default joomla installation prefixed the database tables with a jos_ rather than a mos_ as in the script (another thing to change in these lines 133-140.

Hope this helps someone!

rgds -j


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 



Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group