News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

AJAX Chat Custom Member Groups

Started by mrtrc266, May 10, 2010, 01:59:38 PM

Previous topic - Next topic

mrtrc266

Hello Everyone, hoping I could get a little help here. (This will be for SMF1.1.X and SMF2)

What I'm trying to do is take add  a Custom Member Group to AJAX Chat, I followed the tut from here which is specifically for phpBB3
http://sourceforge.net/apps/mediawiki/ajax-chat/index.php?title=PhpBB3_custom_user_group

I have it working but the problem is that it changes the color for ALL membergroups that aren't Admin, Moderate, Guest or Regular user.

Am I missing something somewhere? (attatched is the raw unedited CustomAJAXChat.php)

All the Code that's required to change is exactly the same except for   this part here

Here is the portion of the code for phpBB3
        // Check if we have a valid registered user:
        if($user->data['is_registered']) {
            $userData = array();
            $userData['userID'] = $user->data['user_id'];

            $userData['userName'] = $this->trimUserName($user->data['username']);
           
            if($auth->acl_get('a_'))
                $userData['userRole'] = AJAX_CHAT_ADMIN;
            elseif($auth->acl_get('m_'))
                $userData['userRole'] = AJAX_CHAT_MODERATOR;
            else
                $userData['userRole'] = AJAX_CHAT_USER;

            return $userData;
           
        } else {
            // Guest users:
            return $this->getGuestUser();
        }
    }


The tutorial For phpbb3 it says
Find
            if($auth->acl_get('a_'))
                $userData['userRole'] = AJAX_CHAT_ADMIN;
            elseif($auth->acl_get('m_'))
                $userData['userRole'] = AJAX_CHAT_MODERATOR;
            else
                $userData['userRole'] = AJAX_CHAT_USER;

Replace with
            $userData['groupID'] = $user->data['group_id'];

            if($auth->acl_get('a_')) {
                $userData['userRole'] = AJAX_CHAT_ADMIN;
            } elseif($auth->acl_get('m_')) {
                $userData['userRole'] = AJAX_CHAT_MODERATOR;
            }    else {
                // Check if we have a member of our custom user group
                if($userData['groupID'] == 7)
                    $userData['userRole'] = AJAX_CHAT_VIP;
                else
                    $userData['userRole'] = AJAX_CHAT_USER;
            }


Here is the portion of the code for SMF
        // Check if we have a valid registered user:
        if($userData['chat_access']) {
            if ($context['user']['is_guest'])
                return $this->getGuestUser($userData);
            else{   
                $userData['userID'] = $context['user']['id'];
                   
                $userData['userName'] = $this->trimUserName($context['user']['name']);
       
                if($context['user']['is_admin'])
                    $userData['userRole'] = AJAX_CHAT_ADMIN;
                elseif(allowedTo('chat_mod'))
                    $userData['userRole'] = AJAX_CHAT_MODERATOR;
                else
                    $userData['userRole'] = AJAX_CHAT_USER;

            return $userData;
            }
        }else
            return null;   
    }


I found
                if($context['user']['is_admin'])
                    $userData['userRole'] = AJAX_CHAT_ADMIN;
                elseif(allowedTo('chat_mod'))
                    $userData['userRole'] = AJAX_CHAT_MODERATOR;
                else
                    $userData['userRole'] = AJAX_CHAT_USER;

And changed to
                $userData['groupID'] = $user->data['group_id'];   
               
                if($context['user']['is_admin']) {
                    $userData['userRole'] = AJAX_CHAT_ADMIN;
                } elseif(allowedTo('chat_mod')) (
                    $userData['userRole'] = AJAX_CHAT_MODERATOR;
                } else (
                // Check if we have a member of our custom user group
                if($userData['groupID'] = 9)
                    $userData['userRole'] = AJAX_CHAT_VIP;
                else
                    $userData['userRole'] = AJAX_CHAT_USER;
                )

TheListener

Where it says:

  if($userData['groupID'] = 9)

Would that be the number of the membergroup?


mrtrc266

Yes that's the member group I designated, but all member groups with the execption of Admin, Mod, User and Guest have the same color I that for just group #9

Yağız...

// Check if we have a valid registered user:
if($userData['chat_access']) {
if ($context['user']['is_guest'])
return $this->getGuestUser($userData);
else{
$userData['userID'] = $context['user']['id'];

$userData['userName'] = $this->trimUserName($context['user']['name']);

if($context['user']['is_admin'])
$userData['userRole'] = AJAX_CHAT_ADMIN;
elseif(allowedTo('chat_mod'))
$userData['userRole'] = AJAX_CHAT_MODERATOR;
else
{
// Check if we have a member of our custom user group
if(in_array(9, $user_info['groups']))
$userData['userRole'] = AJAX_CHAT_VIP;
else
$userData['userRole'] = AJAX_CHAT_USER;
}

return $userData;
}
}else
return null;

mrtrc266

#4
Very Very nice, I think that did it!

Let's say I wanted to add more member groups would it be something like this and keep adding for more member groups?

AJAX_CHAT_VIP2 for Member Group 10
AJAX_CHAT_VIP3 for Member Group 11

               // Check if we have a member of   our custom user group
               if(in_array(9,   $user_info['groups']))
                  $userData['userRole'] =   AJAX_CHAT_VIP;
               if(in_array(10,   $user_info['groups']))
                  $userData['userRole'] =   AJAX_CHAT_VIP2;
               if(in_array(11,     $user_info['groups']))
                  $userData['userRole'] =   AJAX_CHAT_VIP3;
               else
                  $userData['userRole']   = AJAX_CHAT_USER;

Yağız...

I think you don't need AJAX_CHAT_VIP2 and AJAX_CHAT_VIP3, only AJAX_CHAT_VIP.
               // Check if we have a member of   our custom user group
               if(in_array(9,   $user_info['groups']) || in_array(10,   $user_info['groups']) || in_array(11,     $user_info['groups']))
                  $userData['userRole'] =   AJAX_CHAT_VIP;
               else
                  $userData['userRole']   = AJAX_CHAT_USER;


If you need to separate, then your code is OK.

mrtrc266

Ok cool I'll check it out tomorrow. What has to be done after that the /chat/lib/class/CustomAJAXChat.php    file is what scares me LOL

Look at this from file /chat/lib/class/AJAXChat.php down
http://sourceforge.net/apps/mediawiki/ajax-chat/index.php?title=PhpBB3_custom_user_group

Hopefully it will  make more sense when I wake up.

Thanks again for your help, it's greatly appreciated.

Ingwie

Hey guy's! :P

I have like the same problem, just that i became dizzy in reading everything - expect that the tutorial was a few TOO long for myself... I want to just integrate one to two special usergroups.that's all. I am using SMF2 RC3.

Can someone give me a clear tutorial on how to finish on that?
Oh...and why not writing a mod for SMF about that, so the usergroup of SMF is automaticly integrated into AJAXchat? o.o



Have a nice day! ^_^

Advertisement: