Teamspeak Integration

Teamspeak Integration 1.3.8 Alpha

No permission to download

silence

Well-known member
Its okay!

Let me know what you think about the other idea.

Also uninstalling the addon and reinstalling it fixes the upgrade problem, but I don't think users should have to remove it to update to a new version.
No I fixed that issue. I'm uploading the fix now :)
And about the secondary group feature, I don't know what in XF decides the top usergroup, but I can make it so it assigns all the usergroups that the user has, but that's not what you want correct?
 

The Dark Wizard

Well-known member
No I fixed that issue. I'm uploading the fix now :)
And about the secondary group feature, I don't know what in XF decides the top usergroup, but I can make it so it assigns all the usergroups that the user has, but that's not what you want correct?

Yes thats what I want actually. How soon can you make it?

This way I will just not attach a ts group id to the primary group.

And give new accounts a secondary group for our red star(this is limited group on our server). Once they make soem posts on xF, that red star group gets taken away, and thus on TS and then a golden star group is given(These are active site members).

Also I don't know if this is a problem but as a test, I gave a group 3 identities and then i attached some, reduced it back to 1 and the identities did not go done.
 

silence

Well-known member
Yes thats what I want actually. How soon can you make it?

This way I will just not attach a ts group id to the primary group.

And give new accounts a secondary group for our red star(this is limited group on our server). Once they make soem posts on xF, that red star group gets taken away, and thus on TS and then a golden star group is given(These are active site members).

Also I don't know if this is a problem but as a test, I gave a group 3 identities and then i attached some, reduced it back to 1 and the identities did not go done.
I'm confused what exactly did you do? I made 3 connections and linked them to my account, then removed em and they all went away :C
If you join my server you can see it happen. It removes all servergroups from that user and then assigns the requested ones to the identities given in the user's account.
 

The Dark Wizard

Well-known member
I'm confused what exactly did you do? I made 3 connections and linked them to my account, then removed em and they all went away :C
If you join my server you can see it happen. It removes all servergroups from that user and then assigns the requested ones to the identities given in the user's account.

I mean that I added 3 identifies as a user, but I did not remove them. Instead I went to the admin control panel and lowered the amount of identities that group can have. My user test account still retained 3 of them.

I was just asking if thats a bug.

Also what do you think of making it so that Secondary groups count as well?
 

silence

Well-known member
I mean that I added 3 identifies as a user, but I did not remove them. Instead I went to the admin control panel and lowered the amount of identities that group can have. My user test account still retained 3 of them.

I was just asking if thats a bug.

Also what do you think of making it so that Secondary groups count as well?
Yes that is a bug, I will work on that in the next release. When you say secondary groups, my issue is that you want them to have 2 usergroups but only one star in teamspeak. So what if the user has 3 secondary groups (as I mentioned above) and which takes priority over the other, or do they get all those assignments in Teamspeak?
 

The Dark Wizard

Well-known member
Yes that is a bug, I will work on that in the next release. When you say secondary groups, my issue is that you want them to have 2 usergroups but only one star in teamspeak. So what if the user has 3 secondary groups (as I mentioned above) and which takes priority over the other, or do they get all those assignments in Teamspeak?

They would get them all.

Its up to the person who is using the addon to properly set up permissions. In my case I know how to set it up so that the promotion system will never allow people to have more then one at once.

However if people want to give three groups to someone, then I can see the benefit in that.
 

silence

Well-known member
They would get them all.

Its up to the person who is using the addon to properly set up permissions. In my case I know how to set it up so that the promotion system will never allow people to have more then one at once.

However if people want to give three groups to someone, then I can see the benefit in that.
But with your promotion system, is that user assigned a new primary group or given a secondary group?
 

The Dark Wizard

Well-known member
But with your promotion system, is that user assigned a new primary group or given a secondary group?

xenforo does not allow you to chance primary groups. In my case i'd just make my regular usergroup NOT have a teamspeak id. Everything would be done by removing/adding second groups.

If I ever needed to manually change someone's primary group I will(I will be doing that for admins/mods, since I will not allow their permissions to be handled automatically by the system).

Edit: Who are you on your TS server? I'm online :D!
 

silence

Well-known member
xenforo does not allow you to chance primary groups. In my case i'd just make my regular usergroup NOT have a teamspeak id. Everything would be done by removing/adding second groups.

If I ever needed to manually change someone's primary group I will(I will be doing that for admins/mods, since I will not allow their permissions to be handled automatically by the system).

Edit: Who are you on your TS server? I'm online :D!
Alright I'll work on that and see what I can come up with in a day or 2!
I'm Rhododendron :p
 

The Dark Wizard

Well-known member
Alright I'll work on that and see what I can come up with in a day or 2!
I'm Rhododendron :p

Sweet.

Just make it so that when someone receives a new group, it gets added to them on TS however it does not remove other groups(Unless that group went away).

This way you have something really flexible.

I will be online for the next few hours if you manage to create something, I'd be willing to test it.
 

silence

Well-known member
Sweet.

Just make it so that when someone receives a new group, it gets added to them on TS however it does not remove other groups(Unless that group went away).

This way you have something really flexible.

I will be online for the next few hours if you manage to create something, I'd be willing to test it.
Oh I'm setting it so it removes all server groups. Since new servers would be using it, I figured that it would be easier just to remove any manually set servergroups. I won't be able to do much more development tonight, I got a hectic schedule tomorrow but I'll update ya when I start!
 

The Dark Wizard

Well-known member
Oh I'm setting it so it removes all server groups. Since new servers would be using it, I figured that it would be easier just to remove any manually set servergroups. I won't be able to do much more development tonight, I got a hectic schedule tomorrow but I'll update ya when I start!

Okay :)!
 

The Dark Wizard

Well-known member
Oh I'm setting it so it removes all server groups. Since new servers would be using it, I figured that it would be easier just to remove any manually set servergroups. I won't be able to do much more development tonight, I got a hectic schedule tomorrow but I'll update ya when I start!

The addon currently creates a server error when trying to run the user promotion cron

Server Error
invalid group ID

  1. TeamSpeak3_Adapter_ServerQuery_Reply->fetchError() in Teamspeak/API/Adapter/ServerQuery/Reply.php at line 91
  2. TeamSpeak3_Adapter_ServerQuery_Reply->__construct() in Teamspeak/API/Adapter/ServerQuery.php at line 141
  3. TeamSpeak3_Adapter_ServerQuery->request() in Teamspeak/API/Node/Abstract.php at line 73
  4. TeamSpeak3_Node_Abstract->request() in Teamspeak/API/Node/Server.php at line 90
  5. TeamSpeak3_Node_Server->request() in Teamspeak/API/Node/Abstract.php at line 97
  6. TeamSpeak3_Node_Abstract->execute() in Teamspeak/API/Node/Server.php at line 1223
  7. TeamSpeak3_Node_Server->serverGroupClientAdd() in Teamspeak/Helper/Query.php at line 69
  8. Teamspeak_Helper_Query->_addUser() in Teamspeak/Helper/Query.php at line 36
  9. Teamspeak_Helper_Query->_updateServerGroup() in Teamspeak/DataWriter/User.php at line 13
  10. Teamspeak_DataWriter_User->setSecondaryGroups() in XenForo/Model/User.php at line 1388
  11. XenForo_Model_User->_applyUserGroupChanges() in XenForo/Model/User.php at line 1248
  12. XenForo_Model_User->addUserGroupChange() in XenForo/Model/UserGroupPromotion.php at line 232
  13. XenForo_Model_UserGroupPromotion->promoteUser() in XenForo/CronEntry/UserGroupPromotion.php at line 64
  14. XenForo_CronEntry_UserGroupPromotion::runPromotions()
  15. call_user_func() in XenForo/Model/Cron.php at line 356
  16. XenForo_Model_Cron->runEntry() in XenForo/ControllerAdmin/Cron.php at line 204
  17. XenForo_ControllerAdmin_Cron->actionRun() in XenForo/FrontController.php at line 313
  18. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  19. XenForo_FrontController->run() in /home/rpdom/public_html/admin.php at line 13
 

silence

Well-known member
The addon currently creates a server error when trying to run the user promotion cron

