SimplePortal

Customization => Custom Coding => Topic started by: Zirc on January 06, 2010, 06:07:57 PM

Title: Display if somebody is chatting in Who's Online block
Post by: Zirc on January 06, 2010, 06:07:57 PM
Okay i'm gonna post this here first and see if anybody has any ideas before looking elsewhere.
I have AjaxChat Integration 3.2.1, SMF 1.1.11 and SimplePortal 2.3.1 and am looking for some sort of custom code I guess.

What I would like to do is display in the Who's Online block of SimplePortal (chatting) next to a users name if they are in AjaxChat.  I think this should be fairly simple but since my php knowledge is limited I can't figure out the code.  I imagine all it needs to do is get the UserID for the person online and then query the ajaxchat_online table to see if they are the same then output the text (chatting) and if the UserID is not in ajaxchat_online it would not display anything.  Seems pretty straightforward but i'm not sure how to go about it.

My forums are at http://www.tholeweb.com/forums if you need to take a look.

Any help would be great! Thanks
Title: Re: Display if somebody is chatting in Who's Online block
Post by: Stigmartyr on January 21, 2010, 06:24:46 PM
 :thumbsup: Yes please!  I second his motion.  I left behind flash chat in favor of Ajax Chat and I would really like this feature as well.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: [SiNaN] on January 22, 2010, 09:36:16 AM
Code: (Find) [Select]
$stats = ssi_whosOnline('array');
Code: (Replace) [Select]
$stats = ssi_whosOnline('array');
$chat_users = chatOnlineUsers();

Code: (Find) [Select]
$user['link'], '</li>';
Code: (Replace) [Select]
$user['link'], in_array($user['id'], $chat_users) ? ' [In Chat]' : '', '</li>';
You can change [In Chat] text as you like.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: Zirc on January 22, 2010, 03:39:54 PM
Thanks Sinan that works perfectly!!!
Title: Re: Display if somebody is chatting in Who's Online block
Post by: cme1st2302 on January 22, 2010, 09:22:30 PM
Thanks I have been looking for this as well but I was wondering how I would get it to work with FlashChat. 

One question though, if you make these changes wouldn't they be lost the next time there is an update to SP?

Chris
Title: Re: Display if somebody is chatting in Who's Online block
Post by: Zirc on January 22, 2010, 10:24:17 PM
I'm not positive on how the updates to SP work but I'd imagine any custom modifications to the code would be lost.  I myself have all my forum files backed up in a separate directory before I make any changes just to be safe and then you would have a copy you could get the modification from if it is lost.  Or you could just make a text file and copy these code changes into it and any others you do so you have a record of the changes.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: [SiNaN] on January 23, 2010, 12:43:34 PM
Thanks I have been looking for this as well but I was wondering how I would get it to work with FlashChat. 

One question though, if you make these changes wouldn't they be lost the next time there is an update to SP?

Chris

For Flashchat:

Code: (Find) [Select]
$stats = ssi_whosOnline('array');
Code: (Replace) [Select]
$stats = ssi_whosOnline('array');

global $db_prefix;

$request = db_query("
SELECT userid
FROM {$db_prefix}fc_connections
WHERE userid > 0", __FILE__, __LINE__);
$chat_users = array();
while ($row = mysql_fetch_assoc($request))
$chat_users[] = $row['userid'];
mysql_free_result($request);

Code: (Find) [Select]
$user['link'], '</li>';
Code: (Replace) [Select]
$user['link'], in_array($user['id'], $chat_users) ? ' [In Chat]' : '', '</li>';
You can change [In Chat] text as you like.

I'm not positive on how the updates to SP work but I'd imagine any custom modifications to the code would be lost.  I myself have all my forum files backed up in a separate directory before I make any changes just to be safe and then you would have a copy you could get the modification from if it is lost.  Or you could just make a text file and copy these code changes into it and any others you do so you have a record of the changes.

Yeah, you'll lose your edits on updates. At some point I was hoping to make each block as separate files, so only the really updates blocks will updated and others won't be affected. The best I can suggest now is logging your edits so you can apply them after an update.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: Stigmartyr on January 23, 2010, 01:24:16 PM
Pardon my ignorance, but which file do I edit?
Title: Re: Display if somebody is chatting in Who's Online block
Post by: [SiNaN] on January 23, 2010, 01:26:14 PM
Oops, forgot to note: It's Sources/PortalBlocks.php file.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: Stigmartyr on January 23, 2010, 01:30:17 PM
Fantastic, thank you.  It works!
Title: Re: Display if somebody is chatting in Who's Online block
Post by: cme1st2302 on January 23, 2010, 09:30:31 PM
Thanks again [SiNaN]  works great!!!
Title: Re: Display if somebody is chatting in Who's Online block
Post by: Normally on January 24, 2010, 04:33:11 PM
I get the following fault message:
Fatal error:  Call to undefined function  db_query() in /home/kaarten/domains/kaartenleggen.nl/public_html/lenormandkaarten/Sources/PortalBlocks.php on line 318

Any idea?
Title: Re: Display if somebody is chatting in Who's Online block
Post by: ccbtimewiz on January 24, 2010, 06:24:47 PM
Yes, do this instead:

Code: [Select]
   $request = $smcFunc['db_query']('', "
      SELECT userid
      FROM {db_prefix}fc_connections
      WHERE userid > 0");

   $chat_users = array();
   while ($row = $smcFunc['db_fetch_assoc']($request))
      $chat_users[] = $row['userid'];
   $smcFunc['db_free_result']($request);
Title: Re: Display if somebody is chatting in Who's Online block
Post by: [SiNaN] on January 28, 2010, 11:30:24 AM
The code I gave was for SMF 1.1 versions. If you are using SMF 2.0 versions, replace the query with the one ccbtimewiz gave above.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: Stigmartyr on January 28, 2010, 07:10:36 PM
Funny Im using SMF 2.0 RC2 and it works with the code I used.  Well as of the date that I posted it worked, I am using whatever code was available at that time.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: [SiNaN] on January 29, 2010, 11:54:23 AM
That was for the ones using Flashchat. I believe you are using AjaxChat Integration.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: filipina on February 26, 2010, 09:25:31 PM
Hello!  SMF 2.0 RC2 and Flashchat 6.06 installed. I tried to piece together what is written here 1.1.11 v/s 2.0 RC2 for my Portal block but I am getting parse errors. Do I have something wrong here, could someone please help me. It would be greatly appreciated  :)

Find
Code: [Select]
$stats = ssi_whosOnline('array');
Replace With
Code: [Select]
      $stats = ssi_whosOnline('array');

      global $db_prefix;

      $request = $smcFunc['db_query']('', "
          SELECT userid
          FROM {db_prefix}fc_connections
          WHERE userid > 0");

      $chat_users = array();
      while ($row = $smcFunc['db_fetch_assoc']($request))
          $chat_users[] = $row['userid'];
      $smcFunc['db_free_result']($request);

Find
Code: [Select]
$user['link'], '</li>';
Replace With
Code: [Select]
$user['link'], in_array($user['id'], $chat_users) ? ' [In Chat]' : '', '</li>';
I get


Fatal error: Function name must be a string in /xxxxxxxx/public_html/penpal-community/Sources/PortalBlocks.php on line 319

-----------------------------------------------------------


So then I thought I found an error here    ['db_query']('', "       so i tried this
 
Code: [Select]
$stats = ssi_whosOnline('array');

global $db_prefix;

       $request = $smcFunc['db_query']('', '
          SELECT userid
          FROM {db_prefix}fc_connections
          WHERE userid > 0");

       $chat_users = array();
       while ($row = $smcFunc['db_fetch_assoc']($request))
          $chat_users[] = $row['userid'];
       $smcFunc['db_free_result']($request);

And got fatal error line 325 and the page wouldn't load LOL
Title: Re: Display if somebody is chatting in Who's Online block
Post by: [SiNaN] on February 27, 2010, 03:55:16 AM
For Flashchat and SMF 2.0:

Code: (Find) [Select]
$stats = ssi_whosOnline('array');
Code: (Replace) [Select]
$stats = ssi_whosOnline('array');

global $smcFunc;

$request = $smcFunc['db_query']('', '
SELECT userid
FROM {db_prefix}fc_connections
WHERE userid > 0');
$chat_users = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$chat_users[] = $row['userid'];
$smcFunc['db_free_result']($request);

Code: (Find) [Select]
$user['link'], '</li>';
Code: (Replace) [Select]
$user['link'], in_array($user['id'], $chat_users) ? ' [In Chat]' : '', '</li>';
You can change [In Chat] text as you like.
Title: Re: Display if somebody is chatting in Who's Online block
Post by: filipina on February 27, 2010, 02:03:43 PM
Thanks so much [SiNaN] worked perfectly :)
Title: Re: Display if somebody is chatting in Who's Online block
Post by: sekhon on January 30, 2012, 01:39:11 PM
i am using Flashchat 6 and smf 2.0.2

i am bit confused , which file i need to edit with the above code @ [SiNaN]

i want to show block of chat users of FlashChat 6 .  :(
Title: Re: Display if somebody is chatting in Who's Online block
Post by: sekhon on January 30, 2012, 01:59:27 PM
 <!-- Flashchat Who is -->
<p><iframe height="100" frameborder="0" src="chat/info_embedded.php" style="width: 100%; margin: 0; padding: 0; border: 0; overflow: hidden;" scrolling="no" border="0" allowtransparency="true"></iframe></p>
<!-- End Flashchat who is --> 


the above is best solution i ever get.

Thanks to allllllllllllllllllllllll  ;D
SimplePortal 2.3.8 © 2008-2024, SimplePortal