Easier to manage Channel Lists

34 views
Skip to first unread message

Banjo Fox

unread,
Sep 19, 2016, 10:17:30 AM9/19/16
to AJAX-chat
Since I have a large number of channels in my chat (over 20 at this point), I came up with a simplified way to manage channel lists for the various groups of users.
The first part was to switch from using the array() function to range() which let's me abbreviate the lists to a start and end.

range(0,10) is equivalent to array(0,1,2,3,4,5,6,7,8,9,10)

The second part was to set up a couple of ranges based on user permissions (Admin/Mod or Registered User)

$staffChans = range(0,21); // Admins and Moderators
$userChans = range(0,19); // Registered users

Finally, all that needs to be done is to assign those variables to the users themselves

// Sample admin user:
$users[1] = array();
$users[1]['userRole'] = AJAX_CHAT_ADMIN;
$users[1]['userName'] = 'admin';
$users[1]['password'] = 'null';
$users[1]['channels'] = $staffChans;

// Sample moderator user:
$users[2] = array();
$users[2]['userRole'] = AJAX_CHAT_MODERATOR;
$users[2]['userName'] = 'moderator';
$users[2]['password'] = 'null';
$users[2]['channels'] = $staffChans

// Sample registered user:
$users[3] = array();
$users[3]['userRole'] = AJAX_CHAT_USER;
$users[3]['userName'] = 'user';
$users[3]['password'] = 'null';
$users[3]['channels'] = $userChans

Simply refreshing the page -SHOULD- do it (shift+F5 in Firefox and Chrome), but you may need to clear the cache
Reply all
Reply to author
Forward
0 new messages