diff --git a/drupalchat.module b/drupalchat.module
index 09829fb..474fbb0 100644
--- a/drupalchat.module
+++ b/drupalchat.module
@@ -586,7 +586,10 @@ function drupalchat_poll() {
$buddylist = _drupalchat_buddylist($user->uid);
$buddylist_online_old = _drupalchat_buddylist_online($buddylist);
-
+ // create additional sql selector for injected chatrooms
+ $chatrooms = module_invoke_all("drupalchat_chatrooms");
+ $sql_join = '';
+ foreach ($chatrooms as $key => $chatroom) $sql_join .= ', \''. $key .'\'';
$polling_method = variable_get('drupalchat_polling_method', DRUPALCHAT_LONGPOLL);
@@ -620,13 +623,13 @@ function drupalchat_poll() {
if($user->uid > 0) {
$message_count = db_query(' SELECT COUNT(*)
FROM {drupalchat_msg} m
- WHERE (m.uid2 IN (:uid2,\'c-0\') OR m.uid1 = :uid2)
+ WHERE (m.uid2 IN (:uid2,\'c-0\''.$sql_join.') OR m.uid1 = :uid2)
AND m.timestamp > :timestamp', array(':uid2' => $user->uid, ':timestamp' => $last_timestamp))->fetchField();
}
else {
$message_count = db_query(' SELECT COUNT(*)
FROM {drupalchat_msg} m
- WHERE (m.uid2 IN (:uid2,\'c-0\') OR m.uid1 = :uid2)
+ WHERE (m.uid2 IN (:uid2,\'c-0\''.$sql_join.') OR m.uid1 = :uid2)
AND m.timestamp > :timestamp', array(':uid2' => '0-'._drupalchat_get_sid(), ':timestamp' => $last_timestamp))->fetchField();
}
_drupalchat_touch_user($user->uid);
@@ -635,10 +638,10 @@ function drupalchat_poll() {
}
if (($message_count > 0) || ($polling_method == DRUPALCHAT_AJAX)) {
if($user->uid > 0) {
- $messages = db_query('SELECT m.message_id, m.uid1, m.uid2, m.message, m.timestamp FROM {drupalchat_msg} m WHERE (m.uid2 IN (:uid2,\'c-0\') OR m.uid1 = :uid2) AND m.timestamp > :timestamp ORDER BY m.timestamp ASC', array(':uid2' => $user->uid, ':timestamp' => $last_timestamp));
+ $messages = db_query('SELECT m.message_id, m.uid1, m.uid2, m.message, m.timestamp FROM {drupalchat_msg} m WHERE (m.uid2 IN (:uid2,\'c-0\''.$sql_join.') OR m.uid1 = :uid2) AND m.timestamp > :timestamp ORDER BY m.timestamp ASC', array(':uid2' => $user->uid, ':timestamp' => $last_timestamp));
}
else {
- $messages = db_query('SELECT m.message_id, m.uid1, m.uid2, m.message, m.timestamp FROM {drupalchat_msg} m WHERE (m.uid2 IN (:uid2,\'c-0\') OR m.uid1 = :uid2) AND m.timestamp > :timestamp ORDER BY m.timestamp ASC', array(':uid2' => '0-'._drupalchat_get_sid(), ':timestamp' => $last_timestamp));
+ $messages = db_query('SELECT m.message_id, m.uid1, m.uid2, m.message, m.timestamp FROM {drupalchat_msg} m WHERE (m.uid2 IN (:uid2,\'c-0\''.$sql_join.') OR m.uid1 = :uid2) AND m.timestamp > :timestamp ORDER BY m.timestamp ASC', array(':uid2' => '0-'._drupalchat_get_sid(), ':timestamp' => $last_timestamp));
}
//drupal_set_message('
'.print_r($messages,true).'
');
//while ($message = db_fetch_object($messages)) {
@@ -710,7 +713,9 @@ function _drupalchat_buddylist($uid) {
function _drupalchat_buddylist_online($buddylist) {
global $user;
- $users = array();
+ // let other modules plug in additional "users" or "chatrooms"
+ $users = module_invoke_all("drupalchat_chatrooms");
+
if(variable_get('drupalchat_enable_chatroom', 1) == 1) {
$users['c-0'] = array('name' => t('Public Chatroom'), 'status' => '1');
}
diff --git a/js/drupalchat-min.js b/js/drupalchat-min.js
index a71992d..27ba6f5 100644
--- a/js/drupalchat-min.js
+++ b/js/drupalchat-min.js
@@ -1 +1 @@
-eval((function(x){var d="";var p=0;while(p4)d+=d.substr(d.length-x.charCodeAt(p+1)*96-x.charCodeAt(p+2)+3104-l,l);else d+="`";p+=4}}return d})("var j={lIi:null,li` \"#j` *#jI:0,ll1:0,llI:0,Iij:{},Ij1:{}};I(document).Iji(function(){I.il1.l1i=` )((this).find(\"ul, .subpanel\").lI({height:\"auto\"});var Ili=I(window).` <\"(` 5\"ljj=` g*` e(` >)jj=Ili-100` o\"jI=jj-25;if(ljj>jj`!P,`!E3jj});`!z,` 0/}else`\"B-`\"13`#H!\"#chat`!*%1i();`\"O&resize`#W)` =1`!Y!\"").appendTo(jQuery("body"));swfobject.registerObject("drupalchatbeep","9");jQuery("#mainpanel li a.subpanel_toggle, .chatbox a.chatboxhead").live('click',function(){if(jQuery(this).next(".subpanel").is(':visible')){jQuery(this).next(".subpanel").hide();jQuery(this).removeClass('active')}else{jQuery(this).next(".subpanel").toggle();jQuery(this).removeClass('active');jQuery(this).toggleClass('active');var isTextarea=jQuery(this).next(".subpanel").children(".chatboxinput").children(".chatboxtextarea");if(isTextarea.length>0){isTextarea[0].focus();jQuery(this).next(".subpanel").children(".chatboxcontent").scrollTop(jQuery(this).next(".subpanel").children(".chatboxcontent")[0].scrollHeight)}}jQuery('#drupalchat-chat-options').hide();return false});jQuery('.subpanel .subpanel_title').live('click',function(){jQuery(this).parent().hide();jQuery(this).parent().parent().children('a').removeClass('active')});jQuery('#drupalchat .subpanel .subpanel_title span.options').live('click',function(){var offset=jQuery(this).offset();offset.top=offset.top+20;offset.left=offset.left-50;if(jQuery('#drupalchat-chat-options').is(":hidden")){jQuery('#drupalchat-chat-options').show()}else{jQuery('#drupalchat-chat-options').hide()}jQuery('#drupalchat-chat-options').offset({top:offset.top,left:offset.left});return false});jQuery('#drupalchat-chat-options-s').live('click',function(e){if(jQuery(this).html()=='Mute'){jQuery(this).html('Unmute');Drupal.settings.drupalchat.notificationSound='2'}else{jQuery(this).html('Mute');Drupal.settings.drupalchat.notificationSound='1'}jQuery('#drupalchat-chat-options').hide();return false});jQuery('body').live('click',function(){jQuery('#drupalchat-chat-options').hide()});jQuery('.subpanel ul').click(function(e){});jQuery("#chatpanel .subpanel li:not(.link) a").live('click',function(){chatWith(jQuery(this).attr("class"),jQuery(this).text());return false});jQuery(".chatbox .subpanel_title span:not(.min)").live('click',function(){closeChatBox(jQuery(this).attr('class'))});if(Drupal.settings.drupalchat.status==1){jQuery(".chat_options .chat_loading").removeClass('chat_loading').addClass('status-2').html(Drupal.settings.drupalchat.goIdle);jQuery("#chatpanel .icon").attr("src",Drupal.settings.drupalchat.images+"chat-1.png")}else if(Drupal.settings.drupalchat.status==2){jQuery(".chat_options .chat_loading").removeClass('chat_loading').addClass('status-1').html(Drupal.settings.drupalchat.goOnline);jQuery("#chatpanel .icon").attr("src",Drupal.settings.drupalchat.images+"chat-2.png")}jQuery(".chat_options .status-1").live('click',function(){jQuery(".chat_options .status-1").removeClass('status-1').addClass('chat_loading');jQuery.post(Drupal.settings.drupalchat.statusUrl,{status:"1"},function(data){jQuery(".chat_options .chat_loading").removeClass('chat_loading').addClass('status-2').html(Drupal.settings.drupalchat.goIdle);jQuery("#chatpanel .icon").attr("src",Drupal.settings.drupalchat.images+"chat-1.png")})});jQuery(".chat_options .status-2").live('click',function(){jQuery(".chat_options .status-2").removeClass('status-2').addClass('chat_loading');jQuery.post(Drupal.settings.drupalchat.statusUrl,{status:"2"},function(data){jQuery(".chat_options .chat_loading").removeClass('chat_loading').addClass('status-1').html(Drupal.settings.drupalchat.goOnline);jQuery("#chatpanel .icon").attr("src",Drupal.settings.drupalchat.images+"chat-2.png")})});jQuery(".chat_options .options").live('click',function(){alert('Under Construction')});setTimeout(function(){chatPoll()},500);jQuery('#drupalchat .subpanel .chatboxcontent').live('mouseenter',function(){jQuery(this).css("overflow-y","auto")});jQuery('#drupalchat .subpanel .chatboxcontent').live('mouseleave',function(){jQuery(this).css("overflow-y","hidden")})});function chatWith(chatboxtitle,chatboxname){createChatBox(chatboxtitle,chatboxname);jQuery("#chatbox_"+chatboxtitle+" a:first").click();jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus()}function createChatBox(chatboxtitle,chatboxname,chatboxblink){if(jQuery("#chatbox_"+chatboxtitle).length>0){if(jQuery("#chatbox_"+chatboxtitle).css('display')=='none'){jQuery("#chatbox_"+chatboxtitle).css('display','block')}jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus();return}jQuery(" ").attr("id","chatbox_"+chatboxtitle).addClass("chatbox").html(''+chatboxname+''+chatboxname+' is currently offline.
').prependTo(jQuery("#mainpanel"));if(chatboxblink==1){jQuery('#chatbox_'+chatboxtitle+' .chatboxhead').addClass("chatboxblink")}jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").blur(function(){jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").removeClass('chatboxtextareaselected')}).focus(function(){jQuery('#chatbox_'+chatboxtitle+' .chatboxhead').removeClass('chatboxblink');jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").addClass('chatboxtextareaselected')});jQuery("#chatbox_"+chatboxtitle).click(function(){if(jQuery('#chatbox_'+chatboxtitle+' .chatboxcontent').css('display')!='none'){jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus()}});jQuery("#chatbox_"+chatboxtitle).show()}function chatPoll(){if(Drupal.settings.drupalchat.polling_method=='0'){setTimeout(function(){jQuery.getJSON(Drupal.settings.drupalchat.pollUrl,{drupalchat_last_timestamp:drupalchat.last_timestamp},function(data){processChatData(data)})},(Drupal.settings.drupalchat.refresh_rate)*1000)}else if(Drupal.settings.drupalchat.polling_method=='1'){jQuery.getJSON(Drupal.settings.drupalchat.pollUrl,{drupalchat_last_timestamp:drupalchat.last_timestamp},function(data){processChatData(data)})}}function processChatData(data){var drupalchat_messages=data;if((!drupalchat_messages.status||drupalchat_messages.status==0)){if(drupalchat_messages.messages.length>0){var obj=swfobject.getObjectById("drupalchatbeep");if(obj&&Drupal.settings.drupalchat.notificationSound==="1"){try{obj.drupalchatbeep()}catch(e){}}}jQuery.each(drupalchat_messages.messages,function(index,value){var drupalselfmessage=false;if(value.uid1==Drupal.settings.drupalchat.uid){drupalselfmessage=true}if((value.uid2!=Drupal.settings.drupalchat.uid)&&(value.uid1!=Drupal.settings.drupalchat.uid)){drupalchatroom=true}else{drupalchatroom=false}chatboxtitle=(drupalchatroom||drupalselfmessage)?value.uid2:value.uid1;if(jQuery("#chatbox_"+chatboxtitle).length<=0){if((value.uid2!=Drupal.settings.drupalchat.uid)&&(value.uid1!=Drupal.settings.drupalchat.uid)){chatroomname=data.buddylist[value.uid2].name}else chatroomname="Public Chatroom";createChatBox(chatboxtitle,drupalchatroom?chatroomname:value.name,1)}else if(jQuery("#chatbox_"+chatboxtitle+" .subpanel").is(':hidden')){if(jQuery("#chatbox_"+chatboxtitle).css('display')=='none'){jQuery("#chatbox_"+chatboxtitle).css('display','block')}jQuery('#chatbox_'+chatboxtitle+' .chatboxhead').addClass("chatboxblink");jQuery('#chatbox_'+chatboxtitle+' .chatboxhead').live('click',function(){jQuery('#chatbox_'+chatboxtitle+' .chatboxhead').removeClass("chatboxblink");drupalchat.send_current_uid2=chatboxtitle});jQuery("#chatbox_"+chatboxtitle+" .chatboxtextarea").focus()}if(value.uid1==Drupal.settings.drupalchat.uid){value.name=Drupal.settings.drupalchat.username}if(jQuery("."+value.message_id)[0]){return}value.message=value.message.replace(/{{drupalchat_newline}}/g,"
");value.message=emotify(value.message);if(jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent .chatboxusername a:last").html()==value.name){jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").append(''+value.message+'
')}else{var currentTime=new Date();var hours=currentTime.getHours();var minutes=currentTime.getMinutes();if(hours<10){hours="0"+hours}if(minutes<10){minutes="0"+minutes}jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").append(''+value.message+'
')}jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop(jQuery("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);jQuery.titleAlert(Drupal.settings.drupalchat.newMessage,{requireBlur:true,stopOnFocus:true,interval:800})});jQuery('#chatpanel .subpanel ul').empty();jQuery('li[id^="chatbox_"]').each(function(){Drupal.drupalchat.changeStatus(this.id,0)});jQuery.each(drupalchat_messages.buddylist,function(key,value){if(key!='total'){if(key!=Drupal.settings.drupalchat.uid){jQuery('#chatpanel .subpanel ul').append(''+value.name+'');Drupal.drupalchat.changeStatus('chatbox_'+key,1)}}else{jQuery('#chatpanel .online-count').html(value);if(value==0){jQuery('#chatpanel .subpanel ul').append(Drupal.settings.drupalchat.noUsers)}}});jQuery('#chatpanel .subpanel ul li:last-child').addClass('last');drupalchat.last_timestamp=drupalchat_messages.last_timestamp}chatPoll()}function closeChatBox(chatboxtitle){jQuery('#chatbox_'+chatboxtitle).css('display','none')}jQuery(window).unload(function(){jQuery('.chatbox .chatboxhead').removeClass("chatboxblink");jQuery.drupalchatjStorage.set('username',drupalchat.username);jQuery.drupalchatjStorage.set('uid',drupalchat.uid);jQuery.drupalchatjStorage.set('send_current_message',drupalchat.send_current_message);jQuery.drupalchatjStorage.set('last_timestamp',drupalchat.last_timestamp);jQuery.drupalchatjStorage.set('send_current_uid2',drupalchat.send_current_uid2);jQuery.drupalchatjStorage.set('attach_messages_in_queue',drupalchat.attach_messages_in_queue);jQuery.drupalchatjStorage.set('running',drupalchat.running);jQuery.drupalchatjStorage.set('drupalchat',jQuery('#drupalchat').html())});function drupalchat_getCookie(c_name){var i,x,y,ARRcookies=document.cookie.split(";");for(i=0;i