Users tables in Joomla 2.5

3,257 views
Skip to first unread message

pierre dechery

unread,
Feb 24, 2012, 3:01:50 PM2/24/12
to joomla-...@googlegroups.com
Hi everyone,

I need to migrate the users from a 1.0 to a 2.5 Joomla site. Not any content, just the users.

Since my original 1.0 jos_users table is very modificated, with many customized fields, I wish to do the migration manually in phpMyAdmin, but I'd like to confirm exactly what tables in Joomla 2.5 need to be updated.

For what I've learned so far, they are:

 
Anyone can help by saying it's ok, and maybe the exact function of each table? I haven't found this information yet, and any help will be much appreciated.

Regards,

Pierre

fornandakishore

unread,
Feb 24, 2012, 11:11:54 PM2/24/12
to joomla-...@googlegroups.com
Hi Pierre,

Yesterday only I have inserted users in to Joomla v2.5.1. As of my knowledge I found two tables (jos_users, jos_user_usergroup_map) are required to insert data.

jos_usergroups - Contains the User groups, you can create more groups from admin area such as Registered, Author, Super Users (etc..)

jos_users - Contains main user information such as name, username, email, password, block etc..

jos_user_usergroup_map - contains mapping to user_id (from jos_users) and group_id (jos_usergrops)

Below is the code written by me to insert data in to these tables using the save function in the custom component model..

                $data = JRequest::get('post');
$userTable = JTable::getInstance('User', 'JTable', $config = array());
$CustomerTable = $this -> getTable();
$userData = array();
$params = JComponentHelper::getParams('com_users');
$useractivation = $params -> get('useractivation');

jimport('joomla.user.helper');
$salt = JUserHelper::genRandomPassword(32);
$pswrd = $data['password'];
$cryptpswrd = JUserHelper::getCryptedPassword($pswrd, $salt);
$dbpassword = $cryptpswrd . ':' . $salt;
$date = date('Y-m-d H:i:s');

if ($data['id'] && $data['customer_id']) {
$userData['id'] = $data['customer_id'];
}
$userData['name'] = $data['first_name'] . ' ' . $data['last_name'];
$userData['username'] = $userData['email'] = $data['email_address'];
if (!empty($data['password'])) {
$userData['password'] = $dbpassword;
}
$userData['block'] = 0;
$userData['registerDate'] = $date;

if (empty($data['id']) && empty($data['customer_id'])) {
// Check if the user needs to activate their account.
if (($useractivation == 1) || ($useractivation == 2)) {
$userData['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
$userData['block'] = 1;
}
}
//echo "<pre>"; print_r($data); print_r($userData); exit ;

// Inserting Data into Users Table
if (!$userTable -> bind($userData)) {
$this -> setError($userTable -> getError());
return false;
}
// Check the data.
if (!$userTable -> check()) {
$this -> setError($userTable -> getError());
return false;
}
// Store the data.
if (!$userTable -> store()) {
$this -> setError($userTable -> getError());
return false;
}
if (empty($data['id']) && empty($data['customer_id'])) {
$userid = $userTable -> get('id');
} else {
$userid = $data['customer_id'];
}
// Inserting Data into Users Group Table
if (empty($data['id'])) {

$sql = "INSERT INTO `#__user_usergroup_map` (`user_id`, `group_id`) VALUES('" . $userid . "','2')";
$this -> _db -> setQuery($sql);
if (!$this -> _db -> query()) {
JError::raiseError(500, $this -> _db -> getErrorMsg());
}
}
// some other code to ..

I guess this may help you.. :)

 
---------------------

Nanda Kishore. M

PHP Developer

http://php-desk.blogspot.com

Ph: + 91 98499 71144 (Cell)




--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-cms/-/3W_qpjDDDCUJ.
To post to this group, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-cm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.

Ofer Cohen

unread,
Feb 25, 2012, 7:49:05 AM2/25/12
to joomla-...@googlegroups.com

Hey

It would be better if you could document all of this info in the wiki.

Thanks.

pierre dechery

unread,
Mar 2, 2012, 9:55:56 AM3/2/12
to joomla-...@googlegroups.com
Hi Nandu,

Thanks a lot for your answer. I was looking for other opinions about these tables. 

Your code seems fine, but I ended up inserting the user via SQL (It worked)

Regards,

Pierre
To post to this group, send an email to joomla-dev-cms@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-cms+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages