Skip to main content
[ADDON] ElkArte Ajax Chat Started by wintstar · · Read 56918 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic

[ADDON] ElkArte Ajax Chat

ElkArte Ajax Chat
Integrates the Blueimp´s AJAX-Chat 0.8.8 into your ElkArte Forum

Addon: ElkArte Ajax Chat
Version: 1.0.1
Author: wintstar
Language: german informell, english
Themes: Elkarte, Light and Be Social!
ElkArte version: 1.0.6
Download: click here
Plugin: BlueFeeling Theme Plugin

Description:
This this is a port of my mod SMF Ajax Chat. The AJAX Chat is latest version and was further adapted to ElArte. Many Thanks an Emanuel and Spuds for help. It is no longer possible, if a user does not have the necessary permissions to access with a direct link to the Ajax Chat on this. Also, it is not possible, if the Board in maintenance mode to access the AJAX Chat. Permissions can be now individually configured for the Member groups. Chat moderation can also individually be configured.

AJAX Chat Features:
Spoiler (click to show/hide)

ElkArte Addon Functions
  • AJAX Chat Tips in Administrator-Center for further configuration options Blueimp AJAX Chat
Shoutbox
  • Enable shoutbox above at the Board Categories*
  • Enable shoutbox below at Board Categories*
Chat
  • Enable chat functions*
  • New Style "ElkLight, ElkBeSocial!" for Blueimp Ajax Chat
Users in chat
  • Display in the menu next to the chat button, the number of users there are in the chat online?*
  • Display "Who members are in the chat online?"*
* Can be in the Administrator-Center enables / disables.
Permissions, individually for each group
  • Can administer the Chat
  • Can moderate the Chat
  • Can see the Chat
  • Can submit messages in the shoutbox
  • Can "Who is on chat online?" look at

Changelog 1.0.1
Bug fixed
  • "datetime", appears in MySQL databases versions 5.5.32-5.5.42
  • Activation Button the chat page is missing from the configuration of the Ajax Chat
  • Shoutbox text input field runs in mobile view from the "div"

Planned Functions for ElkArte Addon
  • Configuration of Blueimp AJAX chat in Administrator-Center
  • Template valid
 
Planned debugging in the future
  • Solution for the bug 'AJAX_CHAT_BANNED' of the AJAX chat
  • Solution for the bug 'Login/Logout' of the AJAX chat

If not implemented
  • Activate shoutbox above the Board categories on all sides
  • Call Chat as a popup
   
This modification is subject to the licenses

Screenshots:

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #1

Looks AWESOME !

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #2

Great job! :D
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #3

I have a probleme with the adminarea. The Configuration section of the chat is not displayed. Hook integrate_admin_areas and integrate_sa_modify_modifications are installed.

What have I overlooked?

Chat.integrate.php
Code: (php) [Select]
    public static function integrate_admin_areas(&$admin_areas)
    {
    global $txt;

    loadlanguage('Chat');
    $admin_areas['config']['areas']['addonsettings']['subsections']['chat'] = array($txt['chat']);
    }
    
    public static function integrate_sa_modify_modifications($sub_actions)
    {
        $sub_actions['chat'] = array(
            'dir' => SUBSDIR,
            'file' => 'Chat.subs.php',
            'function' => 'ModifyChatSettings'
        );                
    }
Chat.subs.php
Code: (php) [Select]
<?php
/**
* ElkArte Ajax Chat
*
* @author  wintstar
* @license BSD http://opensource.org/licenses/BSD-3-Clause
* @license Bluimp's AJAX Chat is released under a Modified MIT License (MIT) https://raw.githubusercontent.com/Frug/AJAX-Chat/master/chat/license.txt
*
* @version 0.0.1beta
*/

if (!defined('ELK'))
die('No access...');

