SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: raffo on May 30, 2010, 01:32:12 PM

Title: how to make a block visible to every group except...
Post by: raffo on May 30, 2010, 01:32:12 PM
in my forum i have users categorized in groups...

users have 2 groups each [the first group: the year of subscription (that is the one visualized in the posts too), and the second group: just for me to organize the viewable content, and divided in "view"/"not view"]...

my goal is to make a block visible only to people that are not in the group called "view"...
this because i have users in the group of the year without being in the group "view"...

problem is that if i set all the groups except that one in the block permission,  i don't reach my goal!
this because in this way EVEN the people in the "view" group will see it, because i have no user that is in the "view" group without being in a "year of subscription" group (as i said: primary and secondary group)!

it'd be nice to have the possibility to set the block permission as:
let view to users that aren't in this (these) group(s)...
Title: Re: how to make a block visible to every group except...
Post by: Nathaniel on May 30, 2010, 09:34:58 PM
I'm sure that the addition of denying permissions/block viewing to certain membergroups to SimplePortal has been discussed somewhere (might be in a dev board actually).

Anyway, here is a custom edit that should help you to do this:

Code: ("Find (Sources/Subs-Portal.php)") [Select]
if (allowedTo('sp_admin'))
return true;

Code: ("Replace") [Select]
if (allowedTo('sp_admin'))
return true;

if ($type == 'block' && in_array($id, array(1, 2, 3, 4)) && in_array(53, $user_info['groups']))
return false;

Where '1, 2, 3, 4' is a list of blocks that this code will effect and '53' is the id of the group which won't be able to see those blocks.
Title: Re: how to make a block visible to every group except...
Post by: raffo on June 02, 2010, 03:12:45 AM
simply perfect!
it works very nice for my solution, so when a user is in 2 groups as i explained above... :)


just another question: in your example is possible to add a OR or AND for the id of the groups?
Title: Re: how to make a block visible to every group except...
Post by: Nathaniel on June 02, 2010, 04:05:49 AM
just another question: in your example is possible to add a OR or AND for the id of the groups?

Yes. As an example, the code below would stop anyone in groups 53 or 42 from seeing blocks 1, 2, 3, 4.

Code: [Select]
if (allowedTo('sp_admin'))
return true;

if ($type == 'block' && in_array($id, array(1, 2, 3, 4)) && (in_array(53, $user_info['groups']) || in_array(42, $user_info['groups'])))
return false;
Title: Re: how to make a block visible to every group except...
Post by: raffo on June 02, 2010, 04:26:12 AM
thanks! :)
SimplePortal 2.3.8 © 2008-2024, SimplePortal