Hi JomSocial
There is a problem with my JomSocial and Joomla.
I have created a custom Joomla User Group. I assign some of my users into this Joomla User Group.
When user interacts with JomSocial Group, user is removed from Joomla User Group and returned back to a standard Joomla Registered User.
I believe this is a problem with JomSocial.
I am using a brand new clean install of latest version of Joomla 3.3.6, & clean install on latest version of JomSocial v3.2.1.5.
For your reference i am also running my own server with following PHP Version: 5.5.9 -1ubuntu4.5
This is a problem that needs to be addressed, it is important that my users remain in the assigned Joomla User Group, that they are assigned into.
I have seen your Changelog, and was led to believe you had rectified this problem, yet it continues to persist.
Thank you, please help to resole this problem. Your help and support is hugely appreciated.
Thank you again!
Hi Mark,
Please you try open this file components/com_community/libraries/user.php, add this code
$jUser->groups = null;
$jUser->save();
HI Mark,
I am replying to this post to let you know that we have looked further into this issue and late yesterday we discovered that this is, in fact a bug in Joomla and not Jomsocial. To help our own customers we have written a temporary fix. This fix is Joomla code and not Jomsocial. We have also submitted the fix to joomla.org and I would recommend that you vote on this submission. Without votes for the fix, Joomla may not implement the code before their next release. What they do is beyond our control as the bug is not in our product as many users are suggesting.
Below is the code that we have changed which we have tested only on joomla 3.3.3 and joomla 3.3.6
This is the link to the joomla bug submission
issues.joomla.org/tracker/joomla-cms/5138
The fix below should be applied only after backing up your entire site. The initial fix you may have been given will also work in some circumstances, but please note that we will not be adding the first fix into our release as it can cause issues with some 3rd party plugins.
The file to modify is siteroot/libraries/joomla/table/user.php
* @link http://docs.joomla.org/JTable/store
* @since 11.1
*/
public function store($updateNulls = false)
{
// Get the table key and key value.
$k = $this->_tbl_key;
$key = $this->$k;
// TODO: This is a dumb way to handle the groups.
// Store groups locally so as to not update directly.
$groups = $this->groups;
unset($this->groups);
// Insert or update the object based on presence of a key value.
if ($key)
{
// Already have a table key, update the row.
$this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
}
else
{
// Don't have a table key, insert the row.
$this->_db->insertObject($this->_tbl, $this, $this->_tbl_key);
}
// Reset groups to the local object.
$this->groups = $groups;
unset($groups);
$query = $this->_db->getQuery(true);
// Store the group data if the user data was saved.
if (is_array($this->groups) && count($this->groups))
{
// Delete the old user group maps.
$query->delete($this->_db->quoteName('#__user_usergroup_map'))
->where($this->_db->quoteName('user_id') . ' = ' . (int) $this->id);
$this->_db->setQuery($query);
$this->_db->execute();
// Set the new user group maps.
$query->clear()
->insert($this->_db->quoteName('#__user_usergroup_map'))
->columns(array($this->_db->quoteName('user_id'), $this->_db->quoteName('group_id')));
// Have to break this up into individual queries for cross-database support.
foreach ($this->groups as $group)
{
$query->clear('values')
->values($this->id . ', ' . $group);
$this->_db->setQuery($query);
$this->_db->execute();
}
}
// If a user is blocked, delete the cookie login rows
if ($this->block == (int) 1)
{
$query->clear()
->delete($this->_db->quoteName('#__user_keys'))
->where($this->_db->quoteName('user_id') . ' = ' . $this->_db->quote($this->username));
$this->_db->setQuery($query);
$this->_db->execute();
}
return true;
}
/**
* Method to delete a user, user groups, and any other necessary data from the database.
*
public function store($updateNulls = false)
{
// Get the table key and key value.
$k = $this->_tbl_key;
$key = $this->$k;
// TODO: This is a dumb way to handle the groups.
// Store groups locally so as to not update directly.
$groups = $this->groups;
unset($this->groups);
// Insert or update the object based on presence of a key value.
if ($key)
{
// Already have a table key, update the row.
$this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
}
else
{
// Don't have a table key, insert the row.
$this->_db->insertObject($this->_tbl, $this, $this->_tbl_key);
}
// Reset groups to the local object.
$this->groups = $groups;
unset($groups);
$query = $this->_db->getQuery(true);
// Update the group data if the user data was saved.
if (is_array($this->groups) && count($this->groups))
{
// Grab all usergroup entries for the user
$query -> clear()
-> select('*')
-> from($this->_db->quoteName('#__user_usergroup_map'))
-> where($this->_db->quoteName('user_id') . ' = ' . (int) $this->id);
$this->_db->setQUery($query);
$result = $this->_db->loadObjectList();
// Loop through them and check if database contains something $this->groups does not
if(sizeof($result)) {
foreach($result as $map) {
if(array_key_exists($map->group_id, $this->groups)) {
// it already exists, no action required
unset($this->groups[$map->group_id]);
} else {
// it should be removed
$query -> clear()
-> delete($this->_db->quoteName('#__user_usergroup_map'))
-> where($this->_db->quoteName('user_id') . ' = ' . (int) $this->id)
-> where($this->_db->quoteName('group_id') . ' = ' . (int) $map->group_id);
$this->_db->setQuery($query);
$this->_db->execute();
}
}
}
// If there is anything left in this->groups it needs to be inserted
if(sizeof($this->groups)) {
// Set the new user group maps.
$query->clear()
->insert($this->_db->quoteName('#__user_usergroup_map'))
->columns(array($this->_db->quoteName('user_id'), $this->_db->quoteName('group_id')));
// Have to break this up into individual queries for cross-database support.
foreach ($this->groups as $group) {
$query->clear('values')
->values($this->id . ', ' . $group);
$this->_db->setQuery($query);
$this->_db->execute();
}
}
}
return true;
}
/**
* Method to delete a user, user groups, and any other necessary data from the database.
*