Skip to content

Custom chat channels

Doc gWorldz edited this page Jul 17, 2014 · 5 revisions

Table of Contents

Adding custom chat channels - standalone version

If you're using the standalone version you can directly edit the list of available channels. For more information please read Choose Your Channel Settings in the Installation section of the readme.html included.

Adding custom chat channels - custom integration versions

The forum integration versions of AJAX Chat take over the forums as chat channels:

  • The forum's name is used as the channel name (whitespace is replaced with the underscore "_")
  • The forum's ID is used as the channel ID
  • The forum's access restriction is taken over for the channel access restriction
So if you want to restrict access to a specific channel to a specific forum group you only have to restrict access to the forum with the same name.

Limiting the list of forums used as chat channels

If you don't want to use all your forums as channels, you can limit the used forums with a configuration option in lib/config.php:

// Defines an array of channelIDs (e.g. array(0, 1)) to limit the number of available channels, will be ignored if set to null:
$config['limitChannelList'] = array(123,456,789);
This setting would only use the forums with the IDs 123, 456 and 789 as channels.

Adding additional chat channels

To add additional custom chat channels which are not taken from the forums you have to adjust the methods getChannels() and getAllChannels() in lib/class/CustomAJAXChat.php:

  • The method getAllChannels() returns an array of all available channels, no matter if the current user has access to these channels or not.
  • The method getChannels() returns and array of channels to which the current user has access to.
The returned arrays use the channelNames as keys and the channelIDs as values. A valid channel array would be the following:
$channels = array('Extra_Public_Channel_1'=>123, 'Extra_Public_Channel_2'=>456, 'Extra_Public_Channel_3'=>789);
Note: The channelNames may not contain any whitespace.

To add these channels as custom chat channels, do one of the following:

  • Add additional channels individually with an array
  • Add additional channels using lib/class/data/channels.php

Individually with an Array

Add

        $this->_channels = array_merge($this->_channels, array('Extra_Public_Channel_1'=>123, 'Extra_Public_Channel_2'=>456, 'Extra_Public_Channel_3'=>789));
before
      }
      return $this->_channels;

Add

        $this->_allChannels = array_merge($this->_allChannels, array('Extra_Public_Channel_1'=>123, 'Extra_Public_Channel_2'=>456, 'Extra_Public_Channel_3'=>789));
before
      }
      return $this->_allChannels;
Note: This setting would add these channels as public channels accessible for all chat users. To restrict access to such a custom channel you would have to add your own custom conditions before adding the custom channels inside the method getChannels().

With lib/class/data/channels.php

Add

			$this->_channels = array_merge($this->_channels, $this->getCustomChannels());
Before
		}
		return $this->_channels;

Add

			$this->_allChannels = array_merge($this->_allChannels, $this->getCustomChannels());
Before
		}
		return $this->_allChannels;
Note: This setting would add all channels from lib/class/data/channels.php as public channels accessible for all chat users. To restrict access to such a custom channel you would have to add your own custom conditions before adding the custom channels inside the method getChannels().
Clone this wiki locally