Gossamer Forum
Home : Products : Others : Gossamer Community :

Tweak to import routines

Quote Reply
Tweak to import routines
I struggled with importing some users, and figured out a few things.

There are a lot of incompatibility between apps, and one is the user names. Usernames in GForum default to 15 character limits, it seems, and Links has no limits, and allows email addresses as user names, which is not allowed in Community, etc.

Changing the Community::Import::Common.pm to record, and disallow those bad names is a start in cleaning up the new community install.

Code:

require Community::User; ## added
foreach ( @$values ) {
my $hash = generate_hash( $fields, $_, $encrypt);
if ( $CFG->{admin_username} eq $hash->{comm_username} ) {
push @declined, { name => "$hash->{comm_username} <$hash->{comm_email}>", error => 'Duplicate' };
}
elsif ( $db_comm->get({ comm_username => $hash->{comm_username} }) ) {
push @declined, { name => "$hash->{comm_username} <$hash->{comm_email}>", error => 'Duplicate' };
}
elsif ( Community::User::cuser_un_validate_error($hash->{comm_username}) ) { ##
push @declined, { name => "$hash->{comm_username} <$hash->{comm_email}>", error => 'Bad UserName' }; ##
} ##

elsif ( $db_comm->add($hash) ) {
push @imported, { name => "$hash->{comm_username} <$hash->{comm_email}>" };
if ( $callback and ref($callback) eq 'CODE') {
eval { $callback->($hash->{comm_username}, $hash->{comm_email}) };
}
}
else {
push @declined, { name => "$hash->{comm_username} <$hash->{comm_email}>", error => $GT::SQL::error };
}


Adding in the RED areas above, will disallow, and write out user names that do not pass the new community standard for user names. These users will not be imported.

You can then delete those users (carefully) or edit the user names, or do whatever you want, but at least the user won't generate an error in the Community screen with their user names.

I may have more screening code, including deleting links users who are not registered, and not imported, but if they have links, switch the links over to "Admin" before deleting them.

Then, the user can re "claim" those links under a new user name that conforms to the program.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.