Jump to content

canReact improve check


BomAle
 Share

Go to solution Solved by BomAle,

Recommended Posts

Hello,

I wanted to suggest changing this:
/* Protected Groups */
if ( $owner->inGroup( explode( ',', \IPS\Settings::i()->reputation_protected_groups ) ) )
{
	return FALSE;
}

into a better way to check if there is a group (primary or secondary) authorized to receive reaction.

Edited by BomAle
Link to comment
Share on other sites

  • Solution
/* Protected Groups */
if ( !$owner->inGroup( array_diff( array_keys(\IPS\Member\Group::groups( TRUE, FALSE )), explode( ',', \IPS\Settings::i()->reputation_protected_groups ) ) ) )
{
	return FALSE;
}

this is way check only if inside one of groups granted

Edited by BomAle
array_keys and groups( TRUE, FALSE ) skip guest
Link to comment
Share on other sites

check it yourself

<?php
require_once './init.php';
\IPS\Dispatcher\External::i();
echo "groups authorized receive reputation:<br>";
$output = '';
foreach(array_diff( array_keys(\IPS\Member\Group::groups( TRUE, FALSE )), explode( ',', \IPS\Settings::i()->reputation_protected_groups ) ) as $g)
{
	$output .= \IPS\Member\Group::load( $g )->formattedName . '<br>';
}
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $output );
echo $output;

 

Edited by BomAle
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...