Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
AJAX Chat Integration Details »»
AJAX Chat Integration
Version: 1.00, by ICThawk ICThawk is offline
Developer Last Online: Mar 2014 Show Printable Version Email this Page

Category: Chat Modifications - Version: 4.1.4 Rating:
Released: 08-31-2011 Last Update: Never Installs: 15
Uses Plugins
Re-useable Code Translations  
No support by the author.

So I have been using vBulletin for awhile and have been very frustrated with the current lack of integration with AJAX Chat by blueimpu. So, I have decided to do the integration myself and with the help of other users on vB.org I have put together a few plugins.

Add Popup Link for Chat:
I started by adding in the Chat popup link to my navbar. In your navbar template, add the following code to display the Chat Link.

HTML Code:
<a class="navtab" href="#" onClick="MyWindow=window.open('http://www.wavingthewheat.com/chat/index.php','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=800,height=600'); return false;">Chat ({vb:raw num_chatting})</a>
Next you will need to create a new plugin. Set the Hook Location to global_bootstrap_init_start and add the following into the PHP Code box.

PHP Code:
$result mysql_query("SELECT * FROM ajax_chat_online");   
$num_chatting mysql_num_rows($result);   
vB_Template::preRegister('navbar',array('num_chatting' => $num_chatting));
vB_Template::preRegister('FORUMHOME',array('num_chatting' => $num_chatting)); 


Displaying UserNames of Those Online:
Just like in the above there are two parts to this plugin. Modifying a template and creating a plugin. First we need to modify your FORUMHOME template. Right below the <!-- end logged in users --> line add the following.

HTML Code:
<!-- chat users -->
			<div id="wgo_onlineusers" class="wgo_subblock section">
				<h3 class="blocksubhead"><img src="{vb:stylevar imgdir_misc}/users_online.png" alt="Users In Chat" />{vb:raw num_chatting} Users In Chat</h3>
				<div>
					<p>{vb:raw chat_userlist}</p>
				</div>
			</div>
			<!-- end chat users -->
Next we need to create a new plugin. The Hook is global_start and the PHP code is:

PHP Code:
global $vbulletin;  

$results $vbulletin->db->query_read_slave("SELECT userName FROM ajax_chat_online");  
while (
$row $vbulletin->db->fetch_array($results))  
    
$chat_userlist[] = $row['userName'];  
if (
is_array($chat_userlist)) 

    
$chat_userlist implode(', '$chat_userlist);  
    
$vbulletin->db->free_result($results);  

else 

    
// set $chat_userlist to a "no one chatting" message if you want, or leave blank.
    
$chat_userlist ''

vB_Template::preRegister('FORUMHOME', array('chat_userlist' => $chat_userlist)); 

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
2 благодарности(ей) от:
Pianobiz, trueoak

Comments
  #22  
Old 07-10-2016, 01:45 AM
sixpackspeak sixpackspeak is offline
 
Join Date: Mar 2012
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

***
Reply With Quote
  #23  
Old 11-07-2016, 02:09 PM
sixpackspeak sixpackspeak is offline
 
Join Date: Mar 2012
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Updated to the following recently:
vBulletin 4.2.3 Patch Level 2
PHP 5.6.27-0+deb8u1 (cli)

And now the user counter doesn't work properly on the nav bar or who's chatting in the info section.

FYI, I've updated the "global_bootstrap_init_start" slightly, to make it a little more specific (and to remove duplicate login entries):
Code:
$resCNT = mysql_query("SELECT COUNT(userID) FROM ajax_chat_online GROUP BY userID");   
$num_chatting = $resCNT[0];
vB_Template::preRegister('navbar',array('num_chatting' => $num_chatting));
vB_Template::preRegister('FORUMHOME',array('num_chatting' => $num_chatting));
The query works perfectly as intended, however, it was not outputting any numerical counts, either with the current code (in OP) or the updated code.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:12 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.10285 seconds
  • Memory Usage 2,253KB
  • Queries Executed 18 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (2)bbcode_html
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (3)post_thanks_box
  • (2)post_thanks_box_bit
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (3)post_thanks_postbit_info
  • (2)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete