Customization > Blocks and Modifications

Extremely simple bans for SP Shoutbox

(1/2) > >>

phantomm:
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.





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) ---?>

--- End code ---

--- Code: (Replace with) ---$txt['sp_shoutbox_you_are_banned'] = 'You are banned in Shoutbox';

?>

--- End code ---

2. Open ./Themes/default/languages/SPortalAdmin.english.php:

--- Code: (Find) ---?>

--- End code ---

--- Code: (Replace with) ---$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';

?>

--- End code ---

3. Open ./Themes/default/PortalShoutbox.template.php:

--- Code: (Find) --- 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>';

--- End code ---

--- Code: (Replace with) --- 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>';
}

--- End code ---


--- Code: (Find) ---function template_shoutbox_embed($shoutbox)
{
global $context, $scripturl, $settings, $txt;

--- End code ---

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

--- End code ---

5. Open ./Sources/PortalAdminMain.php:

--- Code: (Find) --- array('check', 'sp_resize_images'),

--- End code ---

--- Code: (Replace with) --- array('check', 'sp_resize_images'),
'',
array('check', 'sp_shoutbox_bans_enable'),
array('text', 'sp_shoutbox_banned_users', 'subtext' => $txt['sp_shoutbox_banned_users_desc']),

--- End code ---

and that's it :)

Now you can go to Administration Center » Configuration » General Settings and ban people >:-D

Kryzen:
It looks great, I'll move the topic to Blocks and Modifications for you. :)

phantomm:
I thought that I posted in correct board... Thanks for moving ;)

Kryzen:
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. :)

phantomm:
ah.. good to know :)

Navigation

[0] Message Index

[#] Next page

Go to full version