Server Error
invalid group ID

  1. TeamSpeak3_Adapter_ServerQuery_Reply->fetchError() in Teamspeak/API/Adapter/ServerQuery/Reply.php at line 91
  2. TeamSpeak3_Adapter_ServerQuery_Reply->__construct() in Teamspeak/API/Adapter/ServerQuery.php at line 141
  3. TeamSpeak3_Adapter_ServerQuery->request() in Teamspeak/API/Node/Abstract.php at line 73
  4. TeamSpeak3_Node_Abstract->request() in Teamspeak/API/Node/Server.php at line 90
  5. TeamSpeak3_Node_Server->request() in Teamspeak/API/Node/Abstract.php at line 97
  6. TeamSpeak3_Node_Abstract->execute() in Teamspeak/API/Node/Server.php at line 1223
  7. TeamSpeak3_Node_Server->serverGroupClientAdd() in Teamspeak/Helper/Query.php at line 69
  8. Teamspeak_Helper_Query->_addUser() in Teamspeak/Helper/Query.php at line 36
  9. Teamspeak_Helper_Query->_updateServerGroup() in Teamspeak/DataWriter/User.php at line 13
  10. Teamspeak_DataWriter_User->setSecondaryGroups() in XenForo/Model/User.php at line 1388
  11. XenForo_Model_User->_applyUserGroupChanges() in XenForo/Model/User.php at line 1248
  12. XenForo_Model_User->addUserGroupChange() in XenForo/Model/UserGroupPromotion.php at line 232
  13. XenForo_Model_UserGroupPromotion->promoteUser() in XenForo/CronEntry/UserGroupPromotion.php at line 64
  14. XenForo_CronEntry_UserGroupPromotion::runPromotions()
  15. call_user_func() in XenForo/Model/Cron.php at line 356
  16. XenForo_Model_Cron->runEntry() in XenForo/ControllerAdmin/Cron.php at line 204
  17. XenForo_ControllerAdmin_Cron->actionRun() in XenForo/FrontController.php at line 313
  18. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  19. XenForo_FrontController->run() in /home/rpdom/public_html/admin.php at line 13
I'm not getting that error, did you put in an invalid group id? Nevertheless, I'll set it to ignore that error so even if you set it wrong, your entire forum won't mess up.
Here is a fix though to ignore the error (next release but too many update version's!)
Overwrite the file library/Teamspeak/Helpers/Query.php with this:
PHP:
<?php

require_once("./library/Teamspeak/API/TeamSpeak3.php");
TeamSpeak3::init();
class Teamspeak_Helper_Query
{
    protected function _queryInstance()
    {
        $serverinfo = array(
            'serverip' => XenForo_Application::get('options')->teamspeak_serverip,
            'udp' => XenForo_Application::get('options')->teamspeak_udp,
            'tcp' => XenForo_Application::get('options')->teamspeak_query,
            'user' => XenForo_Application::get('options')->teamspeak_queryuser,
            'password' => XenForo_Application::get('options')->teamspeak_querypassword,
        );
        $nickname = mt_rand();
        $ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$serverinfo['user'].":".$serverinfo['password']."@".$serverinfo['serverip'].":".$serverinfo['tcp']."/?server_port=".$serverinfo['udp']."&nickname=".$nickname);
        return array(
            'ts3_VirtualServer' => $ts3_VirtualServer,
            'info' => $ts3_VirtualServer->getInfo(),
        );
    }
    public function _updateServerGroup($user_id, $new_auth_id, $old_auth_id = false)
    {
        if ($old_auth_id != false)
        {
            $this->_removeUser($old_auth_id);
        }
        $this->_removeUser($new_auth_id);
        $this->_addUser($user_id, $new_auth_id);
    }
    public function _addUser($user_id, $auth_id)
    {
        $instance = $this->_queryInstance();
        try
        {
            if (!empty($auth_id))
            {
                foreach ($auth_id as $info)
                {
                    $identity = $this->_verifyUser($info);
                    if (!$identity)
                    {
                        continue;
                    }
                    $userModel = XenForo_Model::create('XenForo_Model_User');
           
                    $user = $userModel->getUserById($user_id, array(
                        'join' => XenForo_Model_User::FETCH_USER_PERMISSIONS
                    ));
                    $user['permissions'] = XenForo_Permission::unserializePermissions($user['global_permission_cache'], 'teamspeak', 'teamspeakGroupID');
                    $access = $user['permissions']['teamspeak']['teamspeakGroupID'];
                    $list = $instance['ts3_VirtualServer']->clientGetServerGroupsByDbid($identity);
                    if (in_array($access, $list, TRUE))
                    {
                        return;
                    }
                    $instance['ts3_VirtualServer']->serverGroupClientAdd($access, $identity);
                }
            }
        }
        catch(Exception $e)
        {
            return;
        }
        unset($instance['ts3_VirtualServer']);
    }
    public function _removeUser($auth_id)
    {
        $instance = $this->_queryInstance();
        try
        {
            if (!empty($auth_id))
            {
                foreach ($auth_id as $info)
                {
                    $identity = $this->_verifyUser($info);
                    if (!$identity)
                    {
                        continue;
                    }
                    $sgroups = $instance['ts3_VirtualServer']->clientGetServerGroupsByDbid($identity);
                    foreach ($sgroups as $sgid => $sgroup)
                    {
                        if ($sgid == $instance['info']['virtualserver_default_server_group']) continue;
                        $instance['ts3_VirtualServer']->serverGroupClientDel($sgid, $identity);
                        unset($sgroup, $sgid);
                    }
                }
            }
        }
        catch(Exception $e)
        {
            return;
        }
        unset($instance['ts3_VirtualServer']);
    }
    public function _verifyUser($auth_id)
    {
        $instance = $this->_queryInstance();
        try
        {
            $ts_temp = $instance['ts3_VirtualServer']->clientFindDb($auth_id, TRUE);
            $ts_uid = reset($ts_temp);
            unset($instance['ts3_VirtualServer']);
            return $ts_uid;
        }
        catch(Exception $e)
        {
            return false;
        }
    }
}
 

