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
Copy to clipboard
define('AJAX_CHAT_GROUP1',5);

before

Image
Copy to clipboard
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
Copy to clipboard
// 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
Copy to clipboard
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
Copy to clipboard
$validChannels = $customUsers[$this->getUserID()]['channels'];


with

Image
Copy to clipboard
$validChannels = $customUsers[$this->getUserRole()]['channels'];
There are no comments at this time.

Upcoming Events

1)  18 Apr 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  16 May 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  20 Jun 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
5)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7) 
Tiki birthday
8)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
9)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
10)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting