SimplePortal

Customization => Blocks and Modifications => Topic started by: phantomm on September 24, 2012, 12:35:32 PM

Title: Extremely simple bans for SP Shoutbox
Post by: phantomm on September 24, 2012, 12:35:32 PM
Hey,

I have at one site few users that I have to ban from using Shoutbox, but I didn't wanted to create new group (I have them already too much...).
So I made extremely simple bans for SP Shoutbox.

(http://img89.imageshack.us/img89/9096/generalsettingst.png)

(http://img37.imageshack.us/img37/281/myboard.png)

Before editing any file remember to make backup!

Here's what I came up with :D

1. Open ./Themes/default/languages/SPortal.english.php:
Code: (Find) [Select]
?>
Code: (Replace with) [Select]
$txt['sp_shoutbox_you_are_banned'] = 'You are banned in Shoutbox';

?>

2. Open ./Themes/default/languages/SPortalAdmin.english.php:
Code: (Find) [Select]
?>
Code: (Replace with) [Select]
$txt['sp_shoutbox_bans_enable'] = 'Enable bans in Shoutbox';
$txt['sp_shoutbox_banned_users'] = 'Banned users';
$txt['sp_shoutbox_banned_users_desc'] = 'Add user ID\'s separated with comma, without spaces';

?>

3. Open ./Themes/default/PortalShoutbox.template.php:
Code: (Find) [Select]
if ($context['can_shout'])
echo '
<div class="shoutbox_input smalltext">
<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input sp_float_left input_text"', $context['browser']['is_ie'] ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="sp_float_right button_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
</div>';
Code: (Replace with) [Select]
if ($context['can_shout'] && !empty($modSettings['sp_shoutbox_bans_enable']) && !empty($modSettings['sp_shoutbox_banned_users']) && in_array($user_info['id'], explode(',', ''.$modSettings['sp_shoutbox_banned_users'].'')))
{
echo '
<div class="shoutbox_input smalltext">
<input type="text" name="new_shout" class="shoutbox_input sp_float_left input_text" disabled="disabled" readonly="readonly" value="', $txt['sp_shoutbox_you_are_banned'], '"/>
</div>';
}
elseif ($context['can_shout'])
{
echo '
<div class="shoutbox_input smalltext">
<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input sp_float_left input_text"', $context['browser']['is_ie'] ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="sp_float_right button_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
</div>';
}

Code: (Find) [Select]
function template_shoutbox_embed($shoutbox)
{
global $context, $scripturl, $settings, $txt;
Code: (Replace with) [Select]
function template_shoutbox_embed($shoutbox)
{
global $context, $scripturl, $settings, $txt;
global $user_info, $modSettings;

5. Open ./Sources/PortalAdminMain.php:
Code: (Find) [Select]
array('check', 'sp_resize_images'),
Code: (Replace with) [Select]
array('check', 'sp_resize_images'),
'',
array('check', 'sp_shoutbox_bans_enable'),
array('text', 'sp_shoutbox_banned_users', 'subtext' => $txt['sp_shoutbox_banned_users_desc']),

and that's it :)

Now you can go to Administration Center » Configuration » General Settings and ban people >:-D
Title: Re: Extremely simple bans for SP Shoutbox
Post by: Kryzen on October 01, 2012, 09:32:43 AM
It looks great, I'll move the topic to Blocks and Modifications for you. :)
Title: Re: Extremely simple bans for SP Shoutbox
Post by: phantomm on October 01, 2012, 10:38:11 AM
I thought that I posted in correct board... Thanks for moving ;)
Title: Re: Extremely simple bans for SP Shoutbox
Post by: Kryzen on October 01, 2012, 10:40:29 AM
You posted in the correct board, when a modification or block has been reviewed, it'll be moved to this board by a team member. :)
Title: Re: Extremely simple bans for SP Shoutbox
Post by: phantomm on October 01, 2012, 11:05:36 AM
ah.. good to know :)
Title: Re: Extremely simple bans for SP Shoutbox
Post by: katoon on November 30, 2012, 02:44:56 PM
I approve this  :applause:
Title: Re: Extremely simple bans for SP Shoutbox
Post by: TinMan on November 30, 2012, 06:42:26 PM
Nice mod phantomm :)
Title: Re: Extremely simple bans for SP Shoutbox
Post by: player.samp on April 30, 2014, 07:25:19 AM
Can you make this as package to download please?
Title: Re: Extremely simple bans for SP Shoutbox
Post by: phantomm on April 30, 2014, 08:37:06 AM
I'm going to write real mod for this, because now, when this is only template edits user can use "inspect element" feature available in all browsers to add HTML code and send messages.. Now when I look at this code I think 'How could I even post it here..."
SimplePortal 2.3.8 © 2008-2024, SimplePortal