The Dark Wizard

Well-known member
I'm not getting that error, did you put in an invalid group id? Nevertheless, I'll set it to ignore that error so even if you set it wrong, your entire forum won't mess up.
Here is a fix though to ignore the error (next release but too many update version's!)
Overwrite the file library/Teamspeak/Helpers/Query.php with this:
PHP:
<?php

require_once("./library/Teamspeak/API/TeamSpeak3.php");
TeamSpeak3::init();
class Teamspeak_Helper_Query
{
    protected function _queryInstance()
    {
        $serverinfo = array(
            'serverip' => XenForo_Application::get('options')->teamspeak_serverip,
            'udp' => XenForo_Application::get('options')->teamspeak_udp,
            'tcp' => XenForo_Application::get('options')->teamspeak_query,
            'user' => XenForo_Application::get('options')->teamspeak_queryuser,
            'password' => XenForo_Application::get('options')->teamspeak_querypassword,
        );
        $nickname = mt_rand();
        $ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$serverinfo['user'].":".$serverinfo['password']."@".$serverinfo['serverip'].":".$serverinfo['tcp']."/?server_port=".$serverinfo['udp']."&nickname=".$nickname);
        return array(
            'ts3_VirtualServer' => $ts3_VirtualServer,
            'info' => $ts3_VirtualServer->getInfo(),
        );
    }
    public function _updateServerGroup($user_id, $new_auth_id, $old_auth_id = false)
    {
        if ($old_auth_id != false)
        {
            $this->_removeUser($old_auth_id);
        }
        $this->_removeUser($new_auth_id);
        $this->_addUser($user_id, $new_auth_id);
    }
    public function _addUser($user_id, $auth_id)
    {
        $instance = $this->_queryInstance();
        try
        {
            if (!empty($auth_id))
            {
                foreach ($auth_id as $info)
                {
                    $identity = $this->_verifyUser($info);
                    if (!$identity)
                    {
                        continue;
                    }
                    $userModel = XenForo_Model::create('XenForo_Model_User');
          
                    $user = $userModel->getUserById($user_id, array(
                        'join' => XenForo_Model_User::FETCH_USER_PERMISSIONS
                    ));
                    $user['permissions'] = XenForo_Permission::unserializePermissions($user['global_permission_cache'], 'teamspeak', 'teamspeakGroupID');
                    $access = $user['permissions']['teamspeak']['teamspeakGroupID'];
                    $list = $instance['ts3_VirtualServer']->clientGetServerGroupsByDbid($identity);
                    if (in_array($access, $list, TRUE))
                    {
                        return;
                    }
                    $instance['ts3_VirtualServer']->serverGroupClientAdd($access, $identity);
                }
            }
        }
        catch(Exception $e)
        {
            return;
        }
        unset($instance['ts3_VirtualServer']);
    }
    public function _removeUser($auth_id)
    {
        $instance = $this->_queryInstance();
        try
        {
            if (!empty($auth_id))
            {
                foreach ($auth_id as $info)
                {
                    $identity = $this->_verifyUser($info);
                    if (!$identity)
                    {
                        continue;
                    }
                    $sgroups = $instance['ts3_VirtualServer']->clientGetServerGroupsByDbid($identity);
                    foreach ($sgroups as $sgid => $sgroup)
                    {
                        if ($sgid == $instance['info']['virtualserver_default_server_group']) continue;
                        $instance['ts3_VirtualServer']->serverGroupClientDel($sgid, $identity);
                        unset($sgroup, $sgid);
                    }
                }
            }
        }
        catch(Exception $e)
        {
            return;
        }
        unset($instance['ts3_VirtualServer']);
    }
    public function _verifyUser($auth_id)
    {
        $instance = $this->_queryInstance();
        try
        {
            $ts_temp = $instance['ts3_VirtualServer']->clientFindDb($auth_id, TRUE);
            $ts_uid = reset($ts_temp);
            unset($instance['ts3_VirtualServer']);
            return $ts_uid;
        }
        catch(Exception $e)
        {
            return false;
        }
    }
}

That fixed the error thanks!
 
Top