SimplePortal

Support => English Support => Topic started by: Uardo on August 31, 2015, 09:44:58 AM

Title: Muted users not allowed to shout in shoutbox.
Post by: Uardo on August 31, 2015, 09:44:58 AM
Hello evryone,

I am asking if it is possible to make it so users who are muted cannot shout in shoutbox, they already cannot send PMs or post on boards, would be great if someone can show us a way to make it so they can't shout in shoutbox.

Thank you for your time.
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ♦ Ninja ZX-10RR ♦ on August 31, 2015, 10:20:58 AM
Hi Uardo,

I think it has been answered before, but I can't find it at the moment. Basically the way to proceed is to create a membergroup that has *denied* permission to see the shoutbox block, and assign it when necessary.
If you need moderators to be able to assign that membergroup without giving them the "Manage and assign membergroup" permission, you can simply add them as moderators for the banned membergroup.
Hope you don't mind if I move this to Support as coding is not involved ;)

Hint: you can also create a block only visible to the banned membergroup, with some text telling them they have been banned from the shoutbox (which is what I did on my own forum).

Regards
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on August 31, 2015, 11:59:49 AM
Actually creating a membergroup that has denied permission to see the shoutbox block would be a pain and a really hard work, since we have to assign it manually whenever they are muted and remove from membergroup when they are unmuted, i am talking about forums that have over 10,000 users and many of them getting muted daily, imagine having to check everyday if someone is muted or if someone's mute expired.

I am looking for a simple code that would not allow muted users to shout, I don't know much about coding but it should be something like that:

If user muted, not_allowed_to {shout at shoutbox}

I don't know which template to modify, what to replace or add, that's why i am asking!

Regards,
Uardo!



Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ♦ Ninja ZX-10RR ♦ on August 31, 2015, 12:15:26 PM
And that is unfortunately the same thing I said, it works in the same way :/ The closest thing we have is this: http://simpleportal.net/index.php?topic=11714.0 but I'm pretty sure it's not *exactly* what you want either.
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ccbtimewiz on August 31, 2015, 10:02:07 PM
You can check if they can send PMs. If they can't send a PM, then reject their shout.

Open /Sources/PortalShoutbox.php

Find:
Code: [Select]
if (!empty($_REQUEST['shout']))
{
checkSession('request');

is_not_guest();

Replace with:
Code: [Select]
if (!empty($_REQUEST['shout']))
{
checkSession('request');

is_not_guest();
isAllowedTo('pm_send');

This will result in an fatal error if someone tries to make a shout when they don't have permission to send a pm.
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ♦ Ninja ZX-10RR ♦ on September 01, 2015, 05:22:30 AM
Didn't think of that, it could work, even if personally I don't like fatal error thingies.
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on September 01, 2015, 06:50:29 AM
Muted users are not allowed to send PMs. I tried that and it worked, they couldn't shout and i didn't get any error.

I made it so some users couldn't send PMs, and told them to shout while they weren't muted they couldn't but didn't get any fatal error at all.
While you are muted you cannot shout, even that you are allowed to type but when you press enter it keeps reloading (http://puu.sh/jW6rj/5eb9e45060.png) and shout does not appear, is it possible so when you press enter after shouting you will get a message "You are not allowed to shout because you're muted" or something like that, if not no problem!

Thank you for your time and efforts.
Regards,
Uardo
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ccbtimewiz on September 01, 2015, 10:52:00 AM
Hmm.

In that case, revert my edits above and try this;

Find:
Code: [Select]
is_not_guest();
Replace with:
Code: [Select]
is_not_guest();

if (!allowedTo('pm_send'))
{
$_REQUEST['shout'] = '';
$context['can_shout'] = false;
}

Open /Themes/default/PortalShoutbox.template.php

Find:
Code: [Select]
if (!empty($shoutbox['warning']))
echo '
<li class="shoutbox_warning smalltext">', $shoutbox['warning'], '</li>';

Replace with:
Code: [Select]
if (!allowedTo('pm_send'))
$shoutbox['warning'] = 'Sorry, but you are banned from using the shoutbox!';

if (!empty($shoutbox['warning']))
echo '
<li class="shoutbox_warning smalltext">', $shoutbox['warning'], '</li>';
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on September 01, 2015, 12:21:22 PM
When i try to add this
Code: [Select]
if (!allowedTo('pm_send']))
$shoutbox['warning'] = 'Sorry, but you are banned from using the shoutbox!';

Shoutbox and some other blocks does not appear anymore even for users who are not muted.
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ccbtimewiz on September 01, 2015, 12:26:50 PM
That's strange, try this:

Code: [Select]
if (allowedTo('pm_send']) == false)
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on September 01, 2015, 12:30:39 PM
Same problem again.
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ccbtimewiz on September 01, 2015, 06:59:24 PM
You are editing the PortalShoutbox.template.php file right?
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on September 01, 2015, 08:18:04 PM
Yes i am.

It's ok if it cannot be done!
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ccbtimewiz on September 01, 2015, 09:00:36 PM
Let's try it this way then. Make sure to revert all my previous edits.

Open /Sources/PortalShoutbox.php

Find:
Code: [Select]
is_not_guest();
Replace with:
Code: [Select]
is_not_guest();

if (!allowedTo('pm_send'))
{
$_REQUEST['shout'] = '';
$context['banned_from_shoutbox'] = true;
$context['can_shout'] = false;
}
else
$context['banned_from_shoutbox'] = false;

Open /Themes/default/PortalShoutbox.template.php

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

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

if ($context['banned_from_shoutbox'])
$shoutbox['warning'] = 'Sorry, but you are banned from using the shoutbox!';
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on September 01, 2015, 09:29:01 PM
I tried it but the warning message "Sorry, but you are banned from using the shoutbox!" does not appear. The good thing is that this time muted users can see shoutbox and other blocks.

The warning should appear just like "Your last shout was less than 2 seconds ago. Please try again later." message but it isn't.
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ccbtimewiz on September 02, 2015, 01:09:37 AM
Could you check your error log and tell me if you see any undefined indexes for "banned_from_shoutbox"?
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on September 02, 2015, 04:15:07 AM
http://puu.sh/jXaLF/4a68abb107.png

Line 102 is this:    if ($context['banned_from_shoutbox'])
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ccbtimewiz on September 02, 2015, 08:28:22 PM
Sorry, I don't mean to drag this on forever. Revert all previous edits.

Open /Sources/PortalShoutbox.php

Find:
Code: [Select]
if (!empty($_REQUEST['shout']))
{

Replace with:
Code: [Select]
// Can they send a PM on the boards? If not, empty out their request...
if (!allowedTo('pm_send'))
$_REQUEST['shout'] = '';

if (!empty($_REQUEST['shout']))
{

This will make any shout they try and make empty.

Open /Themes/default/PortalShoutbox.template.php

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

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

if (!allowedTo('pm_send') && $context['user']['is_logged'])
{
$context['can_shout'] = false;
$shoutbox['warning'] = 'Sorry, but you are banned from using the shoutbox!';
}
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on September 03, 2015, 04:28:04 AM
Thank you, really appreciated.

Marking this as solved!


Edit: I just realized that guests can see the warning that muted users see in shoutbox..
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: ccbtimewiz on September 03, 2015, 01:00:04 PM
Adjusted it, forgot that guests can't send PMs lol.
Title: Re: Muted users not allowed to shout in shoutbox.
Post by: Uardo on September 03, 2015, 01:03:30 PM
Thank you!
SimplePortal 2.3.8 © 2008-2024, SimplePortal