There is software called IPB SDK that allows webmasters to integrate their websites into their forums (to share information and to make it interact with the forums and all that jazz).. well, when I was coding something for Universium yesterday, I needed a function that did not yet exist in the IPB SDK. This function would return positive feedback if the user belongs to one of of the specified SECONDARY groups on the forums. Because IPB uses primary groups and secondary group (primary the one being showed in profiles, the secondary is "hidden")
the SDK had a function to do what I needed, but it would only look in the user's primary group, instead of both.
So I wrote a function that would scan secondary groups as well... and the author of the SDK said that my code will be incorporated into the next version release.
function is_ingroup($groups,$member='') { global $SDK; if ($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) { return true; } else { return false; } } function is_in2group($groups, $member='') { global $SDK; $sdk_userinfo = $SDK->get_advinfo($member); $sdk_userinfo_altgroups = $sdk_userinfo['mgroup_others']; $sdk_array = explode(",", $sdk_userinfo_altgroups);
if (is_array($groups)) {
foreach ($groups as $g) { if (in_array($g, $sdk_array)) { if (!$x) { $x = true; } } } } else { if (in_array($groups, $sdk_array)) { $x = true; } } if ($x) { return true; } else { return false; } }
Documentation:
standalone function is_ingroup ( groupID [array OR int], memberid [int] )
Well return true if user memberid is in any of the groups specified in groupID. Will also return true if groupID matches any of the user memberid secondary groups
--
standalone function is_in2group ( groupID [array OR int], memberid [int] )
Will return true if user memberid has secondary usergroup that matches an entry in groupID
I just thought I'd share that. I thought it was pretty cool that a lot of the IPB community may be using my code in a few weeks
It's exactly the same thing with less lines. I don't know if it's allowed in this language.
I dont think that that is allowed. Some languages don't like you putting alot of stuff on one line. But it might work i'm not too familiar with PHP.
Also nice work Knippschild.
My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like. My crime is that of outsmarting you, something that you will never forgive me for.
This site is part of the Defy Media Gaming network
The best serving of video game culture, since 2001. Whether you're looking for news, reviews, walkthroughs, or the biggest collection of PC gaming files on the planet, Game Front has you covered. We also make no illusions about gaming: it's supposed to be fun. Browse gaming galleries, humor lists, and honest, short-form reporting. Game on!