Anyway, the problem that I encounter is I don't want Agora using my Joomla username, but I prefer it to use Joomla name. But I've never found any settings or configurations about this. So the only way is to hack it a little. It is kinda hard to find where the code to change it, since I am not so familiar with its code anyway. But at least today, I've successfully change it to using name :D
I am not sure whether this setting is already sufficient or not. So there might be a additional hack in the future.
First of all I must create a function that change all the username in #__agora_users to name of #__users. For me, I create a component called com_tar_setforum in administrator, and put the code like this.
class Tar_setforumController{
...
function setUsername(){
$model = & $this->getModel('forum');
foreach($model->listIdUsers() as $value){
$model->updateUsername($value);
}
$link = JRoute::_('index.php?option=com_tar_setforum');
$this->setRedirect($link,'Nama berhasil di-set');
$this->redirect();
}
....
}
And put a model with function like this :
class Tar_setforumModelForum extends JModel{
function updateUsername($jos_id){
$query = "UPDATE #__agora_users SET username=(SELECT name FROM #__users WHERE id='$jos_id')
WHERE jos_id='$jos_id'";
$this->_db->Execute($query);
}
.....
But only update the name in the #__agora_users doesn't solve the problem. Somehow everytime users access the forum, the table is updated to old value. That's why we need to hack the Agora code.
Here what I change the code :
/components/com_agora/model/user.php
function loadCurrent(){
....
// Update loaded user to not load it again
foreach ($data as $param=>$value) {
$user[$param] = $value;
}
//Here my additional code
$user['username'] = $my->name;
$data['username'] = $my->name;
$this->edit($user['id'],$data);
....
}
and one more
/components/com_agora/model/online.php
function getOnline()
{
....
/*$query = 'SELECT a.id, a.username' .
' FROM #__session AS s INNER JOIN ##__users AS a ON s.userid=a.jos_id' .
' WHERE client_id = 0 AND s.guest=0';
*///commented. This is the old one. Replace with below codes
$query = 'SELECT a.id, u.name
FROM #__session AS s INNER JOIN ##__users AS a ON s.userid=a.jos_id
INNER JOIN #__users AS u ON u.id=s.userid
WHERE client_id = 0 AND s.guest=0';
....
if (count($sessions)) {
foreach ($sessions as $session) {
//$user_array[] = array('id' => $session->id, 'name' =>$session->username); //commented by Xiong
$user_array[] = array('id'=> $session->id, 'name'=>$session->name);
}
}
....
}
After changing this, it should can preserve the username in #__agora_users