/**
* ModifyChatSettings()
*
* - Defines our settings array and uses our settings class to manage the data
*/
function ModifyChatSettings()
{
    global $txt, $scripturl, $context;

    loadlanguage('Chat');
    $context[$context['admin_menu_name']]['tab_data']['tabs']['chat']['description'] = $txt['chat_desc'];

    // Lets build a settings form
    require_once(SUBSDIR . '/SettingsForm.class.php');

    // Instantiate the form
    $chatSettings = new Settings_Form();

    $config_vars = array(
        array('check', 'shoutabove_enabled'),
        array('check', 'anypageshout_enabled'),
        array('check', 'shoutbelow_enabled'),
        array('check', 'chatpage_enabled'),
        array('check', 'chatpopup_enabled'),
        array('check', 'chatbutton_enabled'),
        array('check', 'chatheader_enabled'),
        array('check', 'chatuser_enabled'),
    );

    // Load the settings to the form class
    $chatSettings->settings($config_vars);

    // Saving?
    if (isset($_GET['save']))
    {
        checkSession();
        Settings_Form::save_db($config_vars);
        redirectexit('action=admin;area=addonsettings;sa=chat');
    }

    // Continue on to the settings template
    $context['post_url'] = $scripturl . '?action=admin;area=addonsettings;save;sa=chat';
    $context['settings_title'] = $txt['chat'];

    Settings_Form::prepare_db($config_vars);
    return;
}

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #4

