SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started by: mrtrc266 on June 09, 2009, 02:43:19 PM
-
I have no idea what I'm doing and this is probably toatlly wrong but I've seemed to get a list of users in chat working in Simple Portal.
Only thing I'm would like to do now is get the list to show in the same way that the Users Online Show.
I have the Dot next to "Users In Chat"
2 things I need help with.
1. Need the [user] icon next to each user in chat
2. Need the users names (link) indented
Here code that is in the SSI.php
function ssi_chatOnline($output_method = 'echo')
{
global $db_prefix, $scripturl, $txt;
$users = array();
$userIDs = array();
$result = db_query("SELECT userID
FROM ${db_prefix}ajaxchat_online WHERE NOW() <= DATE_ADD(dateTime, interval 2 MINUTE)
", __FILE__, __LINE__);
while($row = mysql_fetch_assoc($result)) {
array_push($userIDs, $row['userID']);
}
mysql_free_result($result);
$users['IDs'] = array_unique($userIDs);
$users['links'] = array();
if (count($users['IDs']) > 0){
$query = "SELECT mem.ID_MEMBER, mem.realName, mem.ID_GROUP, mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON
(mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))WHERE ";
foreach ($users['IDs'] as $ID)
$query .= 'ID_MEMBER = '. $ID . ' OR ';
//remove the last OR
$query = substr($query, 0, strlen($query)-3);
$result = db_query($query, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'];
if($row['onlineColor'] != ""){
$link.= '" style="color: ' . $row['onlineColor'];
}
$link.= '">' . $row['realName'] . '</a>';
array_push($users['links'], $link);
}
mysql_free_result($result);
}
if ($output_method != 'echo')
return $users;
else{
if (count($users['links']) == 0 )
echo $txt['chat_no_user'];
elseif (count($users['links']) == 1 )
echo '1' . $txt['chat_aUser']. ':<br />', implode($users['links']);
else
echo count($users['links']). $txt['chat_users']. ':<br />', implode('<br />', $users['links']);
}
}
Edit to SPortal1-1.php
Found
echo '
</ul>
<br />
<div class="sp_fullwidth sp_center">', $txt['error_sp_no_online'], '</div>';
}
Added After
echo '
<ul class="sp_list">
<li>', sp_embed_image('dot'), ' ', ssi_chatOnline(),'</li>
</ul>';
See 2 pics for better example of what I'm trying to accomplish
1st pic is the current result
2nd pic is how I'd like it
Thanks in advance for any help.
-
48 hr Bump ;D
Does anyone have any ideas on this?
-
You know, there is a much easier way to do this.
The who's online lists generates all users and what areas they are in. Simply write a script that puts all users that are using "?action=chat" into a list, and then show it on a block.
-
You know, there is a much easier way to do this.
The who's online lists generates all users and what areas they are in. Simply write a script that puts all users that are using "?action=chat" into a list, and then show it on a block.
Me? Write a script? LOL I wish I knew how.
The chat is not an action AJAX Chat is more of a stand alone Chat Room Intergrated into SMF the URL looks like this
www.mysite/chat/index.php
I almost have it...just need the user links indented and the pics to show up. Thanks though.
-
The reason why that's more difficult, Chris, is that the AJAX Chat is an external program (which just happens to nab SMF's user database for permissions), and SMF can't track it. AJAX chat tracks its own users, whether participating in the chatroom or shoutbox versions, and can spit back that list on request, which is what the AJAX Chat Integration mod does.
-
Ahhh, I see now. I was thinking of a different type of integration.
-
The reason why that's more difficult, Chris, is that the AJAX Chat is an external program (which just happens to nab SMF's user database for permissions), and SMF can't track it. AJAX chat tracks its own users, whether participating in the chatroom or shoutbox versions, and can spit back that list on request, which is what the AJAX Chat Integration mod does.
Would you know how the get the "user" pics to show next to the user links and get them inline with the other "users online?"
As always any help is greatly appreciated.
As mentioned I have it 98%....I would just like it to appear like in the second pic
-
I use the following code in a custom PHP block to show who is online in the AJAX Chat (please adapt the german text and the "<linktoyourforum>" part to your needs):
global $db_prefix, $user_info, $context, $scripturl, $modSettings, $txt;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
//users in chat
if (!WIRELESS)
{
$userIDs = chatOnlineUsers();
$context['chat_links'] = array();
if (count($userIDs) > 0)
{
$query = "SELECT mem.ID_MEMBER, mem.realName, mem.ID_GROUP, mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON
(mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))WHERE ";
foreach ($userIDs as $ID)
$query .= 'ID_MEMBER = '. $ID . ' OR ';
//remove the last OR
$query = substr($query, 0, strlen($query)-3);
$result = db_query($query, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
$name = $row['realName'];
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'];
if($row['onlineColor'] != "")
{
$link.= '" style="color: ' . $row['onlineColor'];
}
$link.= '">' . $row['realName'] . '</a>';
array_push($context['chat_links'], $link);
}
mysql_free_result($result);
}
//set the flag true for home page
$context['chat_isHome'] = true;
}
// users in chat
if (isset($context['chat_links']))
{
if (count($context['chat_links']) == 0 )
{
// nobody is in the chat
echo '<ul class="sp_list">
<li>', sp_embed_image('dot'), ' Es ist niemand im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>.
</ul>';
}
else
{
// show users who are in the chat
echo '<ul class="sp_list">
<li>', sp_embed_image('dot'), ' Zur Zeit im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>:
</ul>';
echo '<ul class="sp_list">';
foreach ($context['chat_links'] as $user)
echo '<li class="sp_list_indent">', sp_embed_image('user'), ' ', $user, '</li>';
echo '</ul>';
}
}
Regards,
Dirk
-
I use the following code in a custom PHP block to show who is online in the AJAX Chat (please adapt the german text and the "<linktoyourforum>" part to your needs):
global $db_prefix, $user_info, $context, $scripturl, $modSettings, $txt;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
//users in chat
if (!WIRELESS)
{
$userIDs = chatOnlineUsers();
$context['chat_links'] = array();
if (count($userIDs) > 0)
{
$query = "SELECT mem.ID_MEMBER, mem.realName, mem.ID_GROUP, mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON
(mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))WHERE ";
foreach ($userIDs as $ID)
$query .= 'ID_MEMBER = '. $ID . ' OR ';
//remove the last OR
$query = substr($query, 0, strlen($query)-3);
$result = db_query($query, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
$name = $row['realName'];
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'];
if($row['onlineColor'] != "")
{
$link.= '" style="color: ' . $row['onlineColor'];
}
$link.= '">' . $row['realName'] . '</a>';
array_push($context['chat_links'], $link);
}
mysql_free_result($result);
}
//set the flag true for home page
$context['chat_isHome'] = true;
}
// users in chat
if (isset($context['chat_links']))
{
if (count($context['chat_links']) == 0 )
{
// nobody is in the chat
echo '<ul class="sp_list">
<li>', sp_embed_image('dot'), ' Es ist niemand im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>.
</ul>';
}
else
{
// show users who are in the chat
echo '<ul class="sp_list">
<li>', sp_embed_image('dot'), ' Zur Zeit im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>:
</ul>';
echo '<ul class="sp_list">';
foreach ($context['chat_links'] as $user)
echo '<li class="sp_list_indent">', sp_embed_image('user'), ' ', $user, '</li>';
echo '</ul>';
}
}
Regards,
Dirk
Would it be possible for a translation of the German please. I would like to give this a trial for my portal.
-
Hannilein, thanks, but i think the script is not working for online users... i mean, when nobody's in the chat, it's working, but if someone is chatting, it shows some errors!
i guess making mrtrc266's idea as a mod would be much neater, i mean, why create another block when you can integrate it in the same block?
-
I use the following code in a custom PHP block to show who is online in the AJAX Chat (please adapt the german text and the "<linktoyourforum>" part to your needs):
global $db_prefix, $user_info, $context, $scripturl, $modSettings, $txt;
$block_parameters = array();
if ($return_parameters)
return $block_parameters;
//users in chat
if (!WIRELESS)
{
$userIDs = chatOnlineUsers();
$context['chat_links'] = array();
if (count($userIDs) > 0)
{
$query = "SELECT mem.ID_MEMBER, mem.realName, mem.ID_GROUP, mg.onlineColor, mg.ID_GROUP
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON
(mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))WHERE ";
foreach ($userIDs as $ID)
$query .= 'ID_MEMBER = '. $ID . ' OR ';
//remove the last OR
$query = substr($query, 0, strlen($query)-3);
$result = db_query($query, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
$name = $row['realName'];
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'];
if($row['onlineColor'] != "")
{
$link.= '" style="color: ' . $row['onlineColor'];
}
$link.= '">' . $row['realName'] . '</a>';
array_push($context['chat_links'], $link);
}
mysql_free_result($result);
}
//set the flag true for home page
$context['chat_isHome'] = true;
}
// users in chat
if (isset($context['chat_links']))
{
if (count($context['chat_links']) == 0 )
{
// nobody is in the chat
echo '<ul class="sp_list">
<li>', sp_embed_image('dot'), ' Es ist niemand im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>.
</ul>';
}
else
{
// show users who are in the chat
echo '<ul class="sp_list">
<li>', sp_embed_image('dot'), ' Zur Zeit im <a href="<linktoyourforum>/chat/index.php" target="_blank">Chat</a>:
</ul>';
echo '<ul class="sp_list">';
foreach ($context['chat_links'] as $user)
echo '<li class="sp_list_indent">', sp_embed_image('user'), ' ', $user, '</li>';
echo '</ul>';
}
}
Regards,
Dirk
Would it be possible for a translation of the German please. I would like to give this a trial for my portal.
It worked fine at my site www.baask.com/diwwan
-
Here we go, Hunter (AJAX Chat Intergration Mod Author) made a little add-on that has it exaclty like I was trying to explain.
Thank you!
-
Here we go, Hunter (AJAX Chat Intergration Mod Author) made a little add-on that has it exaclty like I was trying to explain.
Thank you!
I installed this add-on and got the following error..
Fatal error: Call to undefined function ssi_chatonline() in /home/reefersr/public_html/dev/Sources/SPortal2.php on line 798
I am using ajax 3.0 and SP 2.2.2. Does chat 3.2 need to be installed?
-
Tested with SP 2.3.2 and SMF RC3 (modified from Hunters Addon)
(http://i216.photobucket.com/albums/cc92/mrtrc266/spchat.png)
Find /Sources/PortalBlocks.php
}
function sp_boardStats($parameters, $id, $return_parameters = false)
Replace with
//AJAX Chat Users in Chat
$users = ssi_chatOnline('SP');
$count = count($users['links']);
echo '
<ul class="sp_list">
<li>', sp_embed_image('dot'), ' ',$txt['chat_users'], ': ', $count, '</li>
</ul>';
if ($count >= 1 ){
echo '
<ul class="sp_list">';
if ($count == 1 )
echo '
<li class="sp_list_indent">', sp_embed_image('user'), ' ', implode($users['links']), '</li>';
else
foreach ($users['links'] as $link)
echo '
<li class="sp_list_indent">', sp_embed_image('user'), ' ', $link, '</li>';
echo '
</ul>';
}
}
function sp_boardStats($parameters, $id, $return_parameters = false)
-
Hurrah
It works. Can see who is in chat on the block.
One for the next version maybe?
-
Tested with SP 2.3.2 and SMF RC3 (modified from Hunters Addon)
(http://i216.photobucket.com/albums/cc92/mrtrc266/spchat.png)
Find /Sources/PortalBlocks.php
}
function sp_boardStats($parameters, $id, $return_parameters = false)
Replace with
//AJAX Chat Users in Chat
$users = ssi_chatOnline('SP');
$count = count($users['links']);
echo '
<ul class="sp_list">
<li>', sp_embed_image('dot'), ' ',$txt['chat_users'], ': ', $count, '</li>
</ul>';
if ($count >= 1 ){
echo '
<ul class="sp_list">';
if ($count == 1 )
echo '
<li class="sp_list_indent">', sp_embed_image('user'), ' ', implode($users['links']), '</li>';
else
foreach ($users['links'] as $link)
echo '
<li class="sp_list_indent">', sp_embed_image('user'), ' ', $link, '</li>';
echo '
</ul>';
}
}
function sp_boardStats($parameters, $id, $return_parameters = false)
Thanks a lot. it worked for me too :)
-
Does anyone know if this works with SMF RC5, too?
-
I have got this working at http://squeeze.follyball.co.uk/index.php (http://squeeze.follyball.co.uk/index.php) but it will only show up on the Index page. Is there any way to get it to show on every page?
Steve
-
Does anyone know if this works with SMF RC5, too?
Quoting myself, but anyhow... I tried it, and the answer is yes.