Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Donovan
Client



Joined: Oct 07, 2003
Posts: 735
Location: Ohio

PostPosted: Fri Apr 15, 2005 10:29 pm Reply with quote

For instance if I controlled access to a page in a module by using NSN groups by using the following. Can I add in more than one group number to check?

if (!in_groups(1, 10)) {

This doesn't seem to work for me.

It does work if I put in

if (!in_groups(10)) {


Would there be a better way to control access but still use the group concept?
 
View user's profile Send private message Visit poster's website ICQ Number
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sat Apr 16, 2005 3:40 pm Reply with quote

Have you tried passing in a string (using your example) of "1-10"? Unfortunately I do not have the code handy on my laptop to check this out, but I could have sworn that this is how multiple groups is handled.

Give it a try.
montego

P.S. In your example, you showed group 1 and group 10. If instead you wanted groups 2, 4, 6, and 10, your string would look like "2-4-6-10"

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Donovan







PostPosted: Sun Apr 17, 2005 9:57 am Reply with quote

Yep...I think it was the "" and the - for the groups. I had a comma with no ""

Thanks
 
montego







PostPosted: Sun Apr 17, 2005 9:19 pm Reply with quote

It is the dashes...
 
BobMarion
Former Admin in Good Standing



Joined: Oct 30, 2002
Posts: 1037
Location: RedNeck Land (known as Kentucky)

PostPosted: Sun Apr 17, 2005 9:28 pm Reply with quote

$groups = array("1", "2",......."10);
if (!in_groups($groups)) {

_________________
Bob Marion
Codito Ergo Sum
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Send e-mail Visit poster's website
montego







PostPosted: Sun Apr 17, 2005 9:46 pm Reply with quote

Bob,
Why, then, does the following work?

$groups = "1-3-4-5";
if (in_groups($groups)) {
... do code if user is assigned to any of these groups
}

I have it working in one of my modules and have tested different user-to-user group scenarios.... The appropriate code is being called based on the user/group assignments.

Maybe it is not working as I thought???? Doesn't the following line require the type of code I am using above???

Code:
   if(!is_array($gids)) { $gids = explode("-",$gids); }  


[NEVER MIND: I see that the code works either way. It explodes it into an array if it was not passed in as an array. So, bottom line is that both ways will work.]

montego[/b]
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©