Tuesday, March 16, 2010

User Port: upgrades

Been working with the userport extension for joomla and importing 2500 users for a site. This import utility is amazing and saves a ton of time GO GET IT!

I ran into a "feature" that I needed. That feature is to generate random passwords for users on update; when the password field is missing. It also needed to email the new password to the users.

Note: you normally don't want to do this because the import utility automatically loads all the users. Therefore you could accidentally change all your users passwords so be careful.

I chose to modify the userport utility because, well lets face it I'm lazy and making code changes is infinitely more fun than deleting and re-importing records yuk.

Zipped version of the full change for a "quick fix". Oh and it belongs in the folder "administrator\components\com_userport\admin.userport.php"

//change #1 around line 80
//added the userlog to the email body; the userlog contains the new email
'{email_body}' => $params->get( 'message_body_when_notifying_existing_user', JText::_( 'DEFAULT_MESSAGE_BODY_WHEN_NOTIFYING_EXISTING_USER' ) ).
implode( "\n- ", $userLog )

//change #2 around line 228
//create random password on update
else if((bool)$params->get( 'overwrite_password_of_existing_user', false ) == true)

$userData->password  = JUserHelper::genRandomPassword( 12 );
//add the password to the userlog so it can be emailed
$userLog[] = JText::sprintf( 'INFO_PASSWORD_UPDATED', $userData->password );
if((bool)$params->get( 'given_passwords_are_already_encoded', false ) == true )
$userData->password = JUserHelper::getCryptedPassword( $userData->password);

$user->password = $userData->password;


Also fixed a couple of variable warnings caused by missing quotes
//line 446
$title .= JText::_( 'FORM_ADDED_NEW_USERS' ).' ';
//line 450 
$title .= JText::_( 'FORM_UPDATED_EXISTING_USERS').' ';
//line 466
HTML_userport::userportPrintConfiguration( $option, $task, JText::_( 'FORM_CONFIGURATION' ) );
HTML_userport::userportLog( $option, $task, JText::_( 'FORM_RETRIEVED_USERS' ).' '.JText::_( 'FORM_LOG' ), $log );
HTML_userport::userportExport( $option, $task, JText::_( 'FORM_USER_LIST' ), $csvExportString );

I wanted to post this to the project on the project page http://joomlacode.org/gf/project/userport/, or forums but couldn't find a good place on joomlacode.org. Let me know if there is a place for it, i would like to help the community and submit this for the project.

Stumble Upon CodePyro

1 comment:

seekator said...


After upload quick-fix , i`ve got an error
Fatal error: Call to undefined method HTML_userport::userportlog() in /administrator/components/com_userport/admin.userport.php on line 470

Post a Comment