You are not using a class, so it's useless to use "public static function", use just "function" (even though I would suggest you to wrap these functions into a class because in the future it will become handy).
Actually, if this is exactly what you have in the file, it should generate a syntax error, so most likely you have a:
Code: [Select]
class Something
{
    public static function integrate_admin_areas(
[...]etc.
In that case, the "hook" should be:
Something::integrate_admin_areas
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #5

I have this change. But, not work. Hooks are all in green display. All active.

sources/ChatIntegrate.php
Code: (php) [Select]
<?php
/**
 * ElkArte Ajax Chat
 *
 * @author  wintstar
 * @license BSD http://opensource.org/licenses/BSD-3-Clause
 * @license Bluimp's AJAX Chat is released under a Modified MIT License (MIT) https://raw.githubusercontent.com/Frug/AJAX-Chat/master/chat/license.txt
 *
 * @version 0.0.1beta
 */

if (!defined('ELK'))
    die('No access...');


function ias_chat(&$actions)
{
    $actions['chat'] = array('Chat.controller.php', 'Chat_Controller', 'action_chat');
}

function ica_chat(&$current_action)
{
    if ($current_action === 'chat')
    {
        if (empty($_REQUEST['action']))
            $current_action = 'chat';
    }
        
}

function imp_chat(&$buttons, &$menu_count)
{
    global $context, $txt, $boardurl, $scripturl;
        
    loadLanguage('Chat');
        
    function chatOnlineUsers(){
    global $scripturl, $txt, $user_info, $modSettings;

    $db = database();

    $userIDs = array();
    $request = $db->query('', '
        SELECT userID
        FROM {db_prefix}chat_online    WHERE NOW() <= DATE_ADD(dateTime, interval 2 MINUTE)' ,
        array()
        );
        while ($row = $db->fetch_assoc($request)) {
            array_push($userIDs, $row['userID']);
        }
            $db->free_result($request);
            return array_unique($userIDs);
        }
        
       $num = !empty($modSettings['enableChatButtonNo']) ? 0 : count(chatOnlineUsers());
       $chatButton = $txt['chat_index'];
       $chatButton .= ($num > 0) ?  ('('.$num.')') : '';        

        $buttons = elk_array_insert($buttons, 'unread', array(
            'chat' => array(
                'title' => $chatButton,
                'href' => $scripturl . '?action=chat',
                'data-icon' => '',
                'show' => $context['allow_admin'],
            ),
    ));    
}

function ihp_chat()
{
    // Load the Chat Help file.
       loadLanguage('Chat');
}  
    
function iaa_chat(&$admin_areas)
{
    global $txt;
        
    loadlanguage('Chat');
    isAllowedTo('admin_forum');
    $admin_areas['config']['areas']['addonsettings']['subsections']['chat'] = array($txt['chat']);
}
    
function imm_chat($sub_actions)
{
    $sub_actions['chat'] = array(
    'dir' => SOURCEDIR,
    'file' => 'ChatIntegration.php',
    'function' => 'ModifyChatSettings'
    );                
}
    
/**
* ModifyChatSettings()
*
* - Defines our settings array and uses our settings class to manage the data
*/
function ModifyChatSettings()
{
    global $txt, $scripturl, $context;

    loadlanguage('Chat');
    $context[$context['admin_menu_name']]['tab_data']['tabs']['chat']['description'] = $txt['chat_desc'];

    // Lets build a settings form
    require_once(SUBSDIR . '/SettingsForm.class.php');

    // Instantiate the form
    $chatSettings = new Settings_Form();

    $config_vars = array(
        array('title', 'chat_Settings'),    
        array('check', 'chat_above_enabled'),
        array('check', 'chat_anypage_enabled'),
        array('check', 'chat_below_enabled'),
        array('check', 'chat_page_enabled'),
        array('check', 'chat_popup_enabled'),
        array('check', 'chat_button_enabled'),
        array('check', 'chat_header_enabled'),
        array('check', 'chat_user_enabled'),
    );

    // Load the settings to the form class
    $chatSettings->settings($config_vars);

    // Saving?
    if (isset($_GET['save']))
    {
        checkSession();
        Settings_Form::save_db($config_vars);
        redirectexit('action=admin;area=addonsettings;sa=chat');
    }

    // Continue on to the settings template
    $context['post_url'] = $scripturl . '?action=admin;area=addonsettings;save;sa=chat';
    $context['settings_title'] = $txt['chat'];

    Settings_Form::prepare_db($config_vars);
    return;
}             



function ilp_chat(&$permissionGroups, &$permissionList, &$leftPermissionGroups, &$hiddenPermissions, &$relabelPermissions)
{  
    global $context, $txt, $helptxt, $modSettings;
        
    loadLanguage('Chat');
        
    $permissionList['membergroup']['chat_admin'] = array(false, 'chat', 'chat');
    $permissionList['membergroup']['chat_moderator'] = array(false, 'chat', 'chat');
    $permissionList['membergroup']['chat_view_chatpage'] = array(false, 'chat', 'chat');
    $permissionList['membergroup']['chat_view_talkbox'] = array(false, 'chat', 'chat');
    $permissionList['membergroup']['chat_view_chatuser'] = array(false, 'chat', 'chat');

    $permissionGroups['membergroup'][] = 'chat';

    $leftPermissionGroups[] = 'chat';
}

function ips_chat()
{
    global $context, $txt, $helptxt, $modSettings;
        
    loadLanguage('Chat');

    // Guests shouldn't be able to have any portal specific permissions.
    $context['non_guest_permissions'] = array_merge($context['non_guest_permissions'], array(
        'chat_admin',
        'chat_moderator',            
    ));
}

sources/controllers/Chat.controller.php
Code: (php) [Select]
<?php
/**
 * ElkArte Ajax Chat
 *
 * @author  wintstar
 * @license BSD http://opensource.org/licenses/BSD-3-Clause
 * @license Bluimp's AJAX Chat is released under a Modified MIT License (MIT) https://raw.githubusercontent.com/Frug/AJAX-Chat/master/chat/license.txt
 *
 * @version 0.0.1beta
 */

if (!defined('ELK'))
die('No access...');

class Chat_Controller extends Action_Controller
{
public function pre_dispatch()
{
global $modSettings;

// Some things we will need
loadLanguage('Chat');

// Are we allowed to view the map?
isAllowedTo('chat_view_chatpage');
}   
   
public function action_index()
{
return $this->action_chat();
}

public function action_chat()
{
global $txt, $context, $scripturl;

loadLanguage('Chat');
        loadCSSFile('chat.css');
loadTemplate('Chat');
$context['sub_template'] = 'chat';
        $context['page_title'] = $context['forum_name'] . ' - ' . $txt['chat_index'];
// Build the link tree.
$context['linktree'][] = array(
'url' => $scripturl . '?action=chat',
'name' => $txt['chat'],
);       
}
   
   
   
}


Regards Stephan

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #6

Sorry, but I have some difficulties reading the files one at a time. :-[ Without the whole package I'm out of the games. :-[

Have a look at:
https://github.com/emanuele45/WordReplacer
it should give some hints.
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #7

Thanks, that helps me continue.   :)


Regards Stephan

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #8

Have solved the problem. The hook integrate_sa_modify_modifications was too much.

 :)  Little by little I understand the hook system
.

Regards Stephan

Re: [ADDON][BETA] ElkArte Ajax Chat

Reply #9

Short update   :)

Admin area, Permission settings area and Shoutbox above an below the Board Categories creates.

New Screenshots, looking up in the first post.  :)
Regards Stephan

Re: [ADDON] ElkArte Ajax Chat

Reply #10

Addon is released! :)

Download, see first post.
Regards Stephan

Re: [ADDON] ElkArte Ajax Chat

Reply #11

Great job winstar! :D
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON] ElkArte Ajax Chat

Reply #12

Fabulous! Thank you! :)

Re: [ADDON] ElkArte Ajax Chat

Reply #13

QuoteAddon is released! :)
Congratulations !

Re: [ADDON] ElkArte Ajax Chat

Reply #14

:thumbsup: