Loading...
 
Features / Usability

Features / Usability


Re: Autologin to Ajax chat-usergroup mapping

posts: 80 Austria

A real group mapping can be done also. So you could have chatrooms only available for special tiki groups which are mapped to roles.


Step1: Define additional Roles in config.php

add

Image
define('AJAX_CHAT_GROUP1',5);

before

Image
define('AJAX_CHAT_CHATBOT',4); define('AJAX_CHAT_ADMIN',3);



Step 2: define Chatrooms for the group in users.php and change order to the order in Step1 (so the users and roles have teh same Id, that's important!)

Image
// registered user: $users[1] = array(); $users[1]['userRole'] = AJAX_CHAT_USER; $users[1]['channels'] = array(1,2,3,4,5,6); // moderator user: $users[2] = array(); $users[2]['userRole'] = AJAX_CHAT_MODERATOR; $users[2]['channels'] = array(1,2,3,4,5,6,7,8); // admin user: $users[3] = array(); $users[3]['userRole'] = AJAX_CHAT_ADMIN; $users[3]['userName'] = 'admin'; $users[3]['password'] = 'admin'; $users[3]['channels'] = array(1,2,3,4,5,6,7,8); // 4=chatbot // Tiki Group1 channel definition $users[5] = array(); $users[5]['userRole'] = AJAX_CHAT_GROUP1; $users[5]['channels'] = array(1,2,3,4,5,6,7);



Step3: Map the TikiGroup to the Ajax-chat role in CustomAJAXChat.php, the full code again:

Image
function initCustomRequestVars() { global $user, $tiki_p_admin, $userlib; include('../lib/userslib.php'); //needed for UserID //echo " tiki_p_admin: " . $tiki_p_admin; // Auto-login tikiwiki users: if(!$this->getRequestVar('logout') && $user != '') { $UserId = $userlib->get_user_id($user); $this->setRequestVar('userName', $user); $this->setRequestVar('userID', $UserId); $this->setRequestVar('userRole', AJAX_CHAT_USER); // define default role if ($tiki_p_admin == 'y') { $this->setRequestVar('userRole', AJAX_CHAT_ADMIN); } $user_details = $userlib->get_user_details($user); $ug = $user_details['info']['default_group']; if ($ug == 'TikiGroup1') { $this->setRequestVar('userRole', AJAX_CHAT_GROUP1); } $this->setRequestVar('login', true); } }


and replace

Image
$validChannels = $customUsers[$this->getUserID()]['channels'];


with

Image
$validChannels = $customUsers[$this->getUserRole()]['channels'];