SimplePortal

Customization => Custom Coding => Topic started by: 420connect on July 24, 2015, 01:03:16 PM

Title: shoutbox history...
Post by: 420connect on July 24, 2015, 01:03:16 PM
Hey everyone,
I'm on my phone so typing isn't great so I'll try and keep this brief..

Could someone help me add a *if admin* show the shoutbox history button *else* hide it..

I'm also wwondering what happens when the shoutbox reaches its total messages allowed?.. Can I add some code to auto delete the chatlog once it's full..?

Many thanks as always :-)
Title: Re: shoutbox history...
Post by: ♦ Ninja ZX-10RR ♦ on July 24, 2015, 01:52:18 PM
Hi 420connect,

Please open your /Themes/default/PortalShoutbox.template.php

Code: (find) [Select]
echo '
<form action="" method="post">
<div class="shoutbox_container">
<div class="shoutbox_info">
<div id="shoutbox_load_', $shoutbox['id'], '" style="float: right; display: none;"><img src="', $settings['sp_images_url'], '/loading.gif" alt="" /></div>
<a href="', $scripturl, '?action=portal;sa=shoutbox;shoutbox_id=', $shoutbox['id'], '" onclick="sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], '); return false;">', sp_embed_image('refresh'), '</a> <a href="', $scripturl, '?action=portal;sa=shoutbox;shoutbox_id=', $shoutbox['id'], '">', sp_embed_image('history'), '</a>';

if ($context['can_shout'])
echo ' <a href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('smiley'), '</a> <a href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('style'), '</a>';

Code: (replace with) [Select]
echo '
<form action="" method="post">
<div class="shoutbox_container">
<div class="shoutbox_info">
<div id="shoutbox_load_', $shoutbox['id'], '" style="float: right; display: none;"><img src="', $settings['sp_images_url'], '/loading.gif" alt="" /></div>
<a href="', $scripturl, '?action=portal;sa=shoutbox;shoutbox_id=', $shoutbox['id'], '" onclick="sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], '); return false;">', sp_embed_image('refresh'), '</a>';
if ($context['user']['is_admin'])
echo '
<a href="', $scripturl, '?action=portal;sa=shoutbox;shoutbox_id=', $shoutbox['id'], '">', sp_embed_image('history'), '</a>';

if ($context['can_shout'])
echo ' <a href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('smiley'), '</a> <a href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('style'), '</a>';

Best thing is that I tested it and it works ;) Or well, looks like it does since I could see it from my admin account but not from a regular one.



I'm also wwondering what happens when the shoutbox reaches its total messages allowed?.. Can I add some code to auto delete the chatlog once it's full..?
In the shoutbox settings there is this: Maximum shouts: X
I guess that controls it, and the ones exceeding that number get deleted automatically, but you can still manually prune it if you want to.

Regards
Title: Re: shoutbox history...
Post by: [SiNaN] on July 24, 2015, 02:58:36 PM
The change that Ninja provided should be good for hiding the button. Just keep in mind that the users will still be able to access the shoutbox history if they know the URL, unless you restrict the access by editing PortalShoutbox.php file as well.

As for reaching the maximum number of shouts; the shouts will be deleted starting from the oldest ones to accommodate new shouts.
Title: Re: shoutbox history...
Post by: ♦ Ninja ZX-10RR ♦ on July 24, 2015, 03:37:17 PM
True, but I think that reaching that particular URL is annoying enough that people won't bother (assuming they know the link) to type it ;D

Seriously talking... Not sure how to edit the PortalShoutbox.php :/
Title: Re: shoutbox history...
Post by: 420connect on July 25, 2015, 02:47:22 AM
Many thanks you 2!
I'll get it implemented when I can get on a computer.
Title: Re: shoutbox history...
Post by: [SiNaN] on July 25, 2015, 05:46:27 AM
If you'd like to disable direct access as well, the following change should do it:

Sources/PortalShoutbox.php

Code: (Find) [Select]
$request = $smcFunc['db_query']('', '
Code: (Replace) [Select]
if (!$context['user']['is_admin'])
fatal_lang_error('no_access', false);

$request = $smcFunc['db_query']('', '
Title: Re: shoutbox history...
Post by: 420connect on July 25, 2015, 09:16:09 AM
Just implemented both of them and they both worked flawlessly!

 :applause:

Many thanks again!
Title: Re: shoutbox history...
Post by: ♦ Ninja ZX-10RR ♦ on July 25, 2015, 09:41:15 AM
Thanks SiNaN for helping me out on this one :) Wasn't exactly sure on where to place the if statement.

420connect, glad they both did the trick!
SimplePortal 2.3.8 © 2008-2024, SimplePortal