SimplePortal
Customization => Custom Coding => Topic started 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
-
: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.
-
$stats = ssi_whosOnline('array');
$stats = ssi_whosOnline('array');
$chat_users = chatOnlineUsers();
$user['link'], '</li>';
$user['link'], in_array($user['id'], $chat_users) ? ' [In Chat]' : '', '</li>';
You can change [In Chat] text as you like.
-
Thanks Sinan that works perfectly!!!
-
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
-
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.
-
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:
$stats = ssi_whosOnline('array');
$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);
$user['link'], '</li>';
$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.
-
Pardon my ignorance, but which file do I edit?
-
Oops, forgot to note: It's Sources/PortalBlocks.php file.
-
Fantastic, thank you. It works!
-
Thanks again [SiNaN] works great!!!
-
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?
-
Yes, do this instead:
$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);
-
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.
-
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.
-
That was for the ones using Flashchat. I believe you are using AjaxChat Integration.
-
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
$stats = ssi_whosOnline('array');
Replace With
$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
$user['link'], '</li>';
Replace With
$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
$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
-
For Flashchat and SMF 2.0:
$stats = ssi_whosOnline('array');
$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);
$user['link'], '</li>';
$user['link'], in_array($user['id'], $chat_users) ? ' [In Chat]' : '', '</li>';
You can change [In Chat] text as you like.
-
Thanks so much [SiNaN] worked perfectly :)
-
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 . :(
-
<!